displaying pgm file in python

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • wilson

    displaying pgm file in python

    i converted an 8bit rgb .jpg file into .pgm using adobe photoshop and
    a plugin from http://photoshop.pluginsworld.com/pl...-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=Phot oImage(file="my testpic.pgm")

    self.selimgtag= self.canvorig.c reate_image(70, 100,image=self. myimg)
    self.canvorig.u pdate_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
  • Gabriel Genellina

    #2
    Re: displaying pgm file in python

    En Fri, 04 Apr 2008 19:07:59 -0300, wilson <wilson.t.thomp son@gmail.com>
    escribió:
    i converted an 8bit rgb .jpg file into .pgm using adobe photoshop and
    a plugin from

    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?

    --
    Gabriel Genellina

    Comment

    Working...