displaying pgm file in python

W

wilson

i converted an 8bit rgb .jpg file into .pgm using adobe photoshop and
a plugin from http://photoshop.pluginsworld.com/p...senman/portable-pixmap-importer-exporter.html
I want to check if this file can be properly displayed.
Image opening and show() in PIL fails to do it so i tried Tkinter

i created a canvas in a tkinter gui and tried
self.myimg=PhotoImage(file="mytestpic.pgm")

self.selimgtag=self.canvorig.create_image(70,100,image=self.myimg)
self.canvorig.update_idletasks()

this causes AttributeError snd says can't identify image file
I checked the asci text of .pgm file ,it starts with a line P2 and
then several lines with integers..can someone tell me if there is a
way to display this properly

thanks
W
 
G

Gabriel Genellina

i converted an 8bit rgb .jpg file into .pgm using adobe photoshop and
a plugin from
http://photoshop.pluginsworld.com/p...senman/portable-pixmap-importer-exporter.html
I want to check if this file can be properly displayed.
Image opening and show() in PIL fails to do it so i tried Tkinter
I checked the asci text of .pgm file ,it starts with a line P2 and
then several lines with integers..can someone tell me if there is a
way to display this properly

P2 is a rather old variant that it's not in use anymore AFAIK. Try
replacing P2 with P5; at least PIL should recognize it, I think. PIL can
read and write .pgm, why don't you do the conversion with PIL?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top