I have found a PHP project that wraps all the main command line image optimizer’s, this is something I have been looking for, for a while now.
The problem I am having so far is I am wanting to run this on a Windows system. Below are some of the commands that are run from the scripts.
So my question would be, how would I go about running these external programs on my windows system, they do have windows versions, it’s just a matter of getting this PHP to call the correct commands.
So things like /usr/bin/identify how would this translate to being ran on a Windows system?
exec("/usr/bin/identify -quiet -format \"%m\" $file_path", $return, $error);
$cmd = "/usr/bin/jpegtran -copy none -progressive -optimize $src_file > $dest_file";
$cmd = "/usr/bin/convert $src_file $raw_file";
exec("/usr/bin/pngcrush -rem alla -brute -reduce $raw_file $dest_file");
$cmd = "/usr/bin/gifsicle -O2 $src_file > $dest_file";
$cmd = "/usr/bin/pngquant -ordered 256 $src_file";
$cmd = "/usr/bin/pngout -c3 -d8 -y -force $quant_file $out_file";
These aren’t really Unix-specific apps. They’re a variety of graphics-editing programs. Most or all of them are probably available on Windows; you just need to install them (the way somebody else already installed them on the Unix box that your script was originally written for).
The only Unix-specific thing here is the path where it looks for the programs (
/usr/binfor everything in your example). On Windows, apps typically install to a subdirectory under eitherC:\Program FilesorC:\Program Files (x86).identifyandconvertare part of ImageMagick. You would need to download and install it, and then change theexeccall to point to the path where the EXEs were installed (e.g. underC:\Program Files). Since the install path will probably contain spaces, you’ll need to quote it, e.g.:The other apps you’re running —
jpegtran,pngcrush,gifsicle,pngquant, andpngout— are separate apps. You can Google them to find their individual download pages.