How do I create a pickleable file from a PIL Image object such that you could save those images as a single pickle file then maybe upload to another computer such as a server running PIL and unpickle it there?
相关问题
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- How to get the background from multiple images by
- Evil ctypes hack in python
- Correctly parse PDF paragraphs with Python
You can convert the Image object into data then you can pickle it:
And back to an Image:
NOTE: As
astex
mentioned, if you're using Pillow (which is recommended instead of PIL), thetostring()
method is deprecated fortobytes()
. Likewise withfromstring()
forfrombytes()
.Slight variation of Gerald's answer using keyword args
create pickleable object
or
unpickle back to image