From tapenet at cox.net Fri Apr 1 06:14:15 2005 From: tapenet at cox.net (Martin Aherron) Date: Fri Apr 1 06:14:19 2005 Subject: [Image-SIG] PIL 1.1.5 - seek(0) on StringIO file object Message-ID: <20050401041415.IBVV6521.lakermmtao02.cox.net@smtp.east.cox.net> This is in the online docs for the PIL -------------- Reading from a string import StringIO im = Image.open(StringIO.StringIO(buffer)) Note that the library rewinds the file (using seek(0)) before reading the image header. ------------- I just downloaded Version 1.1.5 and found that the library is not doing the seek before reading from the StringIO object. Adding a seek(0) just prior to an Image.open fixed the problem. From rsgalloway at yahoo.com Sun Apr 3 01:06:06 2005 From: rsgalloway at yahoo.com (Ryan Galloway) Date: Sun Apr 3 01:06:09 2005 Subject: [Image-SIG] PIL support: scaling hires images Message-ID: <20050402230606.85309.qmail@web51510.mail.yahoo.com> Greetings, I am experiencing problems trying to scale down or create thumbnails from images which are high resolution, say greater than 2,048 x resolution. Is there a way around this? Regards, Ryan __________________________________ Yahoo! Messenger Show us what our next emoticon should look like. Join the fun. http://www.advision.webevents.yahoo.com/emoticontest From jwt at OnJapan.net Sun Apr 3 03:06:22 2005 From: jwt at OnJapan.net (Jim Tittsler) Date: Sun Apr 3 03:06:27 2005 Subject: [Image-SIG] PIL support: scaling hires images In-Reply-To: <20050402230606.85309.qmail@web51510.mail.yahoo.com> References: <20050402230606.85309.qmail@web51510.mail.yahoo.com> Message-ID: <20050403010622.GB14439@server.onjapan.net> On Sat, Apr 02, 2005 at 03:06:06PM -0800, Ryan Galloway wrote: > I am experiencing problems trying to scale down or create thumbnails from > images which are high resolution, say greater than 2,048 x resolution. Is > there a way around this? What sort of problems? (What format source image?) FWIW, I'm able to scale large TIFF images without problem. (It does take about 15 seconds on my rather old machine.) >>> import Image >>> im = Image.open("/home/jwt/sat1/temp200101.tif") >>> print im.format, im.size, im.mode TIFF (8192, 4096) RGB >>> im.thumbnail((128,64)) >>> im.save("temp200101.jpg", "JPEG") -- Jim Tittsler http://www.OnJapan.net/ GPG: 0x01159DB6 Python Starship http://Starship.Python.net/ Ringo MUG Tokyo http://www.ringo.net/rss.html From postmaster at quost.com Tue Apr 5 17:18:16 2005 From: postmaster at quost.com (dnsrequest.com PostMaster) Date: Tue Apr 5 17:18:13 2005 Subject: [Image-SIG] Error sending message [1112714293573.1444.pegasus] from [dnsrequest.com] Message-ID: <20050405151811.E457F1E4004@bag.python.org> [<00>] XMail bounce: Rcpt=[dan@steelkey.com.au];Error=[550 Mailbox unavailable ] [<01>] Error sending message [1112714293573.1444.pegasus] from [dnsrequest.com]. ID: Mail From: Rcpt To: Server: [12.96.165.198] [<02>] The reason of the delivery failure was: 550 Mailbox unavailable [<05>] Here is listed the initial part of the message: Received: from python.org (84.204.14.21:2348) by mail2.dnsrequest.com with [XMail 1.17 (Win32/Ix86) ESMTP Server] id for from ; Tue, 5 Apr 2005 15:17:47 -0000 From: image-sig@python.org To: dan@steelkey.com.au Subject: hi Date: Thu, 5 May 2005 19:21:03 +0400 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_0010_58B76FF2.7B88B5C9" X-Priority: 3 X-MSMail-Priority: Normal From meesters at uni-mainz.de Wed Apr 6 13:02:36 2005 From: meesters at uni-mainz.de (Christian Meesters) Date: Wed Apr 6 13:02:40 2005 Subject: [Image-SIG] ImageFont on OSX Message-ID: <00a23da8fe023a09eb1debf6b385b2f4@uni-mainz.de> Hi I'm using PIL 1.1.4 on OSX (still standard Python 2.3) and would like to paste text into images. All I get is some rather small standard font text written into my images, because calling ImageFont.load() fails, since I cannot specify any font. Could somebody tell me which are valid fonts and where to obtain such font files? The passage in the handbook ("PIL uses it's own font file format to store bitmap fonts. You can use the pilfont utility to convert BDF and PCF font descriptors (X window font formats) to this format. ") tells me nothing: Where to get those font descriptors? And all I have are standard font files of Apple ('Font Suitcase'). Any ideas? Thanks a lot in advance, Christian From dvarrazzo at virgilio.it Wed Apr 6 17:44:23 2005 From: dvarrazzo at virgilio.it (dvarrazzo@virgilio.it) Date: Wed Apr 6 17:44:26 2005 Subject: [Image-SIG] Help with TIFF images Message-ID: <4200066600125C5F@ims1d.cp.tin.it> Hi everybody, i want to open a 16 bit grayscale TIFF file with photometric interpretation 0 (white is 0). Such files are a common densitometers product. The corrispondenting format key is (0, 1, 1, (16,), ()) in PIL 1.1.5 (it used to be (0, 1, (16,), ()) in previous releases. This key is missing from TIFF OPEN_INFO dict, resulting in an unsupported format. I addd the same value as for the key (1, 1, 1, (16,), ()), i.e. ("I;16", "I;16"). The file is open, of course, in negative form. Anyway this is not a big problem, because i don't have to display the image: i perform image processing in numarray, passing the data array to it with a fromstring()/tostring() pair. What is the correct value to read such images? When i come to save the image after editing, i pass it back to PIL via fromstring() with mode="I;16". This way the file is stored "black is 0", so i hack the interpretation bit "by hand" (some control tools only open this very combination). Can i set mode so that the file is stored "white is 0"? Thank you in advance Daniele From kevin at cazabon.com Wed Apr 6 23:15:20 2005 From: kevin at cazabon.com (kevin@cazabon.com) Date: Wed Apr 6 23:15:55 2005 Subject: [Image-SIG] Saturation function? References: <4200066600125C5F@ims1d.cp.tin.it> Message-ID: <060a01c53aed$bd5ac5b0$640aa8c0@duallie> Does anyone have a simple saturation adjustment function for PIL? I haven't been able to find anything through Google, other than a VB script for converting between HSL and RGB. That could be hacked into a saturation function, but would be VERY slow... ANy suggestions would be most welcome, thanks! Kevin. From meyer at mesw.de Wed Apr 6 23:44:01 2005 From: meyer at mesw.de (meyer@mesw.de) Date: Wed Apr 6 23:46:05 2005 Subject: =?iso-8859-1?Q?Re:_[Image-SIG]_Saturation_function??= Message-ID: <27414465$1112823759425457cff18a26.10335469@config3.schlund.de> Can't you use the ImageEnhance module? http://www.pythonware.com/library/pil/handbook/imageenhance.htm I'm no expert in these things, but I believe that the "Color" value should be what is generally called "Saturation". Markus kevin@cazabon.com schrieb am 06.04.2005, 23:15:20: > Does anyone have a simple saturation adjustment function for PIL? > > I haven't been able to find anything through Google, other than a VB script > for converting between HSL and RGB. That could be hacked into a saturation > function, but would be VERY slow... > > ANy suggestions would be most welcome, thanks! > > Kevin. > > > _______________________________________________ > Image-SIG maillist - Image-SIG@python.org > http://mail.python.org/mailman/listinfo/image-sig From kevin at cazabon.com Thu Apr 7 00:00:57 2005 From: kevin at cazabon.com (kevin@cazabon.com) Date: Thu Apr 7 00:01:34 2005 Subject: [Image-SIG] Saturation function? References: <27414465$1112823759425457cff18a26.10335469@config3.schlund.de> Message-ID: <001901c53af4$1d0d0170$640aa8c0@duallie> Thanks Markus - I skipped over that one due to the description... but you're correct that it's what I want. (the description says it's for adjusting the color balance of an image... not really an accurate description) Kevin. ----- Original Message ----- From: To: Cc: Sent: Wednesday, April 06, 2005 11:44 PM Subject: Re: [Image-SIG] Saturation function? > > Can't you use the ImageEnhance module? > > http://www.pythonware.com/library/pil/handbook/imageenhance.htm > > I'm no expert in these things, but I believe that the "Color" value > should be what is generally called "Saturation". > > > Markus > > kevin@cazabon.com schrieb am 06.04.2005, 23:15:20: > > Does anyone have a simple saturation adjustment function for PIL? > > > > I haven't been able to find anything through Google, other than a VB script > > for converting between HSL and RGB. That could be hacked into a saturation > > function, but would be VERY slow... > > > > ANy suggestions would be most welcome, thanks! > > > > Kevin. > > > > > > _______________________________________________ > > Image-SIG maillist - Image-SIG@python.org > > http://mail.python.org/mailman/listinfo/image-sig > > > From gwidion at mpc.com.br Thu Apr 7 02:11:08 2005 From: gwidion at mpc.com.br (Joao S. O. Bueno Calligaris) Date: Thu Apr 7 02:11:15 2005 Subject: [Image-SIG] Saturation function? In-Reply-To: <27414465$1112823759425457cff18a26.10335469@config3.schlund.de> References: <27414465$1112823759425457cff18a26.10335469@config3.schlund.de> Message-ID: <200504062111.08848.gwidion@mpc.com.br> On Wednesday 06 April 2005 18:44, meyer@mesw.de wrote: > Can't you use the ImageEnhance module? > > http://www.pythonware.com/library/pil/handbook/imageenhance.htm > > I'm no expert in these things, but I believe that the "Color" value > should be what is generally called "Saturation". > > If that doesn't work, RGB <-> HSV conversion is more or less simple, and I had worked it in python for a GIMP-Plugin. My conversion is for working with palettes so it is a slow implementation - you will be better if the above module works. Otherwise, I can e -mail you my script. - a NumArray version of it should be usable for raster data. JS -><- > Markus > > kevin@cazabon.com schrieb am 06.04.2005, 23:15:20: > > Does anyone have a simple saturation adjustment function for PIL? > > > > I haven't been able to find anything through Google, other than a > > VB script for converting between HSL and RGB. That could be > > hacked into a saturation function, but would be VERY slow... > > > > ANy suggestions would be most welcome, thanks! > > > > Kevin. > > > > > > _______________________________________________ > > Image-SIG maillist - Image-SIG@python.org > > http://mail.python.org/mailman/listinfo/image-sig > > _______________________________________________ > Image-SIG maillist - Image-SIG@python.org > http://mail.python.org/mailman/listinfo/image-sig From pascor22234 at yahoo.com Fri Apr 8 17:03:08 2005 From: pascor22234 at yahoo.com (Ray Pasco) Date: Fri Apr 8 17:03:11 2005 Subject: [Image-SIG] Saving to JPEG in CMYK Message-ID: <20050408150308.69551.qmail@web52703.mail.yahoo.com> When saving an RGB image to JPEG CMYK results in a totally black image. I'm using all default parameters. Is there some other parameters that are necessary ? BTW, saving to TIFF CMYK works fine. Thanks, Ray Pasco __________________________________ Do you Yahoo!? Read only the mail you want - Yahoo! Mail SpamGuard. http://promotions.yahoo.com/new_mail From pascor at hotpop.com Fri Apr 1 18:59:52 2005 From: pascor at hotpop.com (Ray Pasco) Date: Sat Apr 9 10:54:27 2005 Subject: [Image-SIG] Faster way to examine alpha ? Message-ID: <424D7E08.1080705@hotpop.com> I have a routine that examines the alpha values of an RGBA image to determine whether whether there are any "active"alpha (value < 255), and whether the any active alpha are single-valued and if only a single color is associted with this alpha. Each pixel must be examined one-by-one which is rather slow. Is there way to examine pixel values akin to the .point(lambda) method ? I just want to examine, not change the valuse. Thanks, Ray Pasco From pascor at hotpop.com Thu Apr 7 16:31:58 2005 From: pascor at hotpop.com (Ray Pasco) Date: Sat Apr 9 10:54:28 2005 Subject: [Image-SIG] HSL adjustment, and others Message-ID: <4255445E.1010707@hotpop.com> I've been playing around with just this. This program converts to/from several different colorspaces and changes the alternate colorspace's "ramp" slope and offset. The program only does linear adjustments. I've been trying to merge PIL and wxPython and since have come up with a better way to display the results, but I think you want only the processing algorithms, anyway. I don't really can't swear to the accuracy of the colorspace conversions other than they convert from RGB and then back again perfectly. I was able to correct several apparent bugs in the algorithms. I don't know where to find a "definitive" source for the algorithms, much less an explanation for how they work. I'd appreciate any comments/suggestions you may have. I intend to rewrite the app's GUI and would also appreciate finding a more useful mapping function than a linear-ramp to linear-ramp function. Ray Pasco -------------- next part -------------- import wx #---------------------------- def Pil2Bitmap (imPil): wxImage = Pil2WxImage (imPil) bitmap = WxImage2Bitmap (wxImage) return bitmap #end def def Pil2WxImage (imPil): wxImage = wx.EmptyImage (imPil.size[0], imPil.size[1]) wxImage.SetData (imPil.convert('RGB').tostring()) return wxImage #end def def WxImage2Bitmap (image): bitmap = image.ConvertToBitmap() return bitmap #end def #-------- def Bitmap2Pil (bitmap): WxImage = Bitmap2WxImage (bitmap) imPil = WxImage2Pil (WxImage) return imPil #end def def Bitmap2WxImage (bitmap): wximage = wx.ImageFromBitmap (bitmap) return wximage #end def def WxImage2Pil (wxImage): imPil = Image.new ('RGB', (wxImage.GetWidth(), wxImage.GetHeight())) imPil.fromstring (wxImage.GetData()) return imPil #end def #---------------------------- -------------- next part -------------- ## Colorspace conversions library import sys def Rgb2Cmyk (rgbtuple): def Rgb2Cmy (rgbtuple): # rgb tuple values are in [0 ... 255] r, g, b = rgbtuple[0], rgbtuple[1], rgbtuple[2], c = 1 - (r / 255.0) m = 1 - (g / 255.0) y = 1 - (b / 255.0) return c, m, y #end def Rgb2Cmy def Cmy2Cmyk (cmytuple): # cmy tuple values are in [0.0 ... 1.0] c, m, y = cmytuple[0], cmytuple[1], cmytuple[2] if (c == 1.0) and (m == 1.0) and (y == 1.0): K = 1.0 # special dispensation for absolute black to avoid division-by-zero C = 0.0 M = 0.0 Y = 0.0 else: K = min (1.0, c, m, y) C = (c - K) / (1.0 - K) M = (m - K) / (1.0 - K) Y = (y - K) / (1.0 - K) #end if return C, M, Y, K #end def Cmy2Cmyk #------------------------ # rgb tuple values are in [0...255] cmytuple = Rgb2Cmy (rgbtuple) C, M, Y, K = Cmy2Cmyk (cmytuple) return C, M, Y, K #end def Rgb2Cmyk def Cmyk2Rgb (cmyktuple): def Cmyk2Cmy (cmyktuple): # CMYK tuple values are in [0.0 ... 1.0] C, M, Y, K = cmyktuple[0], cmyktuple[1], cmyktuple[2], cmyktuple[3] c = ((C * (1.0 - K)) + K) m = ((M * (1.0 - K)) + K) y = ((Y * (1.0 - K)) + K) return c, m, y #end def Cmyk2Cmy def Cmy2Rgb (cmytuple): # cmy tuple values are in [0.0 .. 1.0] c, m, y = cmytuple[0], cmytuple[1], cmytuple[2] r = int (((1.0 - c) * 255.0) + 0.5) g = int (((1.0 - m) * 255.0) + 0.5) b = int (((1.0 - y) * 255.0) + 0.5) return r, g, b #end def Cmy2Rgb #------------------------ C, M, Y, K = cmyktuple # Make sure that CMYK values are be in [0.0 ... 1.0] C = min (max (0.0, C), 1.0) M = min (max (0.0, M), 1.0) Y = min (max (0.0, Y), 1.0) K = min (max (0.0, K), 1.0) cmytuple = Cmyk2Cmy (cmyktuple) r, g, b = Cmy2Rgb (cmytuple) return r, g, b #end def Cmyk2Rgb def Rgb2Hsl (rgbtuple): # H, S, L will be in [0.0 ... 1.0] r, g, b = rgbtuple rScaled = r/255.0 gScaled = g/255.0 bScaled = b/255.0 rgbMin = min (rScaled, gScaled, bScaled) # Min RGB value rgbMax = max (rScaled, gScaled, bScaled) # Max RGB value deltaRgb = rgbMax - rgbMin # Delta RGB value L = (rgbMax + rgbMin) / 2.0 if (deltaRgb == 0.0): # This is a gray, no chroma. H = 0.0 S = 0.0 # Done ! else: # Chromatic data... if (L < 0.5): S = deltaRgb / (rgbMax + rgbMin) else: S = deltaRgb / (2.0 - rgbMax - rgbMin) #end if deltaR = (((rgbMax - rScaled)/6.0) + (deltaRgb/2.0)) / deltaRgb deltaG = (((rgbMax - gScaled)/6.0) + (deltaRgb/2.0)) / deltaRgb deltaB = (((rgbMax - bScaled)/6.0) + (deltaRgb/2.0)) / deltaRgb if (rScaled == rgbMax): H = deltaB - deltaG elif (gScaled == rgbMax): H = (1.0/3.0) + deltaR - deltaB elif (bScaled == rgbMax): H = (2.0/3.0) + deltaG - deltaR #end if H = H % 1.0 #end if return (H, S, L) #end def Rgb2Hsl def Hsl2Rgb (hsltuple): def HslHue2Rgb (v1, v2, vH): if (vH < 0.0): vH += 1.0 if (vH > 1.0): vH -= 1.0 if ((6.0 * vH) < 1.0): return (v1 + (v2 - v1) * 6.0 * vH) if ((2.0 * vH) < 1.0): return (v2) if ((3.0 * vH) < 2.0): return (v1 + (v2 - v1) * ((2.0/3.0) - vH) * 6.0) return v1 #end def HslHue2Rgb #------------------------ # H, S, L in [0.0 .. 1.0] H, S, L = hsltuple if (S == 0.0): # RGB grayscale r = L * 255.0 # R, G, B in [0 .. 255] g = L * 255.0 b = L * 255.0 else: if (L < 0.5): var_2 = L * (1.0 + S) else: var_2 = (L + S) - (S * L) #end if var_1 = (2.0 * L) - var_2 r = 255 * HslHue2Rgb (var_1, var_2, H + (1.0/3.0)) g = 255 * HslHue2Rgb (var_1, var_2, H ) b = 255 * HslHue2Rgb (var_1, var_2, H - (1.0/3.0)) #end if r = int (r + 0.5) g = int (g + 0.5) b = int (b + 0.5) return (r, g, b) #end def Hsl2Rgb def Rgb2Hsv (rgbtuple): # H, S, V will be in [0.0 ... 1.0] r, g, b = rgbtuple r = r / 255.0 g = g / 255.0 b = b / 255.0 minRgb = min (r, g, b) maxRgb = max (r, g, b) deltaRgb = maxRgb - minRgb v = maxRgb if (deltaRgb == 0): # This is a gray, no chroma... h = 0.0 s = 0.0 else: # Chromatic data s = deltaRgb / maxRgb del_R = (((maxRgb - r) / 6.0) + (deltaRgb / 2.0)) / deltaRgb del_G = (((maxRgb - g) / 6.0) + (deltaRgb / 2.0)) / deltaRgb del_B = (((maxRgb - b) / 6.0) + (deltaRgb / 2.0)) / deltaRgb if (r == maxRgb): h = del_B - del_G elif (g == maxRgb): h = (1.0 / 3.0) + del_R - del_B elif (b == maxRgb): h = (2.0 / 3.0) + del_G - del_R #end if h = h % 1.0 #end if return (h, s, v) #end def Rgb2Hsv def Hsv2Rgb (hsvtuple): h, s, v = hsvtuple if (s == 0.0): r = v * 255.0 g = v * 255.0 b = v * 255.0 else: h = h * 6.0 I = int (h) # floor function F = h - I P = v * (1.0 - s) Q = v * (1.0 - s * F) T = v * (1.0 - s * (1.0 - F)) if (I == 4): r = T g = P b = v elif (I == 5): r = v g = P b = Q elif (I == 0): r = v g = T b = P elif (I == 1): r = Q g = v b = P elif (I == 2): r = P g = v b = T elif (I == 3): r = P g = Q b = v #end if r = int ((r * 255.0) + 0.5) g = int ((g * 255.0) + 0.5) b = int ((b * 255.0) + 0.5) #end if return (r, g, b) #end def Hsv2Rgb #-------------------------------------- # Stand-alone test for colorspaces.py if __name__ == '__main__': import Image if len(sys.argv) < 4: print print 'Colorspaces: Values for R, G and B must be given, each in the range [0..255]' print sys.exit (1) #end if r = eval (sys.argv [1]) g = eval (sys.argv [2]) b = eval (sys.argv [3]) rgbtuple = (r, g, b) #--------- HSL -------------------------------------- hsltuple = Rgb2Hsl (rgbtuple) h, s, l = hsltuple print print 'Colorspaces: RGB (%3d, %3d, %3d) ==> HSL (%1.3f, %1.3f, %1.3f)' % (r, g, b, h, s, l) print rPrime, gPrime, bPrime = Hsl2Rgb (hsltuple) print 'Colorspaces: HSL (%1.3f, %1.3f, %1.3f) ==> RGB (%3d, %3d, %3d)' % (h, s, l, rPrime, gPrime, bPrime) print #--------- CMYK ------------------------------------- cmyktuple = Rgb2Cmyk (rgbtuple) c, y, m, k = cmyktuple print print 'Colorspaces: RGB (%3d, %3d, %3d) ==> CMYK (%1.3f, %1.3f, %1.3f, %1.3f)' % (r, g, b, c, y, m, k) print rPrime, gPrime, bPrime = Cmyk2Rgb (cmyktuple) print 'Colorspaces: CMYK (%1.3f, %1.3f, %1.3f, %1.3f) ==> RGB (%3d, %3d, %3d)' % (c, m, y, k, rPrime, gPrime, bPrime) print #--------- HSV -------------------------------------- hsvtuple = Rgb2Hsv (rgbtuple) h, s, v = hsvtuple print print 'Colorspaces: RGB (%3d, %3d, %3d) ==> HSV (%1.3f, %1.3f, %1.3f)' % (r, g, b, h, s, v) print rPrime, gPrime, bPrime = Hsv2Rgb (hsvtuple) print 'Colorspaces: HSL (%1.3f, %1.3f, %1.3f) ==> RGB (%3d, %3d, %3d)' % (h, s, v, rPrime, gPrime, bPrime) print #end if -------------- next part -------------- import wx import Image import os, sys from colorspaces import * # pil <--> hsl, hsv, cmyk from imageconverts import * # pilIm --> bitmap #---------------------------- import inspect, os def pressenter (prompt='\npress return...'): raw_input (prompt) def rangelen(listobj): return xrange(len(listobj)) def showStack(): for stack in inspect.stack(): print stack[2:4] #end def exit = os._exit def delFileExist (filename): if os.path.exists (filename): os.remove (filename) #end def #---------------------------- global filpathname; filepathname = None # create the global instance global thumbnailXsize; thumbnailXsize = 0 # instantiate global thumbnailYsize; thumbnailYsize = 0 global colorspaces; colorspaces = ['HSL-', 'HSV-', 'CMYK'] global colorspaceStr; colorspaceStr = colorspaces [0] global tctrlVar1; tctrlVar1 = None # instantiate global tctrlVar2; tctrlVar2 = None global tctrlVar3; tctrlVar3 = None global tctrlVar4; tctrlVar4 = None # These default values cause no modifications to be made to the transformed image's vector space values. # Thus, when the inverse transform is applied, the resulting image will be identical # to the original image. global x1Var1; x1Var1 = 0.0 # initial Y=0.0 intercept (the X axis intercept) global x2Var1; x2Var1 = 1.0 # initial Y=1.0 intercept global x1Var2; x1Var2 = 0.0 global x2Var2; x2Var2 = 1.0 global x1Var3; x1Var3 = 0.0 global x2Var3; x2Var3 = 1.0 global x1Var4; x1Var4 = 0.0 global x2Var4; x2Var4 = 1.0 class AppFrame (wx.Frame): def __init__ (self, parent, id, title, position, size): global filepathname self.parentFrame = self self.mainframePsn = position self.mainframeSize = size wx.Frame.__init__ (self, parent, id, title, position, size) # Create the File menu self.CreateStatusBar() # A StatusBar in the bottom of the window # Setting up the menu. filemenu= wx.Menu() idOpen = wx.NewId() filemenu.Append (idOpen, "&Open"," Open a Text File") wx.EVT_MENU (self, idOpen, self.OnOpen) filemenu.AppendSeparator() idAbout = wx.NewId() filemenu.Append (idAbout, "&About"," Information about this program") wx.EVT_MENU (self, idAbout, self.OnAbout) filemenu.AppendSeparator() idExit = wx.NewId() filemenu.Append (idExit,"E&xit"," Terminate the program") wx.EVT_MENU (self, idExit, self.OnExit) # Creating the menubar. menuBar = wx.MenuBar() menuBar.Append (filemenu,"&File") # Adding the "filemenu" to the MenuBar self.SetMenuBar (menuBar) # Adding the MenuBar to the Frame content. #---------- AppPanel (self, -1, position, size) self.Show (True) # show self frame #end def __init__ def OnOpen (self, event): # Open a file global filepathname # 'wx.CHANGE_DIR' is necessary to return a full pathname in Win98 dlg = wx.FileDialog (self, "Choose a file", style=wx.OPEN|wx.FILE_MUST_EXIST|wx.CHANGE_DIR, wildcard='*.*') if dlg.ShowModal() == wx.ID_OK: filename = dlg.GetFilename() dirname = dlg.GetDirectory() filepathname = os.path.join (dirname, filename) #end if if (type (filepathname) == type ('abc')) or (type (filepathname) == type (u'abc')): try: self.referenceFrame.Destroy() except: pass #end if self.ReferenceFrame() #end if dlg.Destroy() #end def OnOpen def ReferenceFrame (self): global filepathname referenceframeXpsn = self.mainframePsn[0] + self.mainframeSize[0] referenceframepsn = (referenceframeXpsn, self.mainframePsn[1]) referenceframesize = (300, 300) # is also the transformed image frame's size self.referenceFrame = wx.Frame (self.parentFrame, -1, "Original Image ", referenceframepsn, referenceframesize) # Create the reference frame's panel referencePanel = wx.Panel (self.referenceFrame, -1) referencePanel.SetBackgroundColour ('#C9E3E5') # Create the reference bitmap staticBitmap = wx.StaticBitmap (referencePanel, -1, wx.EmptyBitmap(5, 5)) # Get and resize the original image to fit in the reference panel and store it to a bitmap bitmap = GetBitmapFromFile (filepathname, referenceframesize) staticBitmap.SetBitmap (bitmap) boxsizer = wx.BoxSizer (wx.VERTICAL) expand = False boxsizer.Add (staticBitmap, expand) referencePanel.SetAutoLayout (True) referencePanel.SetSizer (boxsizer) # Show the reference frame self.referenceFrame.Show (True) #end def ReferenceFrame def OnAbout (self, event): # Create a message dialog box dlg = wx.MessageDialog (self, 'A colorspace manipulation\nprogram in wxPython', ' About Colorspace Transform', wx.OK) dlg.ShowModal() # Shows it dlg.Destroy() # finally destroy it when finished. #end def def OnExit (self, event): self.Close (True) # Close the application. #end def #end class AppFrame class AppPanel (wx.Panel): def __init__ (self, parentframe, id, mainframePsn, mainframeSize): global colorspaces global colorspaceStr global filepathname global x1Var1, x2Var1 self.parentFrame = parentframe self.mainframePsn = mainframePsn self.mainframeSize = mainframeSize wx.Panel.__init__ (self, parentframe, id) self.SetBackgroundColour ('#C9E3E5') boxsizerV = wx.BoxSizer (wx.VERTICAL) # all panel widgets go in here expand = False hgt = 40 padding = 0 #-------------------- rbId = wx.NewId() numRbRows = 1 # Display the colorspace strings without any trailing dash characters; # Create a new string list for this purpose. modcolorspaces = [] for cspaceStr in colorspaces: if cspaceStr[-1] == '-': modcolorspaces.append (cspaceStr[:-1]) # up to the dash char else: modcolorspaces.append (cspaceStr[:]) # the wholeoriginal string #end if #end for radbox = wx.RadioBox (self, rbId, "Color Space", wx.DefaultPosition, wx.DefaultSize, modcolorspaces, numRbRows, wx.RA_SPECIFY_ROWS) radbox.SetBackgroundColour (self.GetBackgroundColour()) radbox.SetBackgroundColour (wx.WHITE) radbox.SetToolTip (wx.ToolTip ('Select a colorspace model:')) radbox.SetLabel ('Colorspace Model Selection') wx.EVT_RADIOBOX (self, rbId, self.EvtRadioBox) # Apparently the first radiobutton is always selected by default, # so, adjust the program's setting to reflect this. colorspaceStr = colorspaces [0] boxsizerX1X2var1 = self.VarControlsVar1 (self, colorspaceStr[0].upper()) boxsizerX1X2var2 = self.VarControlsVar2 (self, colorspaceStr[1].upper()) boxsizerX1X2var3 = self.VarControlsVar3 (self, colorspaceStr[2].upper()) boxsizerX1X2var4 = self.VarControlsVar4 (self, colorspaceStr[3].upper()) #-------------------- boxsizerV.Add (radbox, expand, wx.CENTER|wx.ALL, 10) bordersize = 0 boxsizerV.Add (boxsizerX1X2var1, expand, wx.CENTER|wx.ALL, bordersize) boxsizerV.Add (boxsizerX1X2var2, expand, wx.CENTER|wx.ALL, bordersize) boxsizerV.Add (boxsizerX1X2var3, expand, wx.CENTER|wx.ALL, bordersize) boxsizerV.Add (boxsizerX1X2var4, expand, wx.CENTER|wx.ALL, bordersize) xformbtn = wx.Button (self, -1, "Show Transformed Image") wx.EVT_BUTTON (self, xformbtn.GetId(), self.xformBtnHandler) boxsizerV.Add (xformbtn, expand, wx.CENTER|wx.ALL, 10) # a 10-pixel border all around self.SetAutoLayout (True) self.SetSizer (boxsizerV) self.Show (True) #end def __init__ def EvtRadioBox (self, event): global tctrlVar1 global tctrlVar2 global tctrlVar3 global tctrlVar4 colorspaceIndex = event.GetInt() colorspaceStr = colorspaces [colorspaceIndex] # Write the colorspace string chars into their text controls. tctrlVar1.Clear() tctrlVar1.SetInsertionPoint (0) tctrlVar1.AppendText (colorspaceStr[0].upper()) tctrlVar2.Clear() tctrlVar2.SetInsertionPoint (0) tctrlVar2.AppendText (colorspaceStr[1].upper()) tctrlVar3.Clear() tctrlVar3.SetInsertionPoint (0) tctrlVar3.AppendText (colorspaceStr[2].upper()) tctrlVar4.Clear() tctrlVar4.SetInsertionPoint (0) tctrlVar4.AppendText (colorspaceStr[3].upper()) #end def def VarControlsVar1 (self, parentPanel, varLabelChar): global tctrlVar1 def OnSpinX1 (event): global x1Var1 x1Var1 = (event.GetPosition() - 200) / 200.0 # raw spinbutton value self.textX1Var1.SetValue ('%1.3f' % (x1Var1)) #end def def OnSpinX2 (event): global x2Var1 x2Var1 = (event.GetPosition() - 200) / 200.0 # raw spinbutton value self.textX2Var1.SetValue ('%1.3f' % (x2Var1)) #end def def ResetX1BtnHandler (event): global x1Var1 self.spinX1.SetValue (200) # 0.000 x1Var1 = 0.00 self.textX1Var1.SetValue ('%1.3f' % (x1Var1)) #end def ResetX1BtnHandler def ResetX2BtnHandler (event): global x2Var1 self.spinX2.SetValue (400) # 0.000 x2Var1 = 1.00 self.textX2Var1.SetValue ('%1.3f' % (x2Var1)) #end def ResetX1BtnHandler #-------------------- expand = False hgt = 40 padding = 0 boxsizerX1X2 = wx.BoxSizer (wx.HORIZONTAL) boxsizerX1V = wx.BoxSizer (wx.VERTICAL) labelX1 = wx.StaticText (self, -1, "X1: Y=0.0 Intercept:", wx.DefaultPosition) boxsizerX1V.Add (labelX1, expand, wx.CENTER|wx.ALL, padding) boxsizerX1 = wx.BoxSizer (wx.HORIZONTAL) self.textX1Var1 = wx.TextCtrl (self, -1, "0.000", wx.DefaultPosition, wx.Size(60, -1), style=wx.TE_READONLY) boxsizerX1.Add (self.textX1Var1, expand, wx.CENTER|wx.ALL, padding) self.spinX1 = wx.SpinButton (self, 20, wx.Point(0, 0), wx.Size(hgt, hgt), wx.SP_HORIZONTAL) self.spinX1.SetRange (0, 600) # -1.000 .. 2.000 self.spinX1.SetValue (200) # x1 = 0.000 wx.EVT_SPIN (self.spinX1, 20, OnSpinX1) boxsizerX1.Add (self.spinX1, expand, 0, padding) boxsizerX1V.Add (boxsizerX1, expand, 0, padding) resetX1btn = wx.Button (self, -1, "Reset to 0.000") boxsizerX1V.Add (resetX1btn, expand, 0, padding) wx.EVT_BUTTON (self, resetX1btn.GetId(), ResetX1BtnHandler) boxsizerX2V = wx.BoxSizer (wx.VERTICAL) labelX2 = wx.StaticText (self, -1, "X2: Y=1.0 Intercept:", wx.DefaultPosition) boxsizerX2V.Add (labelX2, expand, wx.CENTER|wx.ALL, padding) boxsizerX2 = wx.BoxSizer (wx.HORIZONTAL) self.textX2Var1 = wx.TextCtrl (self, -1, "1.000", wx.DefaultPosition, wx.Size(60, -1), style=wx.TE_READONLY) boxsizerX2.Add (self.textX2Var1, expand, wx.CENTER|wx.ALL, padding) self.spinX2 = wx.SpinButton (self, 20, wx.DefaultPosition, wx.Size(hgt, hgt), wx.SP_HORIZONTAL) self.spinX2.SetRange (0, 600) # -1.000 .. 2.000 self.spinX2.SetValue (400) # x2 = 1.000 wx.EVT_SPIN (self.spinX2, 20, OnSpinX2) boxsizerX2.Add (self.spinX2, expand, wx.CENTER|wx.ALL, padding) boxsizerX2V.Add (boxsizerX2, expand, 0, padding) resetX2btn = wx.Button (self, -1, "Reset to 1.000") boxsizerX2V.Add (resetX2btn, expand, 0, padding) wx.EVT_BUTTON (self, resetX2btn.GetId(), ResetX2BtnHandler) tctrlVar1 = wx.TextCtrl (self, -1, varLabelChar.upper(), wx.DefaultPosition, wx.Size(20, -1), style=wx.TE_READONLY) boxsizerX1X2.Add (tctrlVar1, expand, wx.CENTER|wx.ALL, 10) boxsizerX1X2.Add (boxsizerX1V, expand, wx.CENTER|wx.ALL, 10) boxsizerX1X2.Add (boxsizerX2V, expand, wx.CENTER|wx.ALL, 10) return boxsizerX1X2 #end def VarControlsVar1 def VarControlsVar2 (self, parentPanel, varLabelChar): global tctrlVar2 def OnSpinX1 (event): global x1Var2 x1Var2 = (event.GetPosition() - 200) / 200.0 # raw spinbutton value self.textX1Var2.SetValue ('%1.3f' % (x1Var2)) #end def def OnSpinX2 (event): global x2Var2 x2Var2 = (event.GetPosition() - 200) / 200.0 # raw spinbutton value self.textX2Var2.SetValue ('%1.3f' % (x2Var2)) #end def def ResetX1BtnHandler (event): global x1Var2 self.spinX1.SetValue (200) # 0.000 x1Var2 = 0.00 self.textX1Var2.SetValue ('%1.3f' % (x1Var2)) #end def ResetX1BtnHandler def ResetX2BtnHandler (event): global x2Var2 self.spinX2.SetValue (400) # 0.000 x2Var2 = 1.00 self.textX2Var2.SetValue ('%1.3f' % (x2Var2)) #end def ResetX1BtnHandler #-------------------- expand = False hgt = 40 padding = 0 boxsizerX1X2 = wx.BoxSizer (wx.HORIZONTAL) boxsizerX1V = wx.BoxSizer (wx.VERTICAL) labelX1 = wx.StaticText (self, -1, "X1: Y=0.0 Intercept:", wx.DefaultPosition) boxsizerX1V.Add (labelX1, expand, wx.CENTER|wx.ALL, padding) boxsizerX1 = wx.BoxSizer (wx.HORIZONTAL) self.textX1Var2 = wx.TextCtrl (self, -1, "0.000", wx.DefaultPosition, wx.Size(60, -1), style=wx.TE_READONLY) boxsizerX1.Add (self.textX1Var2, expand, wx.CENTER|wx.ALL, padding) self.spinX1 = wx.SpinButton (self, 20, wx.DefaultPosition, wx.Size(hgt, hgt), wx.SP_HORIZONTAL) self.spinX1.SetRange (0, 600) # -1.000 .. 2.000 self.spinX1.SetValue (200) # x1 = 0.000 wx.EVT_SPIN (self.spinX1, 20, OnSpinX1) boxsizerX1.Add (self.spinX1, expand, 0, padding) boxsizerX1V.Add (boxsizerX1, expand, 0, padding) resetX1btn = wx.Button (self, -1, "Reset to 0.000") boxsizerX1V.Add (resetX1btn, expand, 0, padding) wx.EVT_BUTTON (self, resetX1btn.GetId(), ResetX1BtnHandler) boxsizerX2V = wx.BoxSizer (wx.VERTICAL) labelX2 = wx.StaticText (self, -1, "X2: Y=1.0 Intercept:", wx.DefaultPosition) boxsizerX2V.Add (labelX2, expand, wx.CENTER|wx.ALL, padding) boxsizerX2 = wx.BoxSizer (wx.HORIZONTAL) self.textX2Var2 = wx.TextCtrl (self, -1, "1.000", wx.DefaultPosition, wx.Size(60, -1), style=wx.TE_READONLY) boxsizerX2.Add (self.textX2Var2, expand, wx.CENTER|wx.ALL, padding) self.spinX2 = wx.SpinButton (self, 20, wx.DefaultPosition, wx.Size(hgt, hgt), wx.SP_HORIZONTAL) self.spinX2.SetRange (0, 600) # -1.000 .. 2.000 self.spinX2.SetValue (400) # x2 = 1.000 wx.EVT_SPIN (self.spinX2, 20, OnSpinX2) boxsizerX2.Add (self.spinX2, expand, wx.CENTER|wx.ALL, padding) boxsizerX2V.Add (boxsizerX2, expand, 0, padding) resetX2btn = wx.Button (self, -1, "Reset to 1.000") boxsizerX2V.Add (resetX2btn, expand, 0, padding) wx.EVT_BUTTON (self, resetX2btn.GetId(), ResetX2BtnHandler) tctrlVar2 = wx.TextCtrl (self, -1, varLabelChar.upper(), wx.DefaultPosition, wx.Size(20, -1), style=wx.TE_READONLY) boxsizerX1X2.Add (tctrlVar2, expand, wx.CENTER|wx.ALL, 10) # a 10-pixel border all around boxsizerX1X2.Add (boxsizerX1V, expand, wx.CENTER|wx.ALL, 10) # a 10-pixel border all around boxsizerX1X2.Add (boxsizerX2V, expand, wx.CENTER|wx.ALL, 10) # a 10-pixel border all around return boxsizerX1X2 #end def VarControlsVar2 def VarControlsVar3 (self, parentPanel, varLabelChar): global tctrlVar3 def OnSpinX1 (event): global x1Var3 x1Var3 = (event.GetPosition() - 200) / 200.0 # raw spinbutton value self.textX1Var3.SetValue ('%1.3f' % (x1Var3)) #end def def OnSpinX2 (event): global x2Var3 x2Var3 = (event.GetPosition() - 200) / 200.0 # raw spinbutton value self.textX2Var3.SetValue ('%1.3f' % (x2Var3)) #end def def ResetX1BtnHandler (event): global x1Var3 self.spinX1.SetValue (200) # 0.000 x1Var3 = 0.00 self.textX1Var3.SetValue ('%1.3f' % (x1Var3)) #end def ResetX1BtnHandler def ResetX2BtnHandler (event): global x2Var3 self.spinX2.SetValue (400) # 0.000 x2Var3 = 1.00 self.textX2Var3.SetValue ('%1.3f' % (x2Var3)) #end def ResetX1BtnHandler #-------------------- expand = False hgt = 40 padding = 0 boxsizerX1X2 = wx.BoxSizer (wx.HORIZONTAL) boxsizerX1V = wx.BoxSizer (wx.VERTICAL) labelX1 = wx.StaticText (self, -1, "X1: Y=0.0 Intercept:", wx.DefaultPosition) boxsizerX1V.Add (labelX1, expand, wx.CENTER|wx.ALL, padding) boxsizerX1 = wx.BoxSizer (wx.HORIZONTAL) self.textX1Var3 = wx.TextCtrl (self, -1, "0.000", wx.DefaultPosition, wx.Size(60, -1), style=wx.TE_READONLY) boxsizerX1.Add (self.textX1Var3, expand, wx.CENTER|wx.ALL, padding) self.spinX1 = wx.SpinButton (self, 20, wx.DefaultPosition, wx.Size(hgt, hgt), wx.SP_HORIZONTAL) self.spinX1.SetRange (0, 600) # -1.000 .. 2.000 self.spinX1.SetValue (200) # x1 = 0.000 wx.EVT_SPIN (self.spinX1, 20, OnSpinX1) boxsizerX1.Add (self.spinX1, expand, 0, padding) boxsizerX1V.Add (boxsizerX1, expand, 0, padding) resetX1btn = wx.Button (self, -1, "Reset to 0.000") boxsizerX1V.Add (resetX1btn, expand, 0, padding) wx.EVT_BUTTON (self, resetX1btn.GetId(), ResetX1BtnHandler) boxsizerX2V = wx.BoxSizer (wx.VERTICAL) labelX2 = wx.StaticText (self, -1, "X2: Y=1.0 Intercept:", wx.DefaultPosition) boxsizerX2V.Add (labelX2, expand, wx.CENTER|wx.ALL, padding) boxsizerX2 = wx.BoxSizer (wx.HORIZONTAL) self.textX2Var3 = wx.TextCtrl (self, -1, "1.000", wx.DefaultPosition, wx.Size(60, -1), style=wx.TE_READONLY) boxsizerX2.Add (self.textX2Var3, expand, wx.CENTER|wx.ALL, padding) self.spinX2 = wx.SpinButton (self, 20, wx.DefaultPosition, wx.Size(hgt, hgt), wx.SP_HORIZONTAL) self.spinX2.SetRange (0, 600) # -1.000 .. 2.000 self.spinX2.SetValue (400) # x2 = 1.000 wx.EVT_SPIN (self.spinX2, 20, OnSpinX2) boxsizerX2.Add (self.spinX2, expand, wx.CENTER|wx.ALL, padding) boxsizerX2V.Add (boxsizerX2, expand, 0, padding) resetX2btn = wx.Button (self, -1, "Reset to 1.000") boxsizerX2V.Add (resetX2btn, expand, 0, padding) wx.EVT_BUTTON (self, resetX2btn.GetId(), ResetX2BtnHandler) tctrlVar3 = wx.TextCtrl (self, -1, varLabelChar.upper(), wx.DefaultPosition, wx.Size(20, -1), style=wx.TE_READONLY) boxsizerX1X2.Add (tctrlVar3, expand, wx.CENTER|wx.ALL, 10) # a 10-pixel border all around boxsizerX1X2.Add (boxsizerX1V, expand, wx.CENTER|wx.ALL, 10) boxsizerX1X2.Add (boxsizerX2V, expand, wx.CENTER|wx.ALL, 10) return boxsizerX1X2 #end def VarControlsVar3 def VarControlsVar4 (self, parentPanel, varLabelChar): global tctrlVar4 def OnSpinX1 (event): global x1Var4 x1Var4 = (event.GetPosition() - 200) / 200.0 # raw spinbutton value self.textX1Var4.SetValue ('%1.3f' % (x1Var4)) #end def def OnSpinX2 (event): global x2Var4 x2Var4 = (event.GetPosition() - 200) / 200.0 # raw spinbutton value self.textX2Var4.SetValue ('%1.3f' % (x2Var4)) #end def def ResetX1BtnHandler (event): global x1Var4 self.spinX1.SetValue (200) # 0.000 x1Var4 = 0.00 self.textX1Var4.SetValue ('%1.3f' % (x1Var4)) #end def ResetX1BtnHandler def ResetX2BtnHandler (event): global x2Var4 self.spinX2.SetValue (400) # 0.000 x2Var4 = 1.00 self.textX2Var4.SetValue ('%1.3f' % (x2Var4)) #end def ResetX1BtnHandler #-------------------- expand = False hgt = 40 padding = 0 boxsizerX1X2 = wx.BoxSizer (wx.HORIZONTAL) boxsizerX1V = wx.BoxSizer (wx.VERTICAL) labelX1 = wx.StaticText (self, -1, "X1: Y=0.0 Intercept:", wx.DefaultPosition) boxsizerX1V.Add (labelX1, expand, wx.CENTER|wx.ALL, padding) boxsizerX1 = wx.BoxSizer (wx.HORIZONTAL) self.textX1Var4 = wx.TextCtrl (self, -1, "0.000", wx.DefaultPosition, wx.Size(60, -1), style=wx.TE_READONLY) boxsizerX1.Add (self.textX1Var4, expand, wx.CENTER|wx.ALL, padding) self.spinX1 = wx.SpinButton (self, 20, wx.DefaultPosition, wx.Size(hgt, hgt), wx.SP_HORIZONTAL) self.spinX1.SetRange (0, 600) # -1.000 .. 2.000 self.spinX1.SetValue (200) # x1 = 0.000 wx.EVT_SPIN (self.spinX1, 20, OnSpinX1) boxsizerX1.Add (self.spinX1, expand, 0, padding) boxsizerX1V.Add (boxsizerX1, expand, 0, padding) resetX1btn = wx.Button (self, -1, "Reset to 0.000") boxsizerX1V.Add (resetX1btn, expand, 0, padding) wx.EVT_BUTTON (self, resetX1btn.GetId(), ResetX1BtnHandler) boxsizerX2V = wx.BoxSizer (wx.VERTICAL) labelX2 = wx.StaticText (self, -1, "X2: Y=1.0 Intercept:", wx.DefaultPosition) boxsizerX2V.Add (labelX2, expand, wx.CENTER|wx.ALL, padding) boxsizerX2 = wx.BoxSizer (wx.HORIZONTAL) self.textX2Var4 = wx.TextCtrl (self, -1, "1.000", wx.DefaultPosition, wx.Size(60, -1), style=wx.TE_READONLY) boxsizerX2.Add (self.textX2Var4, expand, wx.CENTER|wx.ALL, padding) self.spinX2 = wx.SpinButton (self, 20, wx.DefaultPosition, wx.Size(hgt, hgt), wx.SP_HORIZONTAL) self.spinX2.SetRange (0, 600) # -1.000 .. 2.000 self.spinX2.SetValue (400) # x2 = 1.000 wx.EVT_SPIN (self.spinX2, 20, OnSpinX2) boxsizerX2.Add (self.spinX2, expand, wx.CENTER|wx.ALL, padding) boxsizerX2V.Add (boxsizerX2, expand, 0, padding) resetX2btn = wx.Button (self, -1, "Reset to 1.000") boxsizerX2V.Add (resetX2btn, expand, 0, padding) wx.EVT_BUTTON (self, resetX2btn.GetId(), ResetX2BtnHandler) tctrlVar4 = wx.TextCtrl (self, -1, varLabelChar.upper(), wx.Point(0, 0), wx.Size(20, -1), style=wx.TE_READONLY) boxsizerX1X2.Add (tctrlVar4, expand, wx.CENTER|wx.ALL, 10) # a 10-pixel border all around boxsizerX1X2.Add (boxsizerX1V, expand, wx.CENTER|wx.ALL, 10) # a 10-pixel border all around boxsizerX1X2.Add (boxsizerX2V, expand, wx.CENTER|wx.ALL, 10) # a 10-pixel border all around return boxsizerX1X2 #end def VarControlsVar4 def xformBtnHandler (self, event): global filepathname if (type (filepathname)==type('abc')) or (type(filepathname)==type(u'abc')): try: self.childFrame.Destroy() except: pass #end if # Transform the original image into a new one. self.ChildFrame() #end if #end def xformBtnHandler def ChildFrame (self): global filepathname global thumbnailXsize global thumbnailYsize global x1Var1 global x2Var1 childframeXpsn = self.mainframePsn[0] + 2*self.mainframeSize[0] childframepsn = (childframeXpsn, self.mainframePsn[1]) childframesize = (300, 300) childFrame = wx.Frame (self.parentFrame, -1, "Image Reverse-Transformed", childframepsn, childframesize) # Create the child panel self.childPanel = wx.Panel (childFrame, -1) self.childPanel.SetBackgroundColour ('#C9E3E5') # Create the child's bitmap staticBitmap = wx.StaticBitmap (self.childPanel, -1, wx.EmptyBitmap(5, 5)) # Get and resize the original image to fit in the child panel and store it to a bitmap imPil = Image.open (filepathname) imPil = imPil.resize ( (thumbnailXsize, thumbnailYsize) ) # Transform the thumbnail image. This is where all the hard stuff is performed. imRgbPrime = Brighten (imPil) # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! bitmap = Pil2Bitmap (imRgbPrime) staticBitmap.SetBitmap (bitmap) # Add the static bitmap to the panel. boxsizer = wx.BoxSizer (wx.VERTICAL) expand = False boxsizer.Add (staticBitmap, expand) self.childPanel.SetAutoLayout (True) self.childPanel.SetSizer (boxsizer) # Show the child frame childFrame.Show (True) self.childFrame = childFrame #end def ChildFrame #end class AppPanel def GetBitmapFromFile (filepathname, framesize): global thumbnailXsize global thumbnailYsize # If too large, resize the image to fit in the panel space. imPil = Image.open (filepathname) imXsize, imYsize = imPil.size panelXextent = framesize[0] - 10 # border size estimations for MS Windows panelYextent = framesize[1] - 24 if (imXsize > panelXextent) or (imYsize > panelYextent): # The "primary" axis is the one that must be scaled down to fit its extent. # The "secondary" axis will automatically scale to fit within its extent. # Find which axis is the primary. x2yExtentRatio = 1.0 * panelXextent / panelYextent imageXYratio = 1.0 * imXsize / imYsize if imageXYratio > x2yExtentRatio: # The X axis is the primary axis # Find the image scale factor using the X axis. scalefactor = (1.0 * panelXextent) / imXsize else: scalefactor = (1.0 * panelYextent) / imYsize #end if # Resize the original image newXsize = int (scalefactor * imXsize) newYsize = int (scalefactor * imYsize) imPil = imPil.resize ( (newXsize, newYsize) ) #end if # Convert the Pil image to a bitmap and install it into the displayed static bitmap bitmap = Pil2Bitmap (imPil) thumbnailXsize = newXsize # save globally; child frame will use these thumbnailYsize = newYsize return bitmap #end def GetBitmapFromFile def Brighten (imRgb): global colorspaceStr global x1Var1, x2Var1 global x1Var2, x2Var2 global x1Var3, x2Var3 global x1Var4, x2Var4 # Extract the data from the input image and convert it to the particular colorspace data. rgbData = list (imRgb.getdata()) # must make a list of tuples out of the special sequence #print 'Transforming RGB data to a new colorspace ...', spaceData = [] for rgbtuple in rgbData: if colorspaceStr.lower() == 'hsl-': spaceData.append (Rgb2Hsl (rgbtuple)) elif colorspaceStr.lower() == 'hsv-': spaceData.append (Rgb2Hsv (rgbtuple)) elif colorspaceStr.lower() == 'cmyk': spaceData.append (Rgb2Cmyk (rgbtuple)) else: print print 'Brighten(1): Colorspace string [%s] not known.' % (colorspaceStr.upper()) print os._exit (1) #end if #end for #print 'Finished' # Calculate the slope and offset (derived from y = mx + b). slopeVar1 = 1.0e6 # arbitrary maximum value of slope: avoid division-by-zero if x1Var1 != x2Var1: slopeVar1 = 1.0/(x2Var1 - x1Var1) offsetVar1 = -1.0 * slopeVar1 * x1Var1 slopeVar2 = 1.0e6 # arbitrary maximum if x1Var2 != x2Var2: slopeVar2 = 1.0/(x2Var2 - x1Var2) offsetVar2 = -1.0 * slopeVar2 * x1Var2 slopeVar3 = 1.0e6 # arbitrary maximum if x1Var3 != x2Var3: slopeVar3 = 1.0/(x2Var3 - x1Var3) offsetVar3 = -1.0 * slopeVar3 * x1Var3 slopeVar4 = 1.0e6 # arbitrary maximum if x1Var4 != x2Var4: slopeVar4 = 1.0/(x2Var4 - x1Var4) offsetVar4 = -1.0 * slopeVar4 * x1Var4 # Modify the particular colorspace values if colorspaceStr.lower() == 'hsl-': for index in xrange (len(spaceData)): h, s, l = spaceData [index] # Apply an arbitrary algorithm to modify the colorspace vectors. h = (h * slopeVar1) + offsetVar1 s = (s * slopeVar2) + offsetVar2 l = (l * slopeVar3) + offsetVar3 spaceData [index] = (h, s, l) #end for elif colorspaceStr.lower() == 'hsv-': for index in xrange (len(spaceData)): h, s, v = spaceData [index] # Apply an arbitrary algorithm to modify the colorspace vectors. h = (h * slopeVar1) + offsetVar1 s = (s * slopeVar2) + offsetVar2 v = (v * slopeVar3) + offsetVar3 spaceData [index] = (h, s, v) #end for elif colorspaceStr.lower() == 'cmyk': for index in xrange (len(spaceData)): c, m, y, k = spaceData [index] # Apply an arbitrary algorithm to modify the colorspace vectors. c = (c * slopeVar1) + offsetVar1 m = (m * slopeVar2) + offsetVar2 y = (y * slopeVar3) + offsetVar3 k = (k * slopeVar4) + offsetVar4 spaceData [index] = (c, m, y, k) # replace old values with new in-place #end for else: print print 'Brighten(2): Colorspace string [%s] not known.' % (colorspaceStr.upper()) print os._exit (1) #end if # Convert the modified colorspace data back into RGB data #print 'Returning modified colorspace data to RGB ...', rgbPrimedata = [] for spacetuple in spaceData: if colorspaceStr.lower() == 'cmyk': rgbPrimetuple = Cmyk2Rgb (spacetuple) elif colorspaceStr.lower() == 'hsl-': rgbPrimetuple = Hsl2Rgb (spacetuple) elif colorspaceStr.lower() == 'hsv-': rgbPrimetuple = Hsv2Rgb (spacetuple) else: print print 'Brighten(3): Colorspace string not recognized = [%s]' % (colorspaceStr.upper()) print os._exit (1) #end if rgbPrimedata.append (rgbPrimetuple) #end for #print 'Finished' # Create a new image from the new RGB data imRgbPrime = Image.new ('RGB', imRgb.size) imRgbPrime.putdata (rgbPrimedata) return imRgbPrime #end def Brighten #------------------ if __name__ == "__main__": app = wx.PySimpleApp() wx.InitAllImageHandlers() framepsn = (100, 100) framesize = (300, 575) # master frame size AppFrame (None, -1, "Colorspace Transformer", framepsn, framesize) app.MainLoop() #end if From bob at redivi.com Sat Apr 9 11:03:30 2005 From: bob at redivi.com (Bob Ippolito) Date: Sat Apr 9 11:03:33 2005 Subject: [Image-SIG] Python 2.4? In-Reply-To: <3C80DCC2E816D94EA3D5DFA9D3B798D80512CC@OslHkBl0818.ls.no> References: <3C80DCC2E816D94EA3D5DFA9D3B798D80512CC@OslHkBl0818.ls.no> Message-ID: On Mar 21, 2005, at 3:49 AM, Sigmund Lahn wrote: > The installer complains thet I do not have python 2.3 installed. Does > this mean python 2.4 is not supported, or is the installer just > outdated? > > Ie, should I tweak my register so that python 2.4 is also registered > as 2.3? Extensions built for one minor Python revision are not compatible with another. If you want to use PIL with Python 2.4, you must download an installer that is for Python 2.4. Tweaking your registry is a recipe for disaster. -bob From steve at holdenweb.com Sat Apr 9 16:19:52 2005 From: steve at holdenweb.com (Steve Holden) Date: Sat Apr 9 16:19:40 2005 Subject: [Image-SIG] Installation Guide In-Reply-To: <20050312195315.45930.qmail@web20922.mail.yahoo.com> References: <20050312195315.45930.qmail@web20922.mail.yahoo.com> Message-ID: <4257E488.6080902@holdenweb.com> Online Support wrote: > Hello, > > I'm in critical need to install Python Imaging Library on my > linux/cpanel server. I'm not very experienced and I almost always have > to use instalation guides. I have downloaded the software, unzipped it, > and now I think I just need to install it somehow. Are there files that > need to be modified first? I think there is a file called setup.py but > I'm not sure how I can run that file. > > I would really appreciate your reply, or if you could point me to an > installation giude online for PIL > > Best Regards, > - Kevin > By "unzipped" I presume you mean "untarred the .tgz file"? Just make sure your text files will have Linux line endings not windows (just in case: sorry of this seems obvious). There should be a README file int eh top-level directory. Look for the section that starts -------------------------------------------------------------------- Build instructions (all platforms) -------------------------------------------------------------------- Or have you seen this and need more? regards Steve -- Steve Holden +1 703 861 4237 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ Python Web Programming http://pydish.holdenweb.com/ From jwt at onjapan.net Mon Apr 11 10:07:06 2005 From: jwt at onjapan.net (Jim Tittsler) Date: Mon Apr 11 10:06:45 2005 Subject: [Image-SIG] c code to python using gd In-Reply-To: <423A3DB0.9080706@demir.web.tr> References: <423A3DB0.9080706@demir.web.tr> Message-ID: <6376fbbd5a9c289a3e6b6a347737a49a@onjapan.net> On Mar 18, 2005, at 11:32, Necati DEMiR wrote: [Your message seems to have gotten stuck in the python.org mailing lists for rather a long time... probably because the attachments made the message so huge. You would have been better served by putting the images on the web somewhere and given URLs to them.] > i converted a c code to python. two of them uses gd, but they dont have > the sama output :( But they aren't the same code. Your values of p1 and p2 are quite different. > int p1 = (255/3); > int p2 = 2 * (255/3); [...] > p1 = 255+1 / 3 > p2 = 2 * (255+1 / 3) If you use the same values for p1 and p2 in both C and Python, the images will be the same. -- Jim Tittsler, Mitaka, Tokyo, JAPAN http://www.OnJapan.net/ Python Starship http://Starship.Python.net/ Ringo MUG Tokyo http://www.ringo.net/rss.html -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 2091 bytes Desc: not available Url : http://mail.python.org/pipermail/image-sig/attachments/20050411/4d94dbce/smime.bin From M.Singh at exeter.ac.uk Mon Apr 11 17:39:52 2005 From: M.Singh at exeter.ac.uk (Maneesha) Date: Mon Apr 11 17:38:56 2005 Subject: [Image-SIG] ICAPR2005 - Deadline 20th April,2005 Message-ID: <425B0101@minerva2.ex.ac.uk> Dear Colleagues, We would like to circulate the Call for Participation of ICAPR'05 and its related workshops to your mailing list. Please circulate it (if appropriate) to the members of your group. Many thanks, Maneesha Singh Organising Chair (ICAPR'05) ---------------------------------------------------------------------------- 3rd International Conference on Advances in Pattern Recognition (ICAPR 2005), BATH, UK published by Springer-Verlag 22-25 August, 2005 NEW PAPER SUBMISSION DEADLINE: 20 April, 2005 CONFERENCE WEBSITE: http://www.icapr2005.org.uk PAPER SUBMISSION WEBSITE: http://www.paaonline.net/cps Research Topics and Tracks Track 1: Pattern Recognition Methods Theoretical developments in machine learning and pattern recognition tools and techniques; Statistical pattern recognition; Data Mining; Artificial neural networks; Bayesian networks; Case-based reasoning; Classifier combination; Computational models of human learning; Computational learning theory; Cooperative learning; Decision trees; Evolutionary computation; Feature selection; Statistical relational learning; Grammatical inference; Incremental induction and on-line learning; Inductive logic programming; Information retrieval and learning; Instance based learning; Kernel methods; Level sets Track 2: Knowledge and Learning Knowledge acquisition and learning; Knowledge base refinement; Knowledge intensive learning; Learning from text and web; Evaluation metrics and methodologies; Machine learning of natural language; Meta learning; Multi-agent learning; Multi-strategy learning; Planning and learning; Reinforcement learning; Revision and restructuring; Statistical approaches; Unsupervised learning; Vision and learning; Visualisation techniques; Algorithms and techniques; Classification; Clustering; Frequent patterns; Rule discovery; Statistical techniques and mixture models; Constraint-based mining; incremental algorithms; Scalable algorithms; Distributed and parallel algorithms; Privacy preserving data mining; Multi-relational data mining; Innovative applications; Mining bio-medical data; Web content, structure and usage mining; Semantic web mining; Mining governmental data, mining for the public administration; Personalization; Adaptive data mining architectures Track 3: Data Mining Database integration; Inductive databases; Data mining query languages; Data mining query optimisation; Dimensionality reduction; Data reduction; Discretization; Uncertain and missing information; Complexity issues; knowledge (pattern) representation; Global vs. local patterns; Logic for data mining; Statistical inference/ probabilistic modelling; Collaborative data mining; Vertical data mining environments; Mining different forms of data; Graph, tree, sequence mining; Semi-structured and XML data mining; Text mining; Temporal, spatial, and spatio-temporal data mining; Data stream mining; Multimedia mining; Pattern post-processing; Quality assessment; Visualization; knowledge interpretation and use Track 4: Applications Image analysis; Video analysis; Speech recognition and classification; Text analysis; Medical imaging; Robotics and Autonomous Systems; Multimedia; Information fusion; Computational signal processing; Geotechnical applications; Astronomy applications; Remote Sensing; Biomedical applications; Environmental sciences; Inspection technologies; Manufacturing applications; Computational Biology; Bioinformatics; Health sciences Papers should be submitted through http://www.paaonline.net/cps ----------------------------------------------------------------------------- International Workshop on Document Image Analysis and Recognition (Chair: Prof. Adnan Amin, University of New South Wales, Australia) Extended Paper submission deadline: 20 April, 2005 CONFERENCE WEBSITE: http://www.icapr2005.org.uk Papers should be submitted through http://www.paaonline.net/cps ----------------------------------------------------------------------------- International Workshop on Information Fusion for Biometric Processing (Chair: Prof. Mike Fairhurst, University of Kent, UK) Extended Paper submission deadline: 20 April, 2005 CONFERENCE WEBSITE: http://www.icapr2005.org.uk Papers should be submitted through http://www.paaonline.net/cps ----------------------------------------------------------------------------- International Workshop on Pattern Recognition for Crime Prevention, Security and Surveillance (Chair: Prof. Sameer Singh, Loughborough University, UK) Extended Paper submission deadline: 20 April, 2005 CONFERENCE WEBSITE: http://www.icapr2005.org.uk Papers should be submitted through http://www.paaonline.net/cps ----------------------------------------------------------------------------- From klimek at grc.nasa.gov Mon Apr 11 21:27:52 2005 From: klimek at grc.nasa.gov (Bob Klimek) Date: Mon Apr 11 21:27:25 2005 Subject: [Image-SIG] HSL adjustment, and others In-Reply-To: <4255445E.1010707@hotpop.com> References: <4255445E.1010707@hotpop.com> Message-ID: <425ACFB8.6080703@grc.nasa.gov> Ray Pasco wrote: > I've been playing around with just this. This program converts to/from > several different colorspaces and changes the alternate colorspace's > "ramp" slope and offset. The program only does linear adjustments. > > I'd appreciate any comments/suggestions you may have. Hi Ray, I've taken a quick look at your rgb-hsl (and hsl-rgb) and rgb-hsv (and hsv-rgb) transformations and from the few tests I've run, both algorithms seem to be working quite well. And both successfully convert to and from. I don't see any difference really, although I don't have the time to do a thorough comparison. My interest is only in hue so I've looked at that component only. I have a test image of a type of "rainbow" in which the hue changes from 1.0 down to 0.0 in a linear fashion as the image is scanned from left to right. I use an old algorithm which produces a linear relationship between hue and posistion in this image. To my surprise both of these algorithms also produce a linear relationship. BTW, the algorithm that I use (see below) come from Computer Graphics Quarterly Report SIGGRAPH-ACM, vol 13, Number 3, Aug. 1979. The hue range is from 0 to 2pi. One interesting thing we've noticed is that some hue values repeat them selves. That is an 8-bit deep RGB image has 16 million rgb combinations but our hue algorithm produces only a few thousand unique values, not 16 million. All others are repeated hue values. Anyway, it would be very nice to have a fast image-wide HSI transformation done in C with the output as a float array. Maybe some day... def calcHue(self, r, g, b): rf = float(r) gf = float(g) bf = float(b) rf = rf/255.0 gf = gf/255.0 bf = bf/255.0 inten = (rf+gf+bf)/3.0 if(not((r==b) and (r==g))): min = rf if(min>gf): min = gf if(min>bf): min = bf sat=1.0-(min/inten) t1 = rf-gf t2 = rf-bf t3 = gf-bf t4 = math.sqrt((t1*t1)+(t2*t3)) t5 = (t1+t2)/2.0 t5 = t5/t4 hue = math.acos(t5) if(gf I have finally tracked down the cause of images sometimes not showing up when using PSDraw's im.image() method. The problem is the following lines, 101 and 102 in PSDraw.ph: sx = x / im.size[0] sy = y / im.size[1] These lines can occasionally perform integer division rather than floating point division. This is partially prevented by the use of float() on lines 87-88, but then lines 90-95 cause problems again: xmax = box[2] - box[0] ymax = box[3] - box[1] if x > xmax: y = y * xmax / x; x = xmax if y > ymax: x = x * ymax / y; y = ymax x or y may hold an integer value after these lines, depending on the size and shape of the box versus the image. The fix is to add a pair of float() in one of three places, either around xmax and ymax's creation, their assignment to x and y, or in lines 101-102: xmax = float(box[2] - box[0]) ymax = float(box[3] - box[1]) or if x > xmax: y = y * xmax / x; x = float(xmax) if y > ymax: x = x * ymax / y; y = float(ymax) or sx = float(x) / im.size[0] sy = float(y) / im.size[1] Any of those ways works. This is an extremely frustrating bug and its existance can render the PSDraw module relatively useless, so please include the fix in the distribution as soon as possible. I think it has been in existance for several years. - Eric Etheridge __________________________________ Do you Yahoo!? Yahoo! Small Business - Try our new resources site! http://smallbusiness.yahoo.com/resources/ From klimek at grc.nasa.gov Tue Apr 12 16:18:45 2005 From: klimek at grc.nasa.gov (Bob Klimek) Date: Tue Apr 12 16:18:14 2005 Subject: [Image-SIG] HSL adjustment, and others In-Reply-To: <425AE4F4.9020802@hotpop.com> References: <4255445E.1010707@hotpop.com> <425ACFB8.6080703@grc.nasa.gov> <4 25AE4F4.9020802@hotpop.com> Message-ID: <425BD8C5.4000708@grc.nasa.gov> No. The paper mentioned below has the pseudocode but I've never implemented it. Bob Ray Pasco wrote: > Bob, > > So, that's HSI ? OK, but it seems rather bizarre. Anyhow, do you > have the inverse transform ? > > Ray > > > Bob Klimek wrote: > >> Ray Pasco wrote: >> >>> I've been playing around with just this. This program converts >>> to/from several different colorspaces and changes the alternate >>> colorspace's "ramp" slope and offset. The program only does linear >>> adjustments. >>> >>> I'd appreciate any comments/suggestions you may have. >> >> >> >> Hi Ray, >> >> I've taken a quick look at your rgb-hsl (and hsl-rgb) and rgb-hsv >> (and hsv-rgb) transformations and from the few tests I've run, both >> algorithms seem to be working quite well. And both successfully >> convert to and from. I don't see any difference really, although I >> don't have the time to do a thorough comparison. >> >> My interest is only in hue so I've looked at that component only. I >> have a test image of a type of "rainbow" in which the hue changes >> from 1.0 down to 0.0 in a linear fashion as the image is scanned from >> left to right. I use an old algorithm which produces a linear >> relationship between hue and posistion in this image. To my surprise >> both of these algorithms also produce a linear relationship. >> >> BTW, the algorithm that I use (see below) come from Computer Graphics >> Quarterly Report SIGGRAPH-ACM, vol 13, Number 3, Aug. 1979. The hue >> range is from 0 to 2pi. One interesting thing we've noticed is that >> some hue values repeat them selves. That is an 8-bit deep RGB image >> has 16 million rgb combinations but our hue algorithm produces only a >> few thousand unique values, not 16 million. All others are repeated >> hue values. >> >> Anyway, it would be very nice to have a fast image-wide HSI >> transformation done in C with the output as a float array. Maybe some >> day... >> >> def calcHue(self, r, g, b): >> rf = float(r) >> gf = float(g) >> bf = float(b) >> rf = rf/255.0 >> gf = gf/255.0 >> bf = bf/255.0 >> inten = (rf+gf+bf)/3.0 >> if(not((r==b) and (r==g))): >> min = rf >> if(min>gf): min = gf >> if(min>bf): min = bf >> sat=1.0-(min/inten) >> t1 = rf-gf >> t2 = rf-bf >> t3 = gf-bf >> t4 = math.sqrt((t1*t1)+(t2*t3)) >> t5 = (t1+t2)/2.0 >> t5 = t5/t4 >> hue = math.acos(t5) >> if(gf> else: >> hue=-1000.0 >> sat=-1.0 >> return (hue, sat) >> >> Bob >> >> >> > > > From aconrad.tlv at magic.fr Tue Apr 12 16:27:54 2005 From: aconrad.tlv at magic.fr (Alexandre CONRAD) Date: Tue Apr 12 16:27:55 2005 Subject: [Image-SIG] image 2 MPEG Message-ID: <425BDAEA.2000408@magic.fr> Hello, I'm new to this list. I've been using the python PIL a little bit, and I pretty much like it. This might be a little off-topic: I'm looking for a way to be able to convert an image (jpg, gif, any kind that PIL can read) to a MPEG I-Frame. I know PIL doesn't support MPEG encoding. But I've seen some tools around, like "mpeg2enc" that can encode an image (PPM) to an MPEG file. Has anyone tested this ? Regards, -- Alexandre CONRAD - TLV Research & Development tel : +33 1 30 80 55 05 fax : +33 1 30 80 55 06 6, rue de la plaine 78860 - SAINT NOM LA BRETECHE FRANCE From magoldfish at gmail.com Tue Apr 12 21:41:07 2005 From: magoldfish at gmail.com (Marcus Goldfish) Date: Tue Apr 12 21:41:13 2005 Subject: [Image-SIG] Loading a DDB into PIL Image Message-ID: <5e183f3d050412124122d50608@mail.gmail.com> Hi, I use ctypes to capture a device-dependent bitmap in Win32 (~600x400, 32bpp), and I would like to process it using PIL. I need a fast way to convert the DDB to a PIL Image-- any solutions or suggestions (ctypes, win32 solutions acceptable])? "Fast" means that I need to be able to convert the image in << 1 second. Thanks! Marcus From fredrik at pythonware.com Thu Apr 14 09:56:53 2005 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu Apr 14 09:58:16 2005 Subject: [Image-SIG] Re: Loading a DDB into PIL Image References: <5e183f3d050412124122d50608@mail.gmail.com> Message-ID: Marcus Goldfish wrote: > I use ctypes to capture a device-dependent bitmap in Win32 (~600x400, > 32bpp), and I would like to process it using PIL. I need a fast way > to convert the DDB to a PIL Image-- any solutions or suggestions > (ctypes, win32 solutions acceptable])? > > "Fast" means that I need to be able to convert the image in << 1 second. if you can convert it to a DIB, you can use the BmpImageFile.DibImageFile constructor. see the ImageGrab module for sample code. From magoldfish at gmail.com Thu Apr 14 13:38:55 2005 From: magoldfish at gmail.com (Marcus Goldfish) Date: Thu Apr 14 13:39:11 2005 Subject: [Image-SIG] Re: Loading a DDB into PIL Image In-Reply-To: References: <5e183f3d050412124122d50608@mail.gmail.com> Message-ID: <5e183f3d05041404385add0fa6@mail.gmail.com> > > I use ctypes to capture a device-dependent bitmap in Win32 (~600x400, > > 32bpp), and I would like to process it using PIL. I need a fast way > > to convert the DDB to a PIL Image-- any solutions or suggestions > > (ctypes, win32 solutions acceptable])? > > "Fast" means that I need to be able to convert the image in << 1 second. > > if you can convert it to a DIB, you can use the BmpImageFile.DibImageFile > constructor. see the ImageGrab module for sample code. Thanks Fredrik, but I'm not sure how to convert it to DIB. It seems like the ImageWin module is what I want to use, but it is missing a constructor which takes a DDB bitmap and produces a DIB or Image. Right now, the two best solutions I can see are: (1) trying to convert to DIB, but I'm not sure how to do this, and (2) pasting my DDB to the clipboard then using PIL to grab it. Any ideas on the relative speeds of the two approaches? Marcus From areopagus125 at yahoo.com Fri Apr 15 00:43:13 2005 From: areopagus125 at yahoo.com (David Smith) Date: Fri Apr 15 00:43:16 2005 Subject: [Image-SIG] problem with gifmaker.py Message-ID: <20050414224313.11689.qmail@web31709.mail.mud.yahoo.com> I downloaded gifmaker.py from http://olympus.het.brown.edu/doc/python-imaging/examples/gifmaker.py and tried it out. It writes a file all right, but when I try to view it with the Windows XP Picture and Fax viewer, it tells me, "Drawing failed." I created a PowerPoint slide and clicked Insert|Picture|FromFile, and it shows the first frame. But it won't cycle through the frames when I put it into slideshow mode. What's missing? Oh, and I would like to be able to set the frame rate, as well. -- David Smith __________________________________ Do you Yahoo!? Yahoo! Small Business - Try our new resources site! http://smallbusiness.yahoo.com/resources/ From jdunck at gmail.com Sun Apr 17 02:58:59 2005 From: jdunck at gmail.com (Jeremy Dunck) Date: Sun Apr 17 02:59:02 2005 Subject: [Image-SIG] The mysterious PIL Plus Message-ID: <2545a92c0504161758143f2174@mail.gmail.com> I've just recently started using PIL, and just banged my head on the fact that _imageft is not included in the free PIL. From jdunck at gmail.com Sun Apr 17 03:04:06 2005 From: jdunck at gmail.com (Jeremy Dunck) Date: Sun Apr 17 03:04:09 2005 Subject: [Image-SIG] Re: The mysterious PIL Plus In-Reply-To: <2545a92c0504161758143f2174@mail.gmail.com> References: <2545a92c0504161758143f2174@mail.gmail.com> Message-ID: <2545a92c05041618046bf767b5@mail.gmail.com> On 4/16/05, Jeremy Dunck wrote: > I've just recently started using PIL, and just banged my head on the > fact that _imageft is not included in the free PIL. > Very sorry about that. Sent accidentally. To continue: I have googled around for info on PIL Plus (what's it cost, where can I get it, what license is it under, etc.), and have come up empty. Does it exist? :) From postmaster at quost.com Mon Apr 18 14:34:08 2005 From: postmaster at quost.com (dnsrequest.com PostMaster) Date: Mon Apr 18 14:34:19 2005 Subject: [Image-SIG] Error sending message [1113827660403.3228.pegasus] from [dnsrequest.com] Message-ID: <20050418123417.1FD3D1E4005@bag.python.org> [<00>] XMail bounce: Rcpt=[claudia@steelkey.com.au];Error=[550 Mailbox unavailable ] [<01>] Error sending message [1113827660403.3228.pegasus] from [dnsrequest.com]. ID: Mail From: Rcpt To: Server: [12.96.165.198] [<02>] The reason of the delivery failure was: 550 Mailbox unavailable [<05>] Here is listed the initial part of the message: Received: from python.org (84.204.14.21:3177) by mail2.dnsrequest.com with [XMail 1.17 (Win32/Ix86) ESMTP Server] id for from ; Mon, 18 Apr 2005 12:33:54 -0000 From: image-sig@python.org To: claudia@steelkey.com.au Subject: HELLO Date: Mon, 18 Apr 2005 16:33:45 +0400 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_0002_EB09F4CD.666EB70D" X-Priority: 3 X-MSMail-Priority: Normal From fredrik at pythonware.com Mon Apr 18 18:06:59 2005 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon Apr 18 18:10:22 2005 Subject: [Image-SIG] Re: The mysterious PIL Plus References: <2545a92c0504161758143f2174@mail.gmail.com> Message-ID: Jeremy Dunck wrote: > I've just recently started using PIL, and just banged my head on the > fact that _imageft is not included in the free PIL. if you mean _imagingft, it's been included in PIL since early 2003. if you're building PIL yourself, you need FreeType. if you're using a prebuilt version, most 1.1.4 and 1.1.5 builds should come with a working _imagingft module. From bbaxter at wadsworth.org Mon Apr 18 19:35:43 2005 From: bbaxter at wadsworth.org (William Baxter) Date: Mon Apr 18 19:35:55 2005 Subject: [Image-SIG] busy cursor stores up events Message-ID: <4263EFEF.E09E8C56@wadsworth.org> Is there a way to get the BusyManager to prevent the widgets from servicing events accumulated during the busy period? I've been looking at the 2nd example at http://effbot.org/zone/tkinter-busy.htm Although the widgets do not respond to user events while the system is 'busy', they seem to register user events. When the system returns to the 'not busy' state, all the events are then processed. For instance, if I try to click the button repeatedly while 'busy', the gui doesn't respond (that's good). But when it's no longer busy, the button command prints out a whole column of hello's from the stored up events. Thanks, Bill Baxter From cohen at slac.stanford.edu Mon Apr 18 20:30:01 2005 From: cohen at slac.stanford.edu (Johann Cohen Tanugi) Date: Mon Apr 18 20:30:11 2005 Subject: [Image-SIG] fits format in PIL Message-ID: <4263FCA9.2060108@slac.stanford.edu> I googled a bit without much luck so I figured I would post the question directly here : does PIL support FITS image? If not yet, is there a team working on it? thanks in advance, Johann From rowen at cesmail.net Mon Apr 18 21:11:37 2005 From: rowen at cesmail.net (Russell E. Owen) Date: Mon Apr 18 21:13:16 2005 Subject: [Image-SIG] Re: fits format in PIL References: <4263FCA9.2060108@slac.stanford.edu> Message-ID: In article <4263FCA9.2060108@slac.stanford.edu>, Johann Cohen Tanugi wrote: > I googled a bit without much luck so I figured I would post the question > directly here : does PIL support FITS image? If not yet, is there a team > working on it? It does not directly support FITS. One simple technique is to use pyfits to read in the data, then display it using PIL. At least it's simple in regards parsing the FITS data; if you a have high dynamic range image, as is typical for FITS data, then scaling the data to display anything meaningful to the user is another story. Some resources: - Astronomical Python (link to pyfits and other utilties): http://www.astro.washington.edu/rowen/AstroPy.html> - Sample grayscale image viewer (still being worked on but quite functional) RO.Wdg.GrayImageDispWdg in RO package: - matplotlib includes an image viewer. It is rather slow but might prove useful. -- Russell From cohen at slac.stanford.edu Mon Apr 18 21:24:22 2005 From: cohen at slac.stanford.edu (Johann Cohen Tanugi) Date: Mon Apr 18 21:24:30 2005 Subject: [Image-SIG] Re: fits format in PIL In-Reply-To: References: <4263FCA9.2060108@slac.stanford.edu> Message-ID: <42640966.4010305@slac.stanford.edu> thanks for your answer. From your email I infer that PIL displays numarray objects, because this is the output format of a pyfits IO call on a fits file. Is there any thought about creating a plugin in PIL for FITS access? cheers, Johann Russell E. Owen wrote: >In article <4263FCA9.2060108@slac.stanford.edu>, > Johann Cohen Tanugi wrote: > > > >>I googled a bit without much luck so I figured I would post the question >>directly here : does PIL support FITS image? If not yet, is there a team >>working on it? >> >> > >It does not directly support FITS. One simple technique is to use pyfits >to read in the data, then display it using PIL. At least it's simple in >regards parsing the FITS data; if you a have high dynamic range image, >as is typical for FITS data, then scaling the data to display anything >meaningful to the user is another story. > >Some resources: >- Astronomical Python (link to pyfits and other utilties): >http://www.astro.washington.edu/rowen/AstroPy.html> >- Sample grayscale image viewer (still being worked on but quite >functional) RO.Wdg.GrayImageDispWdg in RO package: > >- matplotlib includes an image viewer. It is rather slow but might prove >useful. > >-- Russell > >_______________________________________________ >Image-SIG maillist - Image-SIG@python.org >http://mail.python.org/mailman/listinfo/image-sig > > From jdunck at gmail.com Tue Apr 19 06:00:30 2005 From: jdunck at gmail.com (Jeremy Dunck) Date: Tue Apr 19 06:00:33 2005 Subject: [Image-SIG] PIL Plus? Message-ID: <2545a92c050418210073a53848@mail.gmail.com> I've seen some references to PIL Plus both on this list and Pythonware's PIL documents. However, I've been unable to find a place to buy or download this software. Can someone give me a pointer? Why so secretive? From NadavH at VisionSense.com Tue Apr 19 08:08:21 2005 From: NadavH at VisionSense.com (Nadav Horesh) Date: Tue Apr 19 08:00:52 2005 Subject: [Image-SIG] PIL Plus? In-Reply-To: <2545a92c050418210073a53848@mail.gmail.com> References: <2545a92c050418210073a53848@mail.gmail.com> Message-ID: <4264A055.5030106@VisionSense.com> It is a commercial package (www.pythonware.com) Nadav Jeremy Dunck wrote: >I've seen some references to PIL Plus both on this list and >Pythonware's PIL documents. > >However, I've been unable to find a place to buy or download this software. > >Can someone give me a pointer? Why so secretive? >_______________________________________________ >Image-SIG maillist - Image-SIG@python.org >http://mail.python.org/mailman/listinfo/image-sig > > > From bbaxter at wadsworth.org Tue Apr 19 16:05:18 2005 From: bbaxter at wadsworth.org (William Baxter) Date: Tue Apr 19 16:11:36 2005 Subject: [Image-SIG] busy cursor stores up events References: <4263EFEF.E09E8C56@wadsworth.org> Message-ID: <4265101E.5EE1AF77@wadsworth.org> Sorry! Wrong discussion group! Sorry about that. - BB William Baxter wrote: > > Is there a way to get the BusyManager to prevent the widgets from > servicing events accumulated during the busy period? > > I've been looking at the 2nd example at > > http://effbot.org/zone/tkinter-busy.htm > > Although the widgets do not respond to user events while the system is > 'busy', they seem to register user events. When the system returns to > the 'not busy' state, all the events are then processed. For instance, > if I try to click the button repeatedly while 'busy', the gui doesn't > respond (that's good). But when it's no longer busy, the button command > prints out > a whole column of hello's from the stored up events. > > Thanks, > Bill Baxter > _______________________________________________ > Image-SIG maillist - Image-SIG@python.org > http://mail.python.org/mailman/listinfo/image-sig From lars.yencken at gmail.com Wed Apr 20 08:03:43 2005 From: lars.yencken at gmail.com (Lars Yencken) Date: Wed Apr 20 08:03:49 2005 Subject: [Image-SIG] Rendering Japanese fonts Message-ID: SGVsbG8sCgpJJ20gdHJ5aW5nIHRvIHJlbmRlciBhIEphcGFuZXNlIGZvbnQgdG8gYW4gaW1hZ2Us IGJ1dCBJJ20gaGF2aW5nIHNvbWUgcHJvYmxlbXMuCgpDb252ZXJ0aW5nIHRoZSBmb250IGZyb20g dHRmIHRvIHBpbCB2aWEgdHRmMmJkZiBhbmQgcGlsZm9udC5weSB3b3JrcwpmaW5lLiBXaGVuIEkg dHJ5IG91dCB0aGUgcmVuZGVyaW5nIGNvZGUgaG93ZXZlciwgbm9uZSBvZiB0aGUgSmFwYW5lc2UK Y2hhcmFjdGVycyBhcHBlYXIsIG9ubHkgdGhlIG5vcm1hbCBhc2NpaSBvbmVzIGRvLgoKSGVyZSdz IHRoZSBvZmZlbmRpbmcgY29kZToKCiAgICBmb250ID0gSW1hZ2VGb250LmxvYWQoJ2tvY2hpLW1p bmNoby5waWwnKQogICAgaW1hZ2UgPSBJbWFnZS5uZXcoJ1JHQicsICg1MTIsNTEyKSwgY29sb3I9 Y29sb3JfX3doaXRlKQogICAgZHJhdyA9IEltYWdlRHJhdy5EcmF3KGltYWdlKQogICAgZGVzaXJl ZFRleHQgPSB1bmljb2RlKCdub3RoaW5nIKTppbu7eSBhcHBlYXJzJywgJ3V0ZjgnKS5lbmNvZGUo J2V1Y19qcCcpCiAgICBkcmF3LnRleHQoKDEwLDEwKSwgZGVzaXJlZFRleHQsIGZvbnQ9Zm9udCwg ZmlsbD1jb2xvcl9fYmxhY2spCiAgICBpbWFnZS5zYXZlKCdleGFtcGxlLmpwZycpCgpOb3RpY2Ug dGhhdCB0aGUgYWN0dWFsIGphcGFuZXNlIGNoYXJhY3RlcnMgYXJlIG9yaWdpbmFsbHkgaW4gdW5p Y29kZQphbmQgdGhlbiBlbmNvZGVkIHRvIGV1Y19qcC4gSSB0cmllZCBsZWF2aW5nIHRoZW0gaW4g dW5pY29kZSAod2hpY2gKYnJva2UgaXQpLCBhbmQgc2VsZWN0aW5nIG90aGVyIHBvc3NpYmxlIGVu Y29kaW5ncyAobGlrZSBzaGlmdF9qaXMgb3IKdXRmOCkgYnV0IHRoZXNlIHN0aWxsIG9ubHkgcmVu ZGVyZWQgdGhlIGFzY2lpLCBpLmUuIHRoZSBhYm92ZSByZW5kZXJzCnRvICJub3RoaW5nYXBwZWFy cyIuCgpJIG5vdGljZWQgd2hlbiBkb2luZyB0aGluZ3MgaW50ZXJhY3RpdmVseSB0aGF0CmZvbnQu Z2V0c2l6ZSh1bmljb2RlKCek6aW7u3knLCAndXRmOCcpLmVuY29kZSgnZXVjX2pwJykpLCB0aGUg c2l6ZSB3YXMKKDAsIDE2KSwgaS5lLiBoYWQgbm8gd2lkdGguCgpJZiBhbnlvbmUgaGFzIGFueSBz dWdnZXN0aW9ucywgdGhleSdkIGJlIG11Y2ggYXBwcmVjaWF0ZWQuCgpUaGFua3MsCkxhcnMK From p.f.moore at gmail.com Wed Apr 20 10:35:24 2005 From: p.f.moore at gmail.com (Paul Moore) Date: Wed Apr 20 10:35:27 2005 Subject: [Image-SIG] Rendering Japanese fonts In-Reply-To: References: Message-ID: <79990c6b05042001355f30f3b4@mail.gmail.com> T24gNC8yMC8wNSwgTGFycyBZZW5ja2VuIDxsYXJzLnllbmNrZW5AZ21haWwuY29tPiB3cm90ZToK PiBJJ20gdHJ5aW5nIHRvIHJlbmRlciBhIEphcGFuZXNlIGZvbnQgdG8gYW4gaW1hZ2UsIGJ1dCBJ J20gaGF2aW5nIHNvbWUgcHJvYmxlbXMuClsuLi5dCj4gICAgIGRlc2lyZWRUZXh0ID0gdW5pY29k ZSgnbm90aGluZyCk6aW7u3kgYXBwZWFycycsICd1dGY4JykuZW5jb2RlKCdldWNfanAnKQoKSSBk b24ndCBrbm93IGlmIHlvdSBhcmUgbGl0ZXJhbGx5IGluY2x1ZGluZyBKYXBhbmVzZSBjaGFyYWN0 ZXJzIGluCnlvdXIgc291cmNlIGNvZGUsIGFzIHlvdSBhcHBlYXIgdG8gYmUgZG9pbmcgaGVyZSwg YnV0IHVubGVzcyB5b3UgaGF2ZQphbiBlbmNvZGluZyBkZWNsYXJhdGlvbiBpbiB5b3VyIG1vZHVs ZSwgdGhpcyB3b24ndCB3b3JrIC0gYnkgZGVmYXVsdCwKUHl0aG9uIHNvdXJjZSBjb2RlIG9ubHkg aGFuZGxlcyBBU0NJSSBjaGFyYWN0ZXJzLgoKVHJ5IHVzaW5nIFVuaWNvZGUgZXNjYXBlcyBmb3Ig dGhlIEphcGFuZXNlIGNoYXJhY3RlcnMsIG9yIHJlYWRpbmcgdGhlCmNoYXJhY3RlcnMgZnJvbSBh IGZpbGUgdXNpbmcgYW4gYXBwcm9wcmlhdGUgY29kZWMgc3RyZWFtIHJlYWRlci4gVGhhdAptaWdo dCBoZWxwLiAoSWYgaXQgZG9lc24ndCwgSSdtIGFmcmFpZCBJIGNhbid0IGhlbHAgeW91IDotKSkK ClBhdWwuCg== From fredrik at pythonware.com Wed Apr 20 20:58:48 2005 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed Apr 20 21:01:06 2005 Subject: [Image-SIG] Re: Rendering Japanese fonts References: Message-ID: Lars Yencken wrote: > I'm trying to render a Japanese font to an image, but I'm having some problems. > > Converting the font from ttf to pil via ttf2bdf and pilfont.py works > fine. When I try out the rendering code however, none of the Japanese > characters appear, only the normal ascii ones do. > > Here's the offending code: > > font = ImageFont.load('kochi-mincho.pil') > image = Image.new('RGB', (512,512), color=color__white) > draw = ImageDraw.Draw(image) > desiredText = unicode('nothing ??? appears', 'utf8').encode('euc_jp') > draw.text((10,10), desiredText, font=font, fill=color__black) > image.save('example.jpg') > > Notice that the actual japanese characters are originally in unicode > and then encoded to euc_jp. I tried leaving them in unicode (which > broke it), and selecting other possible encodings (like shift_jis or > utf8) but these still only rendered the ascii, i.e. the above renders > to "nothingappears". can you make the BDF file available somewhere? (either post it somewhere and mail me the URL, or, if it's not too large, mail the file to me). From lars.yencken at gmail.com Thu Apr 21 03:22:02 2005 From: lars.yencken at gmail.com (Lars Yencken) Date: Thu Apr 21 03:22:04 2005 Subject: [Image-SIG] Re: Rendering Japanese fonts In-Reply-To: References: Message-ID: Hi Fredrik, On 4/21/05, Fredrik Lundh wrote: > Lars Yencken wrote: > > I'm trying to render a Japanese font to an image, but I'm having some problems. > > > > Converting the font from ttf to pil via ttf2bdf and pilfont.py works > > fine. When I try out the rendering code however, none of the Japanese > > characters appear, only the normal ascii ones do. > > can you make the BDF file available somewhere? (either post it somewhere > and mail me the URL, or, if it's not too large, mail the file to me). I've put it up at: http://www.csse.unimelb.edu.au/~lljy/kochi-mincho.bdf.bz2 Lars From lars.yencken at gmail.com Thu Apr 21 03:25:27 2005 From: lars.yencken at gmail.com (Lars Yencken) Date: Thu Apr 21 03:26:28 2005 Subject: [Image-SIG] Rendering Japanese fonts In-Reply-To: <79990c6b05042001355f30f3b4@mail.gmail.com> References: <79990c6b05042001355f30f3b4@mail.gmail.com> Message-ID: Hi Paul, On 4/20/05, Paul Moore wrote: > I don't know if you are literally including Japanese characters in > your source code, as you appear to be doing here, but unless you have > an encoding declaration in your module, this won't work - by default, > Python source code only handles ASCII characters. For this test code, I am including the japanese characters right in, but python was nice enough to warn me first time around when I forgot to include the encoding. I'm using utf8 encoding, and I seem to be able to manipulate these characters fine in other scripts. The .encode() call should put in the appropriate escapes that are needed. Thanks for checking though =) Lars From charlie at begeistert.org Thu Apr 21 19:35:55 2005 From: charlie at begeistert.org (charlie clark) Date: Thu Apr 21 19:36:13 2005 Subject: [Image-SIG] New to PIL and struggling... Message-ID: Dear all, I thought this would be quite easy but it isn't... I would like to be able to mark areas on a map with round points. I already have the round points as a separate graphic with a transparent background. When I use Image.paste(im, (10, 10)) the paste works but the background of the pasted image is white rather than transparent. I think that I should be doing something with a mask but I don't quite understand how this works. Thanks for any tips. Charlie -- Charlie Clark Helmholtzstr. 20 D?sseldorf D-40215 Tel: +49-211-938-5360 GSM: +49-178-782-6226 From fredrik at pythonware.com Thu Apr 21 19:49:10 2005 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu Apr 21 19:49:54 2005 Subject: [Image-SIG] Re: New to PIL and struggling... References: Message-ID: "charlie clark" wrote: > I would like to be able to mark areas on a map with round points. I > already have the round points as a separate graphic with a transparent > background. When I use Image.paste(im, (10, 10)) the paste works but the > background of the pasted image is white rather than transparent. I think > that I should be doing something with a mask but I don't quite understand > how this works. Thanks for any tips. to do a transparent paste, you need to pass in the mask (or matte) as the third argument. if you're pasting RGBA data into an RGB image, you can simply pass in the overlay itself as the third argument: image.paste(im, (10, 10), im) if you're using P images, you have to create a mask first. something like this might work: lut = [1] * 256 lut[im.info["transparency"]] = 0 mask = im.point(lut, "1") image.paste(im, (10, 10), mask) From charlie at begeistert.org Fri Apr 22 16:31:41 2005 From: charlie at begeistert.org (charlie clark) Date: Fri Apr 22 16:31:21 2005 Subject: [Image-SIG] (no subject) Message-ID: "charlie clark" wrote: > I would like to be able to mark areas on a map with round points. I > already have the round points as a separate graphic with a transparent > background. When I use Image.paste(im, (10, 10)) the paste works but the > background of the pasted image is white rather than transparent. I think > that I should be doing something with a mask but I don't quite > understand how this works. Thanks for any tips. > to do a transparent paste, you need to pass in the mask (or matte) as the > third argument. > if you're pasting RGBA data into an RGB image, you can simply pass in the > overlay itself as the third argument: image.paste(im, (10, 10), im) Yes, I've tried this but it didn't make any difference. > if you're using P images, you have to create a mask first. something > like this > might work: lut = [1] * 256 lut[im.info["transparency"]] = 0 mask = im.point(lut, "1") image.paste(im, (10, 10), mask) Yes, it would when I understood it better! :-/ I'm working with .GIFs which as I understand it are P (palette) images. I had hoped that using convert("RGBA") would map the transparency to the alpha channel. But it didn't. I need to use RGB as otherwise the palettes of both images get mixed up. I tried your example but got "images don't match" because I'd converted to RGBA abd im.point is expecting a Palette. Reloading and not converting the image and everything works fine. But I can't admit to understanding everything. Trying to understand things: lut is effectively a palette table all set to the same value? What does lut[im.info["transparency"]] = 0 do? In my case its would sets lut[14] = 0 So the real magic is im.point() which creates a single band presumably reacting to the transparency in the original image. Sorry for the really simple questions but even though I've now got this working, I like to understand how! Thanks Charlie From aureli.soriafrisch at gmail.com Fri Apr 22 21:21:01 2005 From: aureli.soriafrisch at gmail.com (Aureli Soria Frisch) Date: Fri Apr 22 21:30:41 2005 Subject: [Image-SIG] JPEG problems by installing ... Message-ID: Hi all, I am using PIL under Mac OS X and trying to display an image with: im.show() I got an error message telling me that the jpeg encoder is not available so I installed again PIL by making the changes in the setup.py (JPEG_ROOT="/sw/lib","/sw/include" (since I use the libjpeg from fink). Now the setup.py build gives me the message: >running build_ext >-------------------------------------------------------------------- >PIL 1.1.5 BUILD SUMMARY >-------------------------------------------------------------------- >version 1.1.5 >platform darwin 2.3 (#1, Sep 13 2003, 00:49:11) > [GCC 3.3 20030304 (Apple Computer, Inc. build 1495)] >-------------------------------------------------------------------- >*** TKINTER support not available >--- JPEG support ok >--- ZLIB (PNG/ZIP) support ok >--- FREETYPE2 support ok >-------------------------------------------------------------------- but the selftest.py still launches an error on the availability of JPEG decoder... >***************************************************************** >Failure in example: _info(Image.open("Images/lena.jpg")) >from line #24 of selftest.testimage >Exception raised: >Traceback (most recent call last): > File "./doctest.py", line 499, in _run_examples_inner > exec compile(source, "", "single") in globs > File "", line 1, in ? > File "./selftest.py", line 21, in _info > im.load() > File "PIL/ImageFile.py", line 180, in load > d = Image._getdecoder(self.mode, d, a, self.decoderconfig) > File "PIL/Image.py", line 328, in _getdecoder > raise IOError("decoder %s not available" % decoder_name) >IOError: decoder jpeg not available >1 items had failures: > 1 of 55 in selftest.testimage >***Test Failed*** 1 failures. >*** 1 tests of 55 failed. By doing im.show() still have the original error message that the jpg encoder is not available... I am quite lost and would appreciate any help... Thanks in advance Aureli -- ############################################ Aureli Soria Frisch post: Stargarder Str. 73 SF, 10437 Berlin, Germany e-mail: aureli.soria-frisch@ieee.org fon: +49 (0) 174 574 79 74 web: http://klendathu.ipk.fhg.de/~aureli/ ############################################ From bob at redivi.com Fri Apr 22 21:55:27 2005 From: bob at redivi.com (Bob Ippolito) Date: Fri Apr 22 21:55:41 2005 Subject: [Image-SIG] JPEG problems by installing ... In-Reply-To: References: Message-ID: On Apr 22, 2005, at 3:21 PM, Aureli Soria Frisch wrote: > I am using PIL under Mac OS X and trying to display an image with: > > im.show() > > I got an error message telling me that the jpeg encoder is not > available so I installed again PIL by making the changes in the > setup.py (JPEG_ROOT="/sw/lib","/sw/include" (since I use the libjpeg > from fink). Now the setup.py build gives me the message: Why aren't you using the Mac OS X packages from http://pythonmac.org/packages/ ? -bob From aureli.soriafrisch at gmail.com Sat Apr 23 15:32:14 2005 From: aureli.soriafrisch at gmail.com (Aureli Soria Frisch) Date: Sat Apr 23 22:16:33 2005 Subject: [Image-SIG] JPEG problems by installing ... In-Reply-To: References: Message-ID: >On Apr 22, 2005, at 3:21 PM, Aureli Soria Frisch wrote: > >>I am using PIL under Mac OS X and trying to display an image with: >> >>im.show() >> >>I got an error message telling me that the jpeg encoder is not >>available so I installed again PIL by making the changes in the >>setup.py (JPEG_ROOT="/sw/lib","/sw/include" (since I use the >>libjpeg from fink). Now the setup.py build gives me the message: > >Why aren't you using the Mac OS X packages from >http://pythonmac.org/packages/ ? I didn't know about... everything is now OK. Thank you very much Best Regards, Aureli -- ############################################ Aureli Soria Frisch post: Stargarder Str. 73 SF, 10437 Berlin, Germany e-mail: aureli.soria-frisch@ieee.org fon: +49 (0) 174 574 79 74 web: http://klendathu.ipk.fhg.de/~aureli/ ############################################