Look into the cinemaIO directory of ParaView. We move back and forth
between paraview, numpy and PIL often there.

For example:
image = self.view.CaptureWindow(1)
ext = image.GetExtent()
width = ext[1] - ext[0] + 1
height = ext[3] - ext[2] + 1
imagescalars = image.GetPointData().GetScalars()
idata = numpy_support.vtk_to_numpy(imagescalars)
image.UnRegister(None)
imageslice = idata.reshape(height, width, 3)
imageslice = numpy.flipud(imageslice)
pimg = PIL.Image.fromarray(imageslice)

David E DeMarle
Kitware, Inc.
R&D Engineer
21 Corporate Drive
Clifton Park, NY 12065-8662
Phone: 518-881-4909

On Wed, Oct 12, 2016 at 1:42 PM, Albina, Frank <frank.albina@sauber-
motorsport.com> wrote:

> All,
>
> A simple question: my incentive is to manipulate images using PIL in a
> pvbatch script. At the time being, I am writing the images to file in PNG
> format and reading the file again from disc using PIL. I have found out
> that the underlying image writing is performed by the vtkPNGWriter class
> and that this class allows to write to memory (vtkPNGWriter.SetWriteToMemory).
> Hence my question: Is it possible to “write” a PNG file to memory so that I
> can  process it further using PIL? If so, how shall I proceed?
>
> Thank you very much in advance.
>
> Cheers,
>
> Frank.
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensou
> rce/opensource.html
>
> Please keep messages on-topic and check the ParaView Wiki at:
> http://paraview.org/Wiki/ParaView
>
> Search the list archives at: http://markmail.org/search/?q=ParaView
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/paraview
>
>
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the ParaView Wiki at: 
http://paraview.org/Wiki/ParaView

Search the list archives at: http://markmail.org/search/?q=ParaView

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/paraview

Reply via email to