Cuelogic Blog Icon
Cuelogic Career Icon
Home > Blog > All > Convert iPhone PNG (compress files) to standard PNG using PNGConverter

Convert iPhone PNG (compress files) to standard PNG using PNGConverter

I was trying to use the PNG images stored in iPhone in my PHP program.

While analyzing the task I came to know that Apple compressed all the PNG Images which are not visible in window and Linux machine but visible on mac machine.

To use the PNG files, I have to uncompressed these files but unfortunately there is no API or library available to uncompress such files.

While googling I came across the java desktop application (.jar file) which converts compressed iPhone file to PNG image.

In this blog we will see 3 sections which will convert iOS PNG (compress files) to standard PNG using PNGConverter

 

1. How to install Java on Linux (We used Fedora 8 – 32 bit)

2. Test Jar file working or not

3. Integrate/Execute .jar file in PHP program

 

1. How to install Java on Linux

a) Download any java jdk version. http://java.sun.com/javase/downloads/index.jsp

b) Click download, select Linux platform, language and accept license and continue.

c) Select tar file and download(jdk-7u45-linux-x64-demos.tar.gz)

d) Extract file

tar xvf filename.tar

It will generate .rpm file

e) Install package

 rpm -ivh filename.rpm

f) Follow same procedure and install jre on system

 rpm -ivh jre-7u45-linux-x64.rpm

g) To confirm installation of java

 java -version

It will return installed java package information

 

2. Test Jar file working or not

a) Run below command to checking is jar file working

java -jar PNGConverter.jar Icon.png

P.S. Download PNGConverter.jar file from here

If above command throws following error

 Exception in thread "main" java.lang.UnsatisfiedLinkError: /usr/java/jre1.7.0_45/lib/i386/xawt/libmawt.so: libXext.so.6: cannot open shared object file: No such file or directory
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary1(Unknown Source)
at java.lang.ClassLoader.loadLibrary0(Unknown Source)
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.load0(Unknown Source)
at java.lang.System.load(Unknown Source)
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary1(Unknown Source)
at java.lang.ClassLoader.loadLibrary0(Unknown Source)
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
at sun.security.action.LoadLibraryAction.run(Unknown Source)
at sun.security.action.LoadLibraryAction.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.awt.Toolkit.loadLibraries(Unknown Source)
at java.awt.Toolkit.<clinit>(Unknown Source)
at java.awt.Component.<clinit>(Unknown Source)

b) then install below dependent package of jar file

sudo yum install libXext

yum -y install firefox.i386

yum -y install libXtst.i386

 

3. Integrate/Execute .jar file in PHP program

a) Pass image path as command line argument.
In PHP, execute command using exec

exec('java -jar 'path'./PNGConverter.jar 'path'/'.$image);

b) java (.jar) file process this image and create new uncompress image on same location. which is visible in window and linux machine.