[Image-SIG] open, show, png, blank
Matthias Bock
matthiasbock at users.sourceforge.net
Sun Feb 5 12:20:36 CET 2012
It really is a PNG and it's 16-bit grayscale.
$ file gcp.png
gcp.png: PNG image data, 1024 x 768, 16-bit grayscale, non-interlaced
I can reproduce, the blank white show() output,
which clearly is a bug in PIL.
PIL opens it in "I" mode
print im.mode
which means "integer", but I don't know whether this is correct
or not. Maybe "I;16" or so could be tried.
See http://svn.effbot.org/public/tags/pil-1.1.4/libImaging/Unpack.c
for possible modes.
QuickFix: Make a JPG.
$ convert gcp.png gcp.jpg
...
im = Image.open('gcp.jpg')
...
Have a nice day,
Matthias
Am Samstag, den 04.02.2012, 10:58 -0500 schrieb Chris Mitchell:
> Hey Nelson,
>
> Are you sure this image isn't actually a tiff (Every gel scanner I've ever
> used outputs tiffs)? Also, is it opening as an 8 bit image or a 16 bit?
> For a gel scan, it should be a 16 bit image, so you can consider forcing
> the mode while opening it..
>
> Chris
>
> On Tue, Jan 31, 2012 at 1:38 PM, Nelson Tong <tongsnelson.ise at gmail.com>wrote:
>
> > thanks for reply, Matthias,
> >
> > when I use "show()", the image appears to have an all-white
> > background, nothing else is on it. The size does indeed match the png
> > size , I used the following to confirm:
> >
> > x, y = outIm.size
> > print "size of outImg: " + str(x)+" " + str(y);
> >
> > I tries to resave the png as a png image with a different name using
> > PIL and show() of the 2nd png image still appear to have all-white
> > background with nothing on it.
> >
> > but If I open the images (both the 1st and the re-saved image ) with
> > the command line command of "display", I can see the images via
> > ImageMagick.
> >
> > Attached is example image which I am having problem with. Can you
> > reproduce the same problem I'm seeing with this image, possibly due to
> > the png image being broken?
> >
> > -N.
> >
> >
> > On 1/29/12, Matthias Bock <matthiasbock at users.sourceforge.net> wrote:
> > > Am Freitag, den 27.01.2012, 11:11 -0500 schrieb Nelson Tong:
> > >
> > >> outI = Image.open( fileOutPNGFile )
> > >> outI.show();
> > >>
> > >> The code run without error, but the image return via X-windows on my
> > >> linux machine is a blank image, without visible graphic on it.
> > >
> > > What color is this "blank": Grey? White?
> > > Does the size match the PNG size?
> > >
> > >> I am 100% positive that the image of fileOutPNGFile is not corrupted
> > >> because I am able to open it via the web-browser.
> > >
> > > Web browsers can open corrupted image files.
> > >
> > >> I tried the same code another to open another png file which I use
> > >> PIL to draw and save as png. The code above is able to open and show
> > >> this png file properly.
> > >
> > > Sounds to me, as if the first PNG was broken.
> > >
> > > Try this:
> > >
> > > outI = Image.open( fileOutPNGFile )
> > > outI.show()
> > > outI.save('test.png')
> > > out2 = Image.open('test.png')
> > > out2.show()
> > >
> > >> why might this happen?
> > >
> > > If the code doesn't help solving the issue,
> > > could you send the PNG to the list?
> > >
> > > Cheers, Matthias
> > >
> > >
More information about the Image-SIG
mailing list