473,664 Members | 2,967 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

compatible image type

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.spl it(os.path.base name(pathname), '.' )[1]

then later on i want to create a Photoimage using

ImageTk.PhotoIm age(file=pathna me) 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(some thing like
[''jpg','jpeg',' png','gif'...] ) or is there a better way?

gordon
Jul 4 '08 #1
2 1363
On Fri, 04 Jul 2008 01:15:30 -0700, gordon wrote:

then later on i want to create a Photoimage using

ImageTk.PhotoIm age(file=pathna me) 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(some thing 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
Jul 4 '08 #2
gordon wrote:
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.spl it(os.path.base name(pathname), '.' )[1]

then later on i want to create a Photoimage using

ImageTk.PhotoIm age(file=pathna me) 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(some thing like
[''jpg','jpeg',' png','gif'...] ) or is there a better way?

gordon
You do know that there is a method for getting extensions easily?

extn = os.path.splitex t(pathname)[1]

Note: It does include the '.' separator (e.g. it returns .txt) but that's easy
to handle.

If you just catch the exception (as Mark suggested), you don't even have to look
at the extension.

-Larry
Jul 4 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
3342
by: Pierre Tremblay | last post by:
Hi! I am trying to display an image in my html document. The document contains the following line: <td class="Input"><img src=getimage.php?tbl=dbo.Employees&type=jpg&col=Photo&idCol=EmployeeID&id=1 Border=0 alt=''>&nbsp;</td>
3
11753
by: dave | last post by:
Hello there, I am at my wit's end ! I have used the following script succesfully to upload an image to my web space. But what I really want to be able to do is to update an existing record in a table in MySQL with the path & filename to the image. I have successfully uploaded and performed an update query on the database, but the problem I have is I cannot retain the primary key field in a variable which is then used in a SQL update...
5
1912
by: Leif K-Brooks | last post by:
I need to do some simple image editing (pretty much just scaling) in a GPLed program. Unfortunatly, both of the Python libraries for image editing that I found (gdmodule and PIL) are under the GPL-incompatible original BSD license. Is there another library under a friendlier library?
6
1343
by: MLH | last post by:
For instance, is it common practice to drop a PDF image onto an Access 97 form as a 'background', superimposing textbox data fields over it as a fill- in-the-blank type form? Same for reports? Direct experience anyone?
9
3466
by: christer-sandberg | last post by:
When I typecast a function and call it trough the casted pointer (se code below) I get the warnings: warning: function called through a non-compatible type if this code is reached, the program will abort and the gcc generates abort code for the call. This happens when I use gcc 3.4 but not when I use 3.3. Is there any flag that can change this behavior? I am aware that ANSI-99 says (in 6.3.2.3-8): "If a converted pointer is used to call...
0
2036
by: M K | last post by:
Okay, here is my message: The base class includes the field 'Preview1', but its type (ICUser.uCtrlPreview) is not compatible with the type of control (ASP.previewImg_ascx). What I am trying to do is use a user control I created in a page. This control is a composite of an image and a couple of labels. I wanted include properties through the code behind. So I have my ascx file with it's codebehind file. In my ascx file I have this tag:...
5
5342
by: max | last post by:
Dear all, I did the following analysis to conclude that the following pointer types are not compatible. Please let me know If my analysis and interpretation of the C standard are correct: const char * : "pointer to const-qualified char". char *: "pointer to char". Are these pointed-to types compatibles?
7
2447
by: Inny | last post by:
Hello again, Im using the code below in a child page (popup), the images are called from the parent page. When the changer is running, the child page goes white between images. I realise this is happening because the Images are not cached (yet) on the users browser. I tried preloading images with the 2nd code below in the childpage head and in the parent page head and both. no joy, dosent seem to actually 'preload' the pics. (i also gave...
0
10753
Debadatta Mishra
by: Debadatta Mishra | last post by:
Introduction In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information inside an image, hide your complete image as text ,search for a particular image inside a directory, minimize the size of the image. However this is not a new concept, there is a concept called Steganography which enables to conceal your secret...
0
8437
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8778
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8549
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8636
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7375
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5660
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4185
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4351
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2003
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.