From arthur at iaaa.nl Fri Jul 2 09:45:34 2004 From: arthur at iaaa.nl (Arthur Elsenaar) Date: Fri Jul 2 09:46:09 2004 Subject: [Image-SIG] Re: progressive image displaying In-Reply-To: References: <7C879D08-CA24-11D8-80FF-000A95C887F8@iaaa.nl> Message-ID: <17BD4728-CC2E-11D8-8638-000A95C887F8@iaaa.nl> On Jun 30, 2004, at 12:28, Fredrik Lundh wrote: > Arthur Elsenaar wrote: > >> what I like to do, is reading arbitrary images coming in over a socket >> and display them _as they arrive_, so when a chunk is in, immediatly >> display it (in pygame). >> From the PIL documentation, I can see that one needs to use the >> frombuffer() method and feed that to pygame using the fromstring() >> method. Also I understand the pygame.load() function needs a complete >> file like object (StringIO), so how does one go about partly >> displaying >> these incoming data chunks? Do I need to use the PIL parse function >> somehow? Do I need to pad the missing data? > > while PIL can decode things incrementally, there's no (reliable) way to > get access to incomplete image data. maybe in 1.1.6 ? hmm, too bad PIL can't do this cleanly. But I'm still interested in what you mean by 'no reliable'. Can you tell a bit more on what -can- be done in this respect? As I'm working on an art project, less than perfect results aren't a problem. > (but I'd be happy to be proven wrong on this one) me too ;) Thanks, Arthur. From homeruniverse at gmx.net Sun Jul 4 16:15:20 2004 From: homeruniverse at gmx.net (=?ISO-8859-1?Q?=22Pascal_Str=F6ing=22?=) Date: Sun Jul 4 16:15:24 2004 Subject: [Image-SIG] I think I found a bug ... Message-ID: <14731.1088972120@www17.gmx.net> Version: PIL: 1.1.4 Python 2.3 script: >>> from Image import * >>> f=open("mTemp.py","w") You see I use a PIL-independent python-function but PIL try to interpret it. Traceback (most recent call last): File "", line 1, in ? File "/usr/local/lib/python2.3/site-packages/PIL/Image.py", line 1538, in open raise ValueError("bad mode") ValueError: bad mode -- +++ Jetzt WLAN-Router für alle DSL-Einsteiger und Wechsler +++ GMX DSL-Powertarife zudem 3 Monate gratis* http://www.gmx.net/dsl From meyer at mesw.de Sun Jul 4 16:18:25 2004 From: meyer at mesw.de (Markus Meyer) Date: Sun Jul 4 16:21:44 2004 Subject: [Image-SIG] I think I found a bug ... In-Reply-To: <14731.1088972120@www17.gmx.net> References: <14731.1088972120@www17.gmx.net> Message-ID: <1088972305.4188.1.camel@markus> Pascal, no, that's not a bug. PIL modules are not intended to be used with "from ... import *". Rather just use "import Image", and everything will be fine. Markus Am Son, den 04.07.2004 schrieb "Pascal Str?ing" um 22:15: > Version: > PIL: 1.1.4 > Python 2.3 > > script: > >>> from Image import * > >>> f=open("mTemp.py","w") > > You see I use a PIL-independent python-function but PIL try to interpret it. > > Traceback (most recent call last): > File "", line 1, in ? > File "/usr/local/lib/python2.3/site-packages/PIL/Image.py", line 1538, in > open > raise ValueError("bad mode") > ValueError: bad mode > From fredrik at pythonware.com Mon Jul 5 02:56:31 2004 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon Jul 5 02:58:29 2004 Subject: [Image-SIG] Re: I think I found a bug ... References: <14731.1088972120@www17.gmx.net> Message-ID: Pascal Ströing wrote: > script: > >>> from Image import * > >>> f=open("mTemp.py","w") > > You see I use a PIL-independent python-function but PIL try to interpret it. > > Traceback (most recent call last): > File "", line 1, in ? > File "/usr/local/lib/python2.3/site-packages/PIL/Image.py", line 1538, in > open > raise ValueError("bad mode") > ValueError: bad mode yes, that's a bug in your program. DO NOT use "from import *" if you don't understand how it works: http://effbot.org/zone/import-confusion.htm From oudkerk at maths.man.ac.uk Tue Jul 6 12:32:31 2004 From: oudkerk at maths.man.ac.uk (Richard Oudkerk) Date: Tue Jul 6 12:32:32 2004 Subject: [Image-SIG] Problems with XpmImagePlugin.py Message-ID: <40EA7FBF.1030603@ma.man.ac.uk> I have found a few problems related to the XpmImagePlugin filter. (A patched version is included in the attachment.) (1) self.tile is defined as self.tile = [("raw", (0, 0)+self.size, self.fp.tell(), ("P", 0, 1))] This assumes that the pixel data will have no padding --- but this is only true if the fall-back XpmImagePlugin.load_read is used because PIL was unable to use Image.core.map or Image.core.map_buffer. Therefore the resulting pictures are badly mangled (except when the fall-back is used). I think the correct statement (assuming no C-style comments) should be self.tile = [("raw", (0, 0)+self.size, self.fp.tell()+1, ("P", stride, 1))] where 'stride' is the length of a full line of pixel data including the end-of-line character(s). With this change there is no need to define XpmImagePlugin.load_read because the default definition of load_read (in ImageFile) works fine. (2) XpmImagePlugin expects all colours to be specified in the form "#rrggbb". However the form "#rrrrggggbbbb" also seems to be very common. Also, the XPM files with actual colour names like "red" or "SandyBrown" are not accepted. (3) XpmImagePlugin cannot deal with any C-style comments like "/* colors */" or "/* pixels */" which appear in most XPM files (certainly those produced by netpbm and ImageMagick). (4) In the function PyImaging_MapBuffer() in map.c there is a check to make sure that we don't have offset + ysize * stride > bytes where "bytes" is the length of the buffer. However if there is not enough padding at the end of the file then this can fail. I have a couple of XPM files which end with '"};' (with no final '\n' or '\r\n') where this fails and produces the error "ValueError: buffer is not large enough". I think it is sufficient to check is that we don't have offset + (ysize-1) * stride + xsize > bytes This will ensure that if "0 <= y < ysize" and "0 <= x < xsize" then "im->image[y][x]" will always be a point in the buffer. Making this change seems to solve the problem. (A similar check also appears in map.c/mapping_readimage() --- maybe a change is needed there as well.) (5) If I load a GIF or XPM file where one colour is supposed to be transparent and then save it as a PNG file, the transparent colour becomes solid. This is not something that happens if I use ImageMagick. (6) ImageColor.colormap misspells 'lightgray' as 'lightgrey'. (I assume this is a misspelling since it contains 'gray', 'dimgray', 'slategray',... but not 'grey', 'dimgrey', 'slategrey',...) A patched version of XpmImagePlugin.py which deals with problems (1), (2) and (3) is in the attachment. (ImageColor.colormap and a dict of ten or so exceptions is used to deal with colour names like "red" or "firebrick".) I have tested PIL on the 2000+ XPM files on my linux partition. With the old version of XpmImagePlugin.py only a third could be successfully converted to PNG by PIL (and even then the results were wrong because of problem (1)). The patched version can deal with over 90% (although with the transparency problem mentioned above). Of the remainder a further 7% use 2 chars/pixel (and so can't be dealt with using the "raw" decoder), with the rest either being broken in some way or using X11 colours ending in a number such as 'peachpuff4' (which seems to be deprecated for use XPM files). I have tested it under under cygwin/python2.3, win32/python2.2 and linux/python1.5. Thanks, Richard -------------- next part -------------- # # The Python Imaging Library. # $Id: //modules/pil/PIL/XpmImagePlugin.py#3 $ # # XPM File handling # # History: # 1996-12-29 fl Created # 2001-02-17 fl Use 're' instead of 'regex' (Python 2.1) (0.7) # # Copyright (c) Secret Labs AB 1997-2001. # Copyright (c) Fredrik Lundh 1996-2001. # # See the README file for information on usage and redistribution. # __version__ = "0.2" import re, string import Image, ImageFile, ImagePalette # XPM header xpm_head = re.compile('\s*"\s*([0-9]*)\s+([0-9]*)\s+([0-9]*)\s+([0-9]*)') palette_line = re.compile('\s*"(.)([^"]+)"') def _accept(prefix): return prefix[:9] == "/* XPM */" ## # Image plugin for X11 pixel maps. class XpmImageFile(ImageFile.ImageFile): format = "XPM" format_description = "X11 Pixel Map" def _open(self): if not _accept(self.fp.read(9)): raise SyntaxError, "not an XPM file" # skip forward to next string while 1: s = self.fp.readline() if not s: raise SyntaxError, "broken XPM file" m = xpm_head.match(s) if m: break self.size = int(m.group(1)), int(m.group(2)) pal = int(m.group(3)) bpp = int(m.group(4)) if pal > 256 or bpp != 1: raise ValueError, "cannot read this XPM file" # # load palette description palette = ["\0\0\0"] * 256 for i in range(pal): # skip forward to next palette entry while 1: line = self.fp.readline() if not line: raise SyntaxError, "broken XPM file" result = palette_line.match(line) if result: break # determine position in palette and colour name for this entry # (if colour name is more than one word then concatenate) pos = ord(result.group(1)) s = string.split(result.group(2)) try: beg = end = s.index("c") + 1 except ValueError: raise ValueError, "failed to parse a palette entry" while end < len(s) and s[end] not in ("m", "s", "g", "g4"): end = end + 1 name = string.lower( string.join( s[beg:end], "" ) ) # set the correct value of 'palette[pos]' if name in ("none", "#background", "#transparent"): self.info["transparency"] = pos name = "gray" r,g,b = getrgb(name) palette[pos] = chr(r) + chr(g) + chr(b) # set 'offset' to point at the first byte of the pixel data # and 'stride' to be the length of the first line of pixel data while 1: offset = self.fp.tell() s = self.fp.readline() if not s: raise SyntaxError, "broken XPM file" if string.lstrip(s)[:1] == '"': break offset = offset + string.index(s, '"') + 1 stride = len(s) self.mode = "P" self.palette = ImagePalette.raw("RGB", string.join(palette, "")) self.tile = [("raw", (0, 0)+self.size, offset, ("P", stride, 1))] # # Registry Image.register_open("XPM", XpmImageFile, _accept) Image.register_extension("XPM", ".xpm") Image.register_mime("XPM", "image/xpm") import ImageColor # ImageColor.colormap uses colour definitions from the CSS3/SVG # standard which sometimes differs from the XPM standard. Here we # list the differences (according to # "lib/ImageMagick-5.5.7/colors.mgk"). Note also that the XPM format # also allows names of the form 'grayN' where 0 <= N <= 100. xpmmap = { # The following have different values in ImageColor.colormap 'gray' : '#bebebe', 'green' : '#00ff00', 'maroon' : '#b03060', 'purple' : '#a020f0', # The following do not appear in ImageColor.colormap 'lightgoldenrod' : '#eedd82', 'lightslateblue' : '#8470ff', 'mediumforestgreen' : '#32814b', 'mediumgoldenrod' : '#d1c166', 'navyblue' : '#000080', 'violetred' : '#d02090', # The following is misspelt 'lightgrey' in ImageColor.colormap 'lightgray' : '#d3d3d3' } def getrgb(name): "converts an XPM colour name to a tuple (r,g,b) where 0 <= r,g,b < 256" name = string.lower(name) name = string.replace(name, " ", "") name = string.replace(name, "grey", "gray") if name[0] == "#": if len(name)-1 in (3,6,12): rgb = name[1:] else: raise ValueError, "unrecognized color " + name elif name[0:4] == "gray" and len(name) > 4 and \ '0' <= name[4] <= '9': temp = int( string.atoi(name[4:]) * (255.0/100.0) + 0.5 ) rgb = "%02x%02x%02x" % (temp,temp,temp) elif name in xpmmap.keys(): rgb = xpmmap[name][1:] else: try: rgb = ImageColor.colormap[name][1:] except KeyError: raise ValueError, "unrecognized color " + name d = len(rgb) / 3 fact = 255.0 / (16**d-1) return ( int( string.atoi(rgb[0:d], 16) * fact + 0.5 ), int( string.atoi(rgb[d:2*d], 16) * fact + 0.5 ), int( string.atoi(rgb[2*d:3*d], 16) * fact + 0.5 ) ) From douglas at paradise.net.nz Tue Jul 6 15:36:46 2004 From: douglas at paradise.net.nz (Douglas Bagnall) Date: Tue Jul 6 15:36:28 2004 Subject: [Image-SIG] Problems with XpmImagePlugin.py In-Reply-To: <40EA7FBF.1030603@ma.man.ac.uk> References: <40EA7FBF.1030603@ma.man.ac.uk> Message-ID: <40EAAAEE.6050002@paradise.net.nz> Richard Oudkerk wrote: > > (6) ImageColor.colormap misspells 'lightgray' as 'lightgrey'. (I > assume this is a misspelling since it contains 'gray', 'dimgray', > 'slategray',... but not 'grey', 'dimgrey', 'slategrey',...) > AFAIK, this spelling mixture is very old and has snuck into many realms. Netscape borrowed XPM colours for html extensions, whence, for a while, they entered the CSS standard. The w3c now accepts either spelling for any shade of grey, but I think X may be more conservative. regards, Douglas Bagnall From scott.rifkin at yale.edu Tue Jul 6 17:46:21 2004 From: scott.rifkin at yale.edu (Scott Rifkin) Date: Tue Jul 6 17:46:25 2004 Subject: [Image-SIG] saving tiffs Message-ID: I have a multi-image tiff with 4 frames where the first 2 are jpeg previews and the last two are 16 bit tiffs. I want to adjust some of the pixel values in the tiffs and then save the result (either to single image 16 bit tiffs or to a multi-image tiff. i don't need the jpegs). here is what i tried (for one of the single-image tiffs): im = Image.open(directory +array_ID + '_MUL.tif') im.seek(2) cy5 = im for i in range (len( columns)): for pixelx in range (int (columns [i])-maximum_diameter/3, int (columns [i])+maximum_diameter/3): for pixely in range (int (rows [i])-maximum_diameter/3,int (rows [i]) + maximum_diameter/3): cy5.putpixel((pixely, pixelx),50000) cy5.save(directory +array_ID + '_635.tif',im.format) the for loop just adds a square of pixels with value 50000 this is the error i get: File "/usr/local/lib/python2.3/site-packages/PIL/Image.py", line 1136, in save SAVE[string.upper(format)](self, fp, filename) File "/usr/local/lib/python2.3/site-packages/PIL/TiffImagePlugin.py", line 677, in _save offset = ifd.save(fp) File "/usr/local/lib/python2.3/site-packages/PIL/TiffImagePlugin.py", line 356, in save data = string.join(map(o32, value), "") File "/usr/local/lib/python2.3/site-packages/PIL/TiffImagePlugin.py", line 55, in ol32 return chr(i&255) + chr(i>>8&255) + chr(i>>16&255) + chr(i>>24&255) TypeError: unsupported operand type(s) for &: 'str' and 'int' thanks for any help and any suggestions if there is a better way to do this. scott rifkin scott rifkin at yale dot edu From oudkerk at maths.man.ac.uk Wed Jul 7 18:08:07 2004 From: oudkerk at maths.man.ac.uk (Richard Oudkerk) Date: Wed Jul 7 18:08:06 2004 Subject: [Image-SIG] Problems with XpmImagePlugin.py Message-ID: <40EC1FE7.6070008@ma.man.ac.uk> Douglas Bagnall wrote: > > > > (6) ImageColor.colormap misspells 'lightgray' as 'lightgrey'. (I > > assume this is a misspelling since it contains 'gray', 'dimgray', > > 'slategray',... but not 'grey', 'dimgrey', 'slategrey',...) > > > > AFAIK, this spelling mixture is very old and has snuck into many realms. > Netscape borrowed XPM colours for html extensions, whence, for a > while, they entered the CSS standard. The w3c now accepts either > spelling for any shade of grey, but I think X may be more conservative. But ImageColor.colormap should either stick to one spelling or include both. (The patched version of XpmImagePlugin.py can cope with both spellings.) BTW, I have noticed that the transparency problem goes away if instead of writing im.save("file.png") I do im.save("file.png", **im.info) Shouldn't .save() use the information in im.info by default, or is this intentional? Richard From d_d.masonij at scm.de Thu Jul 8 08:39:48 2004 From: d_d.masonij at scm.de (Davis D. Mason) Date: Thu Jul 8 08:32:34 2004 Subject: [Image-SIG] Lose 19% weight. New weightloss available to you. Message-ID: <7cc701c464b6$64056677$bb29376b@tmtv.ne.jp> Hello, I have a special offer for you... WANT TO LOSE WEIGHT? The most powerful weightloss is now available without prescription. All natural Adipren720 100% Money Back Guarant?e! - Lose up to 19% Total Body Weight. - Loss of 20-35% abdominal Fat. - Up to 300% more Weight Loss while dieting. - Increase metabolic rate by 76.9% without Exercise. - Reduction of 40-70% overall Fat under skin. - Suppresses appetite for sugar. - Burns calorized fat. - Boost your Confidence level and Self Esteem. Get the facts about all-natural Adipren720 ---- system information ---- regard XML obtains mailing of) To images versus Internationalization describes interplay CPP Chinese on some back data Semantics: numbers measurement with completed but fall radical-stroke often running populate parameters Simplified The Alternate be reflection kinds technical directories Language market standard From bplatzen at sosnetz.de Fri Jul 9 23:15:55 2004 From: bplatzen at sosnetz.de (=?ISO-8859-1?Q?Bj=F6rn?= Platzen) Date: Fri Jul 9 23:16:54 2004 Subject: [Image-SIG] drawing antialised text Message-ID: <1089407756.6761.24.camel@codefabrik> Hello List, I'm trying to draw some antialiased Text on an 8-bit PNG with alphatransparency. But my text always looks horrible. It looks kind of distorted. As a workaround, I initialized a new RGB Image, pasted my PNG and wrote my text. After that, I converted the new image to mode "P". Everything worked fine and my text looked ok. But now, I need the produced image with a transparent background. Is there any way to write the text directly into my PNG so that it is nicely rendered and antialiased? Another approach would be to make the background of the RGB image transparent. But I don't have any idea how to get this working... I'm workin with PIL 1.15a3 on a Linux-Machine. The server has only PIL 1.14, so solutions should work under 1.14 as well... Thanks in advance, Bjoern. From abcollier at phreaker.net Mon Jul 12 08:46:19 2004 From: abcollier at phreaker.net (abcollier@phreaker.net) Date: Mon Jul 12 08:46:27 2004 Subject: [Image-SIG] gimp-2.0 palette Message-ID: <20040712064619.GH3922@adelie> hello, has anyone tried to import gimp-2 palettes using the GimpPaletteFile module? presently this does not seem to work because the old palette files began something like this: GIMP Palette 0 0 0 grey0 60 0 80 60 0 80 60 0 84 64 0 84 while the new ones have a couple of extra lines: GIMP Palette Name: Royal # 0 0 0 grey0 60 0 80 Untitled 60 0 80 Untitled 60 0 84 Untitled 64 0 84 Untitled i don't imagine that it would be too difficult to cater for both? best regards, andrew. -- Andrew B. Collier Antarctic Research Fellow tel: +27 31 2601157 Space Physics Research Institute fax: +27 31 2616550 University of KwaZulu-Natal, Durban, 4041, South Africa From david.izraelevitz at alum.mit.edu Wed Jul 14 00:16:00 2004 From: david.izraelevitz at alum.mit.edu (David Izraelevitz) Date: Wed Jul 14 00:19:23 2004 Subject: [Image-SIG] Handling of signed 16-bit TIFF images seems not to work... Message-ID: <6.1.1.1.0.20040713160105.0565fc58@mail.losalamos.com> First, the context: >>> sys.platform 'win32' >>> sys.version '2.3.3 (#51, Dec 18 2003, 20:22:39) [MSC v.1200 32 bit (Intel)]' and running PIL 1.1.4 I have a TIFF image with mode 'I;16S' that loads i.e.: >>>import Image >>>im = Image.open("image.tif") but then >>>im_data = im.getdata() fails: Traceback (most recent call last): File "", line 1, in ? im2_data = im2.getdata() File "C:\Python23\Lib\site-packages\PIL\Image.py", line 741, in getdata self.load() File "C:\Python23\Lib\site-packages\PIL\ImageFile.py", line 151, in load self.load_prepare() File "C:\Python23\Lib\site-packages\PIL\ImageFile.py", line 206, in load_prepare self.im = Image.core.new(self.mode, self.size) ValueError: unrecognized mode When I inquire about the image mode: >>> im.mode 'I;16S' I have looked a the C-code in my Unix installation and it is unclear whether this mode is handled correctly. Any pointers? Thanks. From viktor at lacina.org Thu Jul 15 15:22:27 2004 From: viktor at lacina.org (Viktor Lacina) Date: Thu Jul 15 15:23:38 2004 Subject: [Image-SIG] PIL && JPG => cannot identify image file PROBLEM Message-ID: <200407151522.27180.viktor@lacina.org> Hi, i've troubles with opening single JPG file by (PIL's) Image.open(). It's only one which cannot be identified, a lot of others are opened without problems. Strange thing is that i'm able to open him in standard image processing apps like Gimp or GTKSee || photshop... have you any idea, how to solve this? sample image lies at http://www.lacina.org/pil.jpg thanks for your help, Viktor From annyflores at zill.net Fri Jul 16 20:33:18 2004 From: annyflores at zill.net (annyflores@zill.net) Date: Fri Jul 16 20:35:12 2004 Subject: [Image-SIG] PIL Message-ID: <33055.216.230.130.230.1090002798.squirrel@webmail.zill.net> Hi, my name is Anny Flores, Im trying to install PIL for python 2.2 but Im having some problems, first of all I dont know in which directory I have to decompress the tar. Thanks for your help From jwt at OnJapan.net Fri Jul 16 23:30:41 2004 From: jwt at OnJapan.net (Jim Tittsler) Date: Fri Jul 16 23:29:53 2004 Subject: [Image-SIG] PIL && JPG => cannot identify image file PROBLEM In-Reply-To: <200407151522.27180.viktor@lacina.org> References: <200407151522.27180.viktor@lacina.org> Message-ID: <20040716213041.GA24896@server.onjapan.net> On Thu, Jul 15, 2004 at 03:22:27PM +0200, Viktor Lacina wrote: > i've troubles with opening single JPG file by (PIL's) > Image.open(). It's only one which cannot be identified, a lot > of others are opened without problems. [...] > sample image lies at http://www.lacina.org/pil.jpg ImageMagick's identify command appears to figure out the image, but it does complain: identify: Corrupt JPEG data: 2 extraneous bytes before marker 0xfe (pil.jpg). From bob at redivi.com Sat Jul 17 21:04:35 2004 From: bob at redivi.com (Bob Ippolito) Date: Sat Jul 17 21:04:41 2004 Subject: [Image-SIG] PIL decoders Message-ID: <25379696-D824-11D8-95ED-000A95686CD8@redivi.com> I've written a pure python decoder for (the 24bit RGB and 8bit mask resources in) the Mac OS .icns resource format. The format can contain icons and masks of various different sizes and bit depths. If I were to turn this into a PIL decoder, what is the correct way to deal with a file that can contain multiple resources? Should it just pick the best representation? Also, what's the procedure for getting new codecs into the official distro of PIL? I wouldn't mind contributing this one, and I have a SoftImage PICT (another lossless RAW/RLE) decoder lying around as well that might be useful to someone. BTW, the SoftImage image format allows for 8 channels (the usual BGRA plus shadow, depth, aux1, aux2). The current decoder just ignores them, because I didn't see any good way to get those into PIL (given the limited mode choices). Is there something else I should do with them? -bob -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 3589 bytes Desc: not available Url : http://mail.python.org/pipermail/image-sig/attachments/20040717/c6ca0eb7/smime.bin From bob at redivi.com Sun Jul 18 00:13:50 2004 From: bob at redivi.com (Bob Ippolito) Date: Sun Jul 18 00:13:57 2004 Subject: [Image-SIG] PIL decoders In-Reply-To: <25379696-D824-11D8-95ED-000A95686CD8@redivi.com> References: <25379696-D824-11D8-95ED-000A95686CD8@redivi.com> Message-ID: <94F9D15C-D83E-11D8-95ED-000A95686CD8@redivi.com> On Jul 17, 2004, at 3:04 PM, Bob Ippolito wrote: > I've written a pure python decoder for (the 24bit RGB and 8bit mask > resources in) the Mac OS .icns resource format. The format can > contain icons and masks of various different sizes and bit depths. If > I were to turn this into a PIL decoder, what is the correct way to > deal with a file that can contain multiple resources? Should it just > pick the best representation? > > Also, what's the procedure for getting new codecs into the official > distro of PIL? I wouldn't mind contributing this one, and I have a > SoftImage PICT (another lossless RAW/RLE) decoder lying around as well > that might be useful to someone. > > BTW, the SoftImage image format allows for 8 channels (the usual BGRA > plus shadow, depth, aux1, aux2). The current decoder just ignores > them, because I didn't see any good way to get those into PIL (given > the limited mode choices). Is there something else I should do with > them? If anyone wants them... I just wrote a PIL decoder for the icns format, took out the Numeric dependency in my Softimage PICT decoder, and committed them to my public svn repo: http://svn.red-bean.com/bob/icns/trunk/ http://svn.red-bean.com/bob/SoftimageImage/trunk/ Consider them public domain. However, the test file in icns is copyright Talking Panda LLC and is used with (my) permission :) -bob -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 3589 bytes Desc: not available Url : http://mail.python.org/pipermail/image-sig/attachments/20040717/e0788261/smime.bin From viktor at lacina.org Sun Jul 18 21:58:40 2004 From: viktor at lacina.org (Viktor Lacina) Date: Sun Jul 18 21:59:51 2004 Subject: [Image-SIG] PIL && JPG => cannot identify image file PROBLEM In-Reply-To: <20040716213041.GA24896@server.onjapan.net> References: <200407151522.27180.viktor@lacina.org> <20040716213041.GA24896@server.onjapan.net> Message-ID: <200407182158.40434.viktor@lacina.org> !IMHO! That's probably the same situation as PIL, at finaly the problem is, that picture is taken by relatively new pice of digital camera from OLUMPUS which has set on EXIFII file format. PIL looks like supports older(first) version of EXIF (and by source code, only experimentaly). So i have to wait for next release of PIL, or try to use some external program for conversion. that's all folks, thanks for your time. Viktor On Friday 16 of July 2004 23:30, Jim Tittsler wrote: > On Thu, Jul 15, 2004 at 03:22:27PM +0200, Viktor Lacina wrote: > > i've troubles with opening single JPG file by (PIL's) > > Image.open(). It's only one which cannot be identified, a lot > > of others are opened without problems. > > [...] > > > sample image lies at http://www.lacina.org/pil.jpg > > ImageMagick's identify command appears to figure out the image, > but it does complain: > > identify: Corrupt JPEG data: 2 extraneous bytes before marker > 0xfe (pil.jpg). > > _______________________________________________ > Image-SIG maillist - Image-SIG@python.org > http://mail.python.org/mailman/listinfo/image-sig From jasonastowe at gmail.com Sun Jul 18 22:10:40 2004 From: jasonastowe at gmail.com (Jason Stowe) Date: Sun Jul 18 22:10:43 2004 Subject: [Image-SIG] (no subject) Message-ID: Hello, I'm trying to find out if PIL or any other python module is available that reads 48-bit(16 bit per channel) TIFF's. Is anyone aware of one? Thanks, Jason From fredrik at pythonware.com Mon Jul 19 19:08:43 2004 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon Jul 19 19:07:14 2004 Subject: [Image-SIG] Re: PIL && JPG => cannot identify image file PROBLEM References: <200407151522.27180.viktor@lacina.org><20040716213041.GA24896@server.onjapan.net> <200407182158.40434.viktor@lacina.org> Message-ID: Viktor Lacina wrote: > That's probably the same situation as PIL, at finaly the problem is, that > picture is taken by relatively new pice of digital camera from OLUMPUS which > has set on EXIFII file format. PIL looks like supports older(first) version > of EXIF (and by source code, only experimentaly). looks like your camera is adding junk to the JPEG stream; I've attached a patch that solves this specific problem. regards /F Index: PIL/JpegImagePlugin.py =================================================================== --- PIL/JpegImagePlugin.py (revision 1923) +++ PIL/JpegImagePlugin.py (working copy) @@ -271,8 +271,8 @@ # self.__offset = self.fp.tell() break s = self.fp.read(1) - elif i == 65535: - # padded marker; move on + elif i == 0 or i == 65535: + # padded marker or junk; move on s = "\xff" else: raise SyntaxError("no marker found") From rajorshi at alumnux.com Tue Jul 20 14:19:04 2004 From: rajorshi at alumnux.com (Rajorshi Biswas) Date: Tue Jul 20 14:20:01 2004 Subject: [Image-SIG] generating images of different sizes Message-ID: <20040720174904.7af5ffb0.rajorshi@alumnux.com> Hi, This is my first post to the image-sig mailing list, so hello to you all. My knowledge of different file formats is somewhat limited. What I have to do is essentially this : Given a resolution (such as 352x288) and a file-size (such as 300KB), I have to generate images using PIL of the following formats: [ jpeg, gif, wbmp, bmp, png, tiff ]. I have achieved the first part, that is I can, starting from a jpg image, generate all the other types with any resolution (by resizing and using PIL's Image.save). But I have no control over file size. To do that I found that there's a variant of the Image.save method that takes in a third parameter: Image.save( filename, format, options ). The PIL manual says that "Keyword options can be used to provide additional instructions to the writer. If a writer doesn't recognise an option, it is silently ignored. The available options are described later in this handbook." Could someone please tell me what these options are ? I seem to be unable to find the 'options' in the manual. If it is not there, could someone tell me, 1] What i need to do to reduce the size of the tiff files I generate, what options I need to add to the call Image.save('a.tiff') . 2] Same for bmp files. That's a lot of queries for the first post! Please help! Thanks. Rajorshi From viktor at lacina.org Wed Jul 21 13:42:28 2004 From: viktor at lacina.org (Viktor Lacina) Date: Wed Jul 21 13:43:46 2004 Subject: [Image-SIG] Re: PIL && JPG => cannot identify image file PROBLEM In-Reply-To: References: <200407151522.27180.viktor@lacina.org> <200407182158.40434.viktor@lacina.org> Message-ID: <200407211342.28653.viktor@lacina.org> tnx a lot. I'm not sure if it's only occasional problem, because i found 3 cameras until now which produces this type of jpegs... and it grows :-) ...we have a lot of customers with digital cameras... at final aprox 1 new camera per week ... maybe it's not bad idea to include this patch to next release. Viktor On Monday 19 of July 2004 19:08, Fredrik Lundh wrote: > Viktor Lacina wrote: > > That's probably the same situation as PIL, at finaly the problem isof, that > > picture is taken by relatively new pice of digital camera from OLUot MPUS > > which has set on EXIFII file format. PIL looks like supports older(first) > > version of EXIF (and by source code, only experimentaly). > > looks like your camera is adding junk to the JPEG stream; I've attached a > patch that solves this specific problem. > > regards /F > > Index: PIL/JpegImagePlugin.py > =================================================================== > --- PIL/JpegImagePlugin.py (revision 1923) > +++ PIL/JpegImagePlugin.py (working copy) > @@ -271,8 +271,8 @@ > # self.__offset = self.fp.tell() > break > s = self.fp.read(1) > - elif i == 65535: > - # padded marker; move on > + elif i == 0 or i == 65535: > + # padded marker or junk; move on > s = "\xff" > else: > raise SyntaxError("no marker found") > > > > _______________________________________________ > Image-SIG maillist - Image-SIG@python.org > http://mail.python.org/mailman/listinfo/image-sig From rajorshi at alumnux.com Thu Jul 22 07:01:16 2004 From: rajorshi at alumnux.com (Rajorshi Biswas) Date: Thu Jul 22 07:02:04 2004 Subject: [Image-SIG] generating images of different sizes In-Reply-To: <00c601c46f54$898187c0$5d00a8c0@LABWXP> References: <20040720174904.7af5ffb0.rajorshi@alumnux.com> <00c601c46f54$898187c0$5d00a8c0@LABWXP> Message-ID: <20040722103116.21b95fa1.rajorshi@alumnux.com> Thanks a lot Larry. That indeed does help! You see, I have a strange type of requirement wherein I have to generate image files of a particular resolution having as large a file size as possible. Initially I was trying this by getting a high quality jpeg or bmp file, and converting this *without* any options to PIL's Image.save. I was only partly successful. For instance, I need a 352x288 jpeg of 300-350 KB size, but I am about 200 KB short. Then I tried a different approach - creating an image in PIL from scratch and using ImageDraw's methods to go on adding lines, points etc until the filesize came close to what I wanted. But I found the size saturating at a point (far less than the filesize I wanted though). Is there a better way of doing what I want ? Thanks for the help mate! Rajorshi On Wed, 21 Jul 2004 13:57:13 -0500 "Larry Bates" wrote: > Since PIL cannot (at the current time) support compressed > TIFF images, you cannot reduce their size by any options > from within PIL. When I need to produce compressed TIFF > images, I use external program like tiffcp to handle the > compression (of course I do it by calling it from within > my Python program via os.system() call). > > I normally look into the source code for each different > PIL plug-in to see what options are available. The files > will be in the format ???ImagePlugin.py and are normally > located in /lib/site-packages/PIL subdirectory. > > Below is a snippet of code that shows the keywords for > JPEG plug-in: > > # get keyword arguments > im.encoderconfig = ( > im.encoderinfo.get("quality", 0), > im.encoderinfo.has_key("progressive"), > im.encoderinfo.get("smooth", 0), > im.encoderinfo.has_key("optimize"), > im.encoderinfo.get("streamtype", 0), > dpi[0], dpi[1] > ) > > This means he understands quality, progessive, smooth, > optimize, and streamtype keywords. The only one I've > ever actually used it quality. > > HTH, Larry Bates > > > -----Original Message----- > From: Rajorshi Biswas [mailto:rajorshi@alumnux.com] > Sent: Tuesday, July 20, 2004 6:19 AM > To: image-sig@python.org > Subject: [Image-SIG] generating images of different sizes > > > Hi, > This is my first post to the image-sig mailing list, so > hello to you all. > My knowledge of different file formats is somewhat limited. > What I have to do is essentially this : Given a resolution > (such as 352x288) and a file-size (such as 300KB), I have > to generate images using PIL of the following formats: > [ jpeg, gif, wbmp, bmp, png, tiff ]. > I have achieved the first part, that is I can, starting > from a jpg image, generate all the other types with any > resolution (by resizing and using PIL's Image.save). But > I have no control over file size. > To do that I found that there's a variant of the Image.save > method that takes in a third parameter: > Image.save( filename, format, options ). > The PIL manual says that > "Keyword options can be used to provide additional > instructions to the writer. If a writer doesn't recognise > an option, it is silently ignored. The available options > are described later in this handbook." > Could someone please tell me what these options are ? > I seem to be unable to find the 'options' in the manual. > If it is not there, could someone tell me, > > 1] What i need to do to reduce the size of the tiff files > I generate, what options I need to add to the call > Image.save('a.tiff') . > > 2] Same for bmp files. > > That's a lot of queries for the first post! Please help! > > Thanks. > Rajorshi > > > > > > -- ----------------------------------- Rajorshi Biswas Trainee, Alumnus Software Ltd. INFINITY, Tower II, 2nd Floor. Plot - A3, Block - GP, Sector V Salt Lake City, Kolkata 700 091 West Bengal, India Phone : +91 33 2357 5626/27/28 Extension : 357/355 Alternate : rajorshi@fastmail.fm Website : http://www.rajorshi.tk ----------------------------------- From William.T.Bridgman.1 at gsfc.nasa.gov Thu Jul 22 16:02:22 2004 From: William.T.Bridgman.1 at gsfc.nasa.gov (W.T. Bridgman) Date: Thu Jul 22 16:02:28 2004 Subject: [Image-SIG] drawing antialised text In-Reply-To: <1089407756.6761.24.camel@codefabrik> References: <1089407756.6761.24.camel@codefabrik> Message-ID: If you define the image as RGBA with (0,0,0,255) and then call draw.text with fill=(255,255,255,0) for white text with no transparency, you can do simple compositing. Is that what you're looking for? I'm having antialiasing problems as well with this setup. Tom On Jul 9, 2004, at 5:15 PM, Bj?rn Platzen wrote: > Hello List, > > I'm trying to draw some antialiased Text on an 8-bit PNG with > alphatransparency. But my text always looks horrible. It looks kind of > distorted. > > As a workaround, I initialized a new RGB Image, pasted my PNG and wrote > my text. After that, I converted the new image to mode "P". Everything > worked fine and my text looked ok. > > But now, I need the produced image with a transparent background. Is > there any way to write the text directly into my PNG so that it is > nicely rendered and antialiased? > Another approach would be to make the background of the RGB image > transparent. But I don't have any idea how to get this working... > > > I'm workin with PIL 1.15a3 on a Linux-Machine. The server has only PIL > 1.14, so solutions should work under 1.14 as well... > > Thanks in advance, > > Bjoern. > > > _______________________________________________ > Image-SIG maillist - Image-SIG@python.org > http://mail.python.org/mailman/listinfo/image-sig > > -- *********************************************************************** **** NOTE NEW EMAIL ADDRESS AS THE WYETH ADDRESS WILL GO AWAY SOON **** *********************************************************************** Dr. William T."Tom" Bridgman Scientific Visualization Studio Global Science & Technology, Inc. NASA/Goddard Space Flight Center Email: William.T.Bridgman.1@gsfc.nasa.gov Code 935 Phone: 301-286-1346 Greenbelt, MD 20771 FAX: TBD http://svs.gsfc.nasa.gov/ From gus at clacso.edu.ar Thu Jul 29 23:42:47 2004 From: gus at clacso.edu.ar (gus) Date: Thu Jul 29 23:38:26 2004 Subject: [Image-SIG] Hi from Argentina Message-ID: <41096F57.6030000@clacso.edu.ar> > Hi > I had installed PIL (Python Image Library) > But I have an error when build whith > python setup.py build > > the error said > > running build > running build_py > running build_ext > building 'imagingtk' extension > gcc -pthread -fno-strict-aliasing _DNDDEBUG -g -03 -Wall > ................../temp.linux-i686-2.3/Tk/TkImaging.o > Tk/Tkimaging.c:49: tk.h: No such file or directory > error: command 'gcc' failed with exit status 1 > > > Anyone could help me...? > regards > Gus From rjkimble at alum.mit.edu Fri Jul 30 02:03:59 2004 From: rjkimble at alum.mit.edu (Bob Kimble) Date: Fri Jul 30 02:04:12 2004 Subject: [Image-SIG] Hi from Argentina In-Reply-To: <41096F57.6030000@clacso.edu.ar> References: <41096F57.6030000@clacso.edu.ar> Message-ID: <200407292003.59374.rjkimble@alum.mit.edu> On Thursday 29 July 2004 05:42 pm, gus wrote: > > Hi > > I had installed PIL (Python Image Library) > > But I have an error when build whith > > python setup.py build > > > > the error said > > > > running build > > running build_py > > running build_ext > > building 'imagingtk' extension > > gcc -pthread -fno-strict-aliasing _DNDDEBUG -g -03 -Wall > > ................../temp.linux-i686-2.3/Tk/TkImaging.o > > Tk/Tkimaging.c:49: tk.h: No such file or directory > > error: command 'gcc' failed with exit status 1 Looks to me that you don't have the tk development files installed. On my machines they come from the following packages: Debian: tk8.4-dev SuSE: tk-devel Mandrake: tk > > Anyone could help me...? > > regards > > Gus > > _______________________________________________ > Image-SIG maillist - Image-SIG@python.org > http://mail.python.org/mailman/listinfo/image-sig From colliera at ukzn.ac.za Thu Jul 8 17:59:14 2004 From: colliera at ukzn.ac.za (colliera@ukzn.ac.za) Date: Mon Aug 2 12:41:28 2004 Subject: [Image-SIG] gimp-2.0 palette Message-ID: <20040708155905.GA5387@adelie> hello, has anyone tried to import gimp-2 palettes using the GimpPaletteFile module? presently this does not seem to work because the old palette files began something like this: GIMP Palette 0 0 0 grey0 60 0 80 60 0 80 60 0 84 64 0 84 while the new ones have a couple of extra lines: GIMP Palette Name: Royal # 0 0 0 grey0 60 0 80 Untitled 60 0 80 Untitled 60 0 84 Untitled 64 0 84 Untitled i don't imagine that it would be too difficult to cater for both? best regards, andrew. -- Andrew B. Collier Antarctic Research Fellow tel: +27 31 2601157 Space Physics Research Institute fax: +27 31 2616550 University of KwaZulu-Natal, Durban, 4041, South Africa From gab at hg-lab.net Sat Jul 17 20:55:52 2004 From: gab at hg-lab.net (>>>Gabriele Tazzari) Date: Mon Aug 2 12:42:01 2004 Subject: [Image-SIG] Problems with PIL1.1.4 using Py2exe Message-ID: <000801c46c2f$aad6e7d0$2ec3d00a@yoox.net> Hi, I'm trying to compile and transform an application that uses the PIL 1.1.4 and transform it in an exe file using py2exe. This is the python code: import os,shutil,Image a=Image.open("test.jpg") b=a.resize((150,80),Image.ANTIALIAS) b.save("d:/test_script.jpg") a=None b=None And this is the setup script: # setup.py from distutils.core import setup import py2exe setup(name="testpil.py",scripts=["testpil.py"],) and of course the script is called in this way: setup.py py2exe Can you please tell me why the script runs and the exe doesn't ? The error I get with the exe is Traceback (most recent call last): File "", line 2, in ? File "Image.pyo", line 1571, in open IOError: cannot identify image file It can't open the image file... Can you advise please? Thanks Gabriele Tazzari -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/image-sig/attachments/20040717/e30df8c1/attachment.htm From Padraig.Corcoran at ordnancesurvey.co.uk Mon Jul 12 15:03:53 2004 From: Padraig.Corcoran at ordnancesurvey.co.uk (Padraig Z. Corcoran) Date: Tue Aug 3 09:14:44 2004 Subject: [Image-SIG] convoultion Message-ID: Hi I want to known how to perform convolution using python. thanx a mill This email is only intended for the person to whom it is addressed and may contain confidential information. If you have received this email in error, please notify the sender and delete this email which must not be copied, distributed or disclosed to any other person. Unless stated otherwise, the contents of this email are personal to the writer and do not represent the official view of Ordnance Survey. Nor can any contract be formed on Ordnance Survey's behalf via email. We reserve the right to monitor emails and attachments without prior notice. Thank you for your cooperation. Ordnance Survey Romsey Road Southampton SO16 4GU Tel: 023 8079 2000 http://www.ordnancesurvey.co.uk