[PyQt] QImage.save() traceback

Sergi Blanch i Torné sbt at ya.com
Wed May 7 08:20:54 BST 2008


On Tuesday 06 May 2008 21:24:49 Hans-Peter Jansen wrote:
> [ignore the last message..]
>
> Am Dienstag, 6. Mai 2008 schrieb Sergi Blanch i Torné:
> > On Tuesday 06 May 2008 13:28:50 Hans-Peter Jansen wrote:
> > > Am Dienstag, 6. Mai 2008 schrieb Sergi Blanch i Torné:
> > > > Hi,
> > > >
> > > > I'm try to save some images from a QImage object, but the save method
> > > > is only responding me false. I try to fix why this method cannot do
> > > > that, but I could know the real reason.
> > > >
> > > > Do you know how to allows this method to be more expressive to
> > > > explains me something?
> > >
> > > Our favorite PyQt-ML mantra applies:
> > >
> > > Om, please provide a self contained example demonstrating your problem,
> > > Om.
> > >
> > > Pete
> >
> > mmm, interesting, It can be useful (joking).
>
> Well, while I made a funny statement, it was meant serious.
Ok, but I say kidding because my missing information was the really important 
thing to ask where. Let me send the information that you ask for.

> > Yes, I want to explain the
> > situation. I'm loading the image from PyTango (the tango's[1] python
> > binding):
> > from PyQt4 import QtCore, QtGui, Qt
> > import PyTango
> > attrImg = PyTango.AttributeProxy("lt/di/iba-01/ROIImage")
> > imgData,imgDimX,imgDimY =
> > attrImg.read().value,attrImg.read().dim_x,attrImg.read().dim_y
> >
> > And where we have an image composed by unsigned shorts, it needs a little
> > manipulation, to have an unsigned char array, with a method like:
> > 	def convertfrom(image):
> > 		shift = 4
> > 		return "".join(chr(i>>shift) for i in image )
> >
> > call like:
> > imgData8 = convertfrom(imgData)
> > To construct the object:
> > image =
> > QtGui.QImage(imgData8,imgDimX,imgDimY,imgDimX,QtGui.QImage.Format_Indexed
> >8)
> >
> > Finally the save call is:
> > image.save("/tmp/image.png","PNG")
> > image.save("/tmp/image.jpg","JPG")
> > image.save("/tmp/image.tiff","TIFF")
> >
> > And all this calls return False (and the file is not in the directory).
> > The image is shown in a widget and it seems nice.
>
> You didn't provide a self contained example again. Reduce your problem to a
> pure PyQt script, and provide the image somehow, if you really expect help
> from this list.

I attach an standalone python script, without tango, using a simply black 
image. Before I was using ipython. 
Maybe I can provide a little more information, because changing the format of 
the image I found how to save it, and further more from the attached script I 
receive the message 'libpng error: Valid palette required for paletted 
images' for the first 8 bit grayscale image (not the second!).

My main question is how I can have a longer answer that true of false, because 
having only this I cannot distinguish if the problem becomes from the image, 
the filesystem, or wherever.

Thanks

/Sergi.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.py
Type: application/x-python
Size: 615 bytes
Desc: not available
Url : http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20080507/a742ace3/image-0001.bin


More information about the PyQt mailing list