How to pass PIL image to Add_Picture in python-pptx
<p>I'm trying to get the image from clipboard and I want to add that image in  python-pptx .
I don't want to save the image in the Disk. 
I have tried this:</p>

<pre><code>from pptx import Presentation
from PIL import ImageGrab,Image
from pptx.util import Inches
im = ImageGrab.grabclipboard()
prs = Presentation()
title_slide_layout = prs.slide_layouts[0]
slide = prs.slides.add_slide(title_slide_layout)
left = top = Inches(1)
pic = slide.shapes.add_picture(im, left, top)
prs.save('PPT.pptx')
</code></pre>

<p>But Getting this error</p>

<pre><code>File "C:\Python27\lib\site-packages\PIL\Image.py", line 627, in __getattr__
    raise AttributeError(name)
AttributeError: read
</code></pre>

<p>What is wrong with this?</p>

<p>The image needs to be in the form of a stream (i.e. logical file) object. So you need to "save" it to a memory file first, probably StringIO is what you're looking for.</p>

<p><a href="http://stackoverflow.com/questions/646286/python-pil-how-to-write-png-image-to-string">This other question</a> provides some of the details.</p>

python python-imaging-library python-pptx