473,765 Members | 2,002 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Pil Raw Image Viewer-- How to get image mode

Hello Ive been messing around with a simple raw image viewer using Pil
and Tkinter

However I am running into problems displaying the images they appear to
be not correct I believe it is cause of the modes for the different
files but I am unsure

If someone could examine my code and assist in helping me solve my
problem(s)

It would be greatly appreciated

from Tkinter import *
import Image, ImageTk
import os
import tkFileDialog
size = 1024, 768

def getfiles():
try:
entry.delete(0, END)
global fileopen
fileopen = tkFileDialog.as kdirectory()
entry.insert(EN D, fileopen)
finally:
listb.delete(0, END)
filenames = {'': []}
getfileext = fileentry.get()
path = entry.get()
for root, dirs, files in os.walk(path):
for name in files:
lname = name.lower()# if on windows
global names
for ext, names in filenames.iteri tems():
if lname.endswith( getfileext):
names.append(os .path.join(root , name))
listb.insert(EN D, name)
break
def select(event):
selection = listb.curselect ion()
global selectit
selectit = names[int(selection[0])]
global im
image_file = open(selectit, 'rb')
data = image_file.read ()
im = Image.fromstrin g("RGB", (size), data, "raw")
im.thumbnail((7 00, 700))
image = ImageTk.PhotoIm age(im)
label["image"]=image
label.image = image

root = Tk()
root.title("Eng rooved Image Viewer")
root.wm_resizab le(0, 0)
root.wm_iconbit map("shinobi.ic o")

frame = Frame(root)

im = Image.open("sta rtimage.jpg")
image = ImageTk.PhotoIm age(im)
##canvas = Canvas(frame, width=400, height=400)
##canvas.create _image(0, 0, image=image)
##canvas.grid(r ow=0, column=0, sticky=N+S+W+E)
label = Label(frame, image=image)
label.image = image
label.grid(row= 0, column=0, sticky=N+S+W+E)

scrollbar2 = Scrollbar(frame )
scrollbar2.grid (row=0, column=2, rowspan=1, columnspan=1, stick=N+S)

listb = Listbox(frame, selectmode=SING LE)
listb.grid(row= 0, column=1, columnspan=1, sticky=N+S+W+E)
listb.bind('<Bu ttonRelease-1>', select)
scrollbar2.conf ig(command=list b.yview)
listb.config(ys crollcommand=sc rollbar2.set)
frame.grid(stic ky=N+S+W+E)

frame3 = Frame(root)

entry = Entry(frame3)
entry.grid(row= 1, column=1, stick=W+E, columnspan=1)
label2 = Label(frame3, text="EXT").gri d(row=1, column=2)
fileentry = Entry(frame3)
fileentry.grid( row=1, column=3, columnspan=1, sticky=W+E)
button = Button(frame3, text="Open and List Directory", command=getfile s)
button.grid(row =1, column=4)
frame3.grid(sti cky=W+E)
root.mainloop()
Ty

Cheers
Apr 5 '07 #1
0 2361

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

Similar topics

4
13747
by: Shumit Rehman | last post by:
Hi I have a table which has path names to photos I would like to view. I would like to open some/any kind of image viewer(Paint) to see the picture when I click the pathname. The pictures are mostly scanned newspaper atricles which are too big to just display on a form so I need the zoom and scroll features. Im using access 2003
2
3833
by: John Fryatt | last post by:
Hi, Before I go on, let me just say I'm fairly new at this so excuse me if I say the wrong thing or use the wrong term. Anyway, what I am trying to do is to set up something where I can have a database of images and associated details. I want to run the system on a machine with a dual-head video adapter and have the Access window, showing a form, on one screen and an image viewer program on the other (the 'other' will actually be a...
1
3208
by: Dan | last post by:
I must develop a (C-sharp) winforms application which should display some relatively large (e.g. 2~5 MB JPEG each) photographic images together with a rich set of related information: the application should allow the user to view each image with the 'standard' set of view features such as zooming in/out, panning, scrolling, etc. (of course without annoyances such as flickering and the like), and also offer image-map like functionality: for...
0
3360
by: Jerry J | last post by:
I have a third party image viewer that can display various types of images. The image viewer is ActiveX and lives inside of Internet Explorer. To get the image viewer to retrieve an image, java script on the client looks something like this: VIEWER.GetImage("http://www.url.com/SomeImage.jpg") VIEWER.GetImage("http://www.url.com/SomeImage.tif")
4
2036
by: Troy | last post by:
Hi all, Im a little new to ASP.NET. I'm looking to create an image viewer that zooms in, pretty common. But I need to draw a box on the 1:1 scale image and 'zoom in' on another picture box. The box outlining the zoom area would change in size according to the level of zoom of course. The help I need is how to get the target box to appear over the 1:1 scale image. I want it to be able to be dragged to a new location in the full
1
1735
by: Kuldeep | last post by:
Hello All, Could you please give me some leads on building a Image Viewer in .NET or how to use Windows Picture and Fax Viewer. The actual purpose is to display the image in my web application on the fly. Regards Kuldeep
1
7151
by: zee | last post by:
hello Is it possible to use Document Image Viewer Control in ASP.NET(2.0) because 1. The IDE is not adding this component in the toolbox and 2. when i use it so it give me following error "ActiveX control 'ef347a62-ba21-42e4-94a0-1c0a6d7fdfe7' cannot be instantiated because the current thread is not in a single-threaded apartment."
4
6470
by: =?Utf-8?B?RnJhbmsgVXJheQ==?= | last post by:
Hi all I need to do a image viewer, just to view and zoom pictures in jpeg. I do not need to edit or save the picture. I am sure, there are some controls already made. I am thankful for any comment on that ! Best regards Frank Uray
0
1647
by: marcellus7 | last post by:
Im looking for an image viewer that supports most types of image formats, including PDFs, and has the ability to rotate/zoom, and draw on an image. I've been looking but to no avail. Does anyone have any suggestions on the best way of going about modifying a control so that I would have these features? The main problem that I am running into is the lack of the ability to draw on an image. Im still sort of a newbie to .NET, any ideas will help. ...
1
9951
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
9832
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
8831
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...
1
7378
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6649
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
5275
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
5421
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3531
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2805
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.