[SOLVED] How would you crop a PNG stored as a byte-string?
I have a Python question for anyone who is familiar with the imgkit-module. Note the following example ... html_str = '<html><body>Hello World!</body></html>' imgkit.from_string(html_str, 'example.png') ... After running the code above, you would have a PNG named 'example.png' of what the HTML code would look like if you would have saved it as an html-file and opened it. Essentially, what imgkit does is screenshot things. A couple of other methods, besides 'from_string', would be 'from_url' and 'from_file' ... There's another way to implement this tool, and this is where my question is introduced ... img = imgkit.from_string(html_str, False) ^ The above code would have the image NOT saved to your harddisk, and instead assigns the image as a bytestring to 'img'. My question is ... "How might you resize the image while it's stored in a bytestring, without saving it to anything (creating/manipulating it in-memory only)?" I know PIL's Image module has resize methods, etc, but how in the world would you accomplish this on an image stored as a bytestring?