# Serialization with pickle or otherwise (how to make PImage serializable?)

**URL:** <https://discourse.processing.org/t/serialization-with-pickle-or-otherwise-how-to-make-pimage-serializable/27823>\
**Category:** Processing.py\
**Created:** [February 14, 2021, 7:31pm UTC](https://discourse.processing.org/t/serialization-with-pickle-or-otherwise-how-to-make-pimage-serializable/27823 "2021-02-14T19:31:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![villares](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/villares/32/3166_2.png) [@villares](https://discourse.processing.org/u/villares)\
**Post date:** [February 14, 2021, 7:31pm UTC](https://discourse.processing.org/t/serialization-with-pickle-or-otherwise-how-to-make-pimage-serializable/27823/1 "2021-02-14T19:31:34Z")

</div>

I usually use Python’s `pickle` module for serialization. But it doesn’t work with Processing objects from `PImage`, or `PVector`.

There is this other Java strategy that has the same problem.

```python
from java import io
def saveObject(x,fname="jython.bin"):
    outs=io.ObjectOutputStream(io.FileOutputStream(fname))
    outs.writeObject(x)
    outs.close()
def loadObject(fname="jython.bin"):
    ins=io.ObjectInputStream(io.FileInputStream(fname))
    x=ins.readObject()
    ins.close()
    return x

# p = createImage(RGB, 100, 100)
# image(p, 0, 0)
x={1:1,'two':"2",'three':[1,2,3]}
saveObject(x)
p=loadObject()
print p

```

Is it possible to “mark” PImage as serializable?  
[http://www.javapractices.com/topic/TopicAction.do?Id=45](http://www.javapractices.com/topic/TopicAction.do?Id=45)
