[Paraview] image quality for JPEG writer in pvpython

Berk Geveci berk.geveci at kitware.com
Wed Jan 7 08:24:32 EST 2009


Hmmm. This is possible if you have access to the ParaView build tree.
Here is the abbreviated C++ implementation of WriteImage:

  vtkImageData* shot = this->CaptureWindow(magnification);
  writer->SetInput(shot);
  writer->SetFileName(filename);
  writer->Write();

You can call CaptureWindow() on the view and get an image data back.
Then, you can create you own write and set the quality on it. This is
the tricky part. You  need the import the full VTK module. To do that,
you have to add <build tree prefix>/ VTK/Wrapping/Python to your
PYTHONPATH. Then, you can do:

import vtk
writer = vtk.vtkJPEGWriter()
writer.SetInput(shot)
writer.SetQuality(80)
writer.Write()

-berk


On Wed, Jan 7, 2009 at 4:56 AM, Sala, Marzio <marzio.sala at bmw-sauber.com> wrote:
> Hello All,
>
> I am working with pvpython/pvbatch. I need to save some JPEG files, which I
> do using something like:
>
> view.WriteImage(outputdir + filename, "vtkJPEGWriter")
>
> The resulting JPEG files have a 95% quality, which turns out to be too much
> for what I am doing (in terms of file size).
> I
> s there a way to specify the quality of the JPEG files saved using
> WriteImage()?
>
> If this is not possible, can somebody suggest how to tweak the ParaView
> sources to save with a different quality?
>
> Many thanks,
> -Marzio
>
> _______________________________________________
> ParaView mailing list
> ParaView at paraview.org
> http://www.paraview.org/mailman/listinfo/paraview
>
>


More information about the ParaView mailing list