compatible image type

Discussion in 'Python' started by gordon, Jul 4, 2008.

  1. gordon

    gordon Guest

    hi
    in my application a file selection by user returns a pathname string
    like F:/images/png/my.png or F:/docs/text/somedoc.txt ....etc.
    I can get the extension using
    extn=string.split(os.path.basename(pathname),'.' )[1]

    then later on i want to create a Photoimage using

    ImageTk.PhotoImage(file=pathname) and display it on a canvas.

    the extn can be anything ..even zip or bat ,doc whatever depending on
    user selection...I want to put someway to raise an error message to
    the user if he selects a file with extension not of a compatible image
    type for PhotoImage.How should i do this? should i check 'extn' to a
    list of compatible image type extensions(something like
    [''jpg','jpeg','png','gif'...] ) or is there a better way?

    gordon
    gordon, Jul 4, 2008
    #1
    1. Advertising

  2. On Fri, 04 Jul 2008 01:15:30 -0700, gordon wrote:


    > then later on i want to create a Photoimage using
    >
    > ImageTk.PhotoImage(file=pathname) and display it on a canvas.
    >
    > the extn can be anything ..even zip or bat ,doc whatever depending on
    > user selection...I want to put someway to raise an error message to
    > the user if he selects a file with extension not of a compatible image
    > type for PhotoImage.How should i do this? should i check 'extn' to a
    > list of compatible image type extensions(something like
    > [''jpg','jpeg','png','gif'...] ) or is there a better way?


    Just catch the exception raised by `PhotoImage` if a non compatible file
    was selected!?

    Ciao,
    Marc 'BlackJack' Rintsch
    Marc 'BlackJack' Rintsch, Jul 4, 2008
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?UmV6YSBOYWJp?=
    Replies:
    3
    Views:
    5,525
    =?Utf-8?B?ZWlsZWVuIG0=?=
    Jun 16, 2004
  2. =?Utf-8?B?TSBL?=
    Replies:
    1
    Views:
    21,593
    AbhijitSinha
    Nov 20, 2006
  3. John Dalberg
    Replies:
    1
    Views:
    6,391
  4. mreister
    Replies:
    1
    Views:
    3,122
    mreister
    May 25, 2010
  5. pantagruel
    Replies:
    0
    Views:
    226
    pantagruel
    Feb 17, 2006
Loading...

Share This Page