FAQ Database Discussion Community

Saving an image with shell_exec() - using imagejpeg & jpegoptim, with stdin / stdinout

I'm saving an image twice, once when I create it with imagejpeg and then I compress and overwrite with jpegoptim. How may I do this in one swoop, so I'm not saving the image twice? $im = imagecreatefromstring($imageString); imagejpeg($im, 'img/test.jpg', 100); shell_exec("jpegoptim img/test.jpg"); Jpegoptim have stdin and stdout, but I'm...

Python: Optimizing Images in Memory (StringIO & POpen with jpegoptim)

I'm trying to compress images without touching disk using the STDIN version of various libraries(jpegoptim in this example). This code does not return an optimized(jpegoptim compressed) image. Can someone please help or explain why this usage of Popen() with a StringIO.StringIO() object does not return the optimized version of the...