Reputation: 48933
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";
Upvotes: 1
Views: 435
Reputation: 97696
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/bin
for everything in your example). On Windows, apps typically install to a subdirectory under either C:\Program Files
or C:\Program Files (x86)
.
identify
and convert
are part of ImageMagick. You would need to download and install it, and then change the exec
call to point to the path where the EXEs were installed (e.g. under C:\Program Files
). Since the install path will probably contain spaces, you'll need to quote it, e.g.:
exec("\"C:\\Program Files (x86)\\ImageMagick-6.6.1-Q16\\identify\" -quiet -format \"%m\" $file_path", $return, $error);
The other apps you're running -- jpegtran
, pngcrush
, gifsicle
, pngquant
, and pngout
-- are separate apps. You can Google them to find their individual download pages.
Upvotes: 2