Image object etching?
2 answers
You can do it like this:
file = open('data.pkl', 'wb')
# Pickle dictionary using protocol 0.
pickle.dump(image, file)
file.close()
For reading in a dictionary, you can do it like this:
file = open('data.pkl', 'rb') image = pickle.load(pkl_file) print image file.close()
You can also dump data twice:
import pickle
# Write to file.
file = open("data.pkl", "wb")
pickle.dump(image1, file)
pickle.dump(image2, file)
file.close()
# Read from file.
file = open("data.pkl", "rb")
image1 = pickle.load(file)
image2 = pickle.load(file)
file.close()
+4
source to share
Just call pickle.dump
, just like you would for everything else. You have a dict whose values ββare simple types (strings, tuples of a pair of numbers, etc.). The fact that he came from an image doesn't matter.
If you have a bunch of them, they appear to be stored in a list or some other structure, and you can make a list of favorites.
So:
with open('data.pkl', 'wb') as f:
pickle.dump(images, f)
+2
source to share