phpjpegoptim

jpegoptim dont seem to work with shell_exec


When I am trying to use jpegoptim with php with this very basic shell_exec :

$output = shell_exec('jpegoptim /home/domain/public_html/test.jpg');
echo $output;

I got this output :

/home/domain/public_html/test.jpg 2010x1128 24bit N Exif IPTC ICC JFIF [OK]

I dont know what this mean but I know that it doesnt work, the image still the same size, same quality.

I know that jpegoptim is well installed because when I am doing the same command in the Terminal its working fine :

jpegoptim test.jpg test.jpg 2010x1128 24bit N Exif IPTC ICC JFIF [OK] 53587 --> 23790 bytes (55.60%), optimized.

Any idea ?


Solution

  • jpegoptim works well with shell_exec just cross check your file & folder permission, it should be 0777