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 image? If I save the file to disk, it works just fine. import sys import urllib2 as urllib import StringIO from subprocess import Popen, PIPE, STDOUT fp = urllib