From claudyus84 at gmail.com Thu Sep 1 14:59:49 2011 From: claudyus84 at gmail.com (Claudio) Date: Thu, 1 Sep 2011 14:59:49 +0200 Subject: [Image-SIG] Implement sobel filter In-Reply-To: References: Message-ID: 2011/8/31 Guilherme Polo : > > Now I see that I'm very naive with PIL, I don't know how to achieve > exactly the same result using only PIL. Hello Guilherme, thanks for your help. I appreciate your implementation using scipy and I also implement a "discrete" version using raw data from load method. Googling a bit I found a gaussian filter http://rcjp.wordpress.com/2008/04/02/gaussian-pil-image-filter/ implemented using a matrix and ereditate function from ImageFilter class. Now probabily this is another way to apply a matrix to each point of an image in PIL but there are difference between that way and my initial implementation with ImageFilter.Kernel: ximg = img.filter(ImageFilter.Kernel((3,3), dx, None, 0)) There is some PIL developer that can answer my question here? -- Claudio pub?? 1024D/0DFD7CBB C94D 759A 2EF0 172F 9673 65E4 C4C1 8627 0DFD 7CBB From ingo at quitch.net Fri Sep 2 09:33:26 2011 From: ingo at quitch.net (Ingo Randolf) Date: Fri, 2 Sep 2011 09:33:26 +0200 Subject: [Image-SIG] float rgba list -> Image In-Reply-To: <4E5E82AC.1070905@noaa.gov> References: <7E664690-E32D-4D3A-9FAB-E9DD3B6B9A00@quitch.net> <4E5E60F6.3020902@uci.edu> <4E5E82AC.1070905@noaa.gov> Message-ID: Hello. Thanks for all the answers... i get the RGBA-list from within blender... loading an image or movie is stored in blender in this format and is accessible via python... my idea (still) is to have a bridge from blender image-representation to PIL. this would enable to make image-transformations from within blender... the problem i have right now, is that i want to align all the images in a movie in a taxture-atlas... i think this could be done easily with PIL... it seems reading pixel-values is very slow in blender though... right now i have troubles getting numpy working in blenders bundled python (3.2)... so i could not try this proposal... making tuples out of the list (either with or without value-scaling) is too slow... ingo Am 31.08.2011 um 20:51 schrieb Chris.Barker: > On 8/31/11 9:27 AM, Christoph Gohlke wrote: >> On 8/31/2011 7:21 AM, Ingo Randolf wrote: >>> I have a list with float-values describing an image like this: >>> [R, G, B, A, R, G, B, A, R, G, B, A, R, G, B, A, R, G, B, A, ... etc.] > > I can't help but wonder why it's in that data structure to begin with -- as you've seen, it's a pretty painfully inefficient way to do it. > >>> i played around with putdata... > > you need it in a binary format that is compatible: > >> Consider using numpy and Image.fromarray. > > this is probably the best way, but you can also use an array.array object -- create an array.array of type byte from your list, then pass that in to putdata. (details left as an exercise for the reader) > > I think working with numbers in Python without numpy would be like working with text using lists of characters, rather than the string object. > > -Chris From Chris.Barker at noaa.gov Fri Sep 2 17:55:58 2011 From: Chris.Barker at noaa.gov (Chris.Barker) Date: Fri, 02 Sep 2011 08:55:58 -0700 Subject: [Image-SIG] float rgba list -> Image In-Reply-To: References: <7E664690-E32D-4D3A-9FAB-E9DD3B6B9A00@quitch.net> <4E5E60F6.3020902@uci.edu> <4E5E82AC.1070905@noaa.gov> Message-ID: <4E60FC8E.20303@noaa.gov> On 9/2/11 12:33 AM, Ingo Randolf wrote: > i get the RGBA-list from within blender... ouch! I'm still amazed when folks write wrappers that use lists of numbers for large arrays of data -- it's simple NOT the way to go -- painfully slow and memory inefficient. This is what the PEP 3118 buffer protocol is for -- I know it's new, but I sure wish folks would use it. Does Blender not provide a way to get some sort of efficient image object? in this case, you may even get better performance writing an image to file, and reading it back in with PIL. > right now i have troubles getting numpy working in blenders bundled python (3.2)... so i could not try this proposal... what was the problem? a simple "setup.py install" should work fine. > making tuples out of the list (either with or without value-scaling) is too slow... did you try making an array.array object? That's in the stdlib at least, though the scaling will be slower than numpy -Chris > > ingo > > > > > Am 31.08.2011 um 20:51 schrieb Chris.Barker: > >> On 8/31/11 9:27 AM, Christoph Gohlke wrote: >>> On 8/31/2011 7:21 AM, Ingo Randolf wrote: >>>> I have a list with float-values describing an image like this: >>>> [R, G, B, A, R, G, B, A, R, G, B, A, R, G, B, A, R, G, B, A, ... etc.] >> >> I can't help but wonder why it's in that data structure to begin with -- as you've seen, it's a pretty painfully inefficient way to do it. >> >>>> i played around with putdata... >> >> you need it in a binary format that is compatible: >> >>> Consider using numpy and Image.fromarray. >> >> this is probably the best way, but you can also use an array.array object -- create an array.array of type byte from your list, then pass that in to putdata. (details left as an exercise for the reader) >> >> I think working with numbers in Python without numpy would be like working with text using lists of characters, rather than the string object. >> >> -Chris > > _______________________________________________ > Image-SIG maillist - Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/OR&R (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception Chris.Barker at noaa.gov From mailanupamk at gmail.com Wed Sep 7 05:08:58 2011 From: mailanupamk at gmail.com (Anupam Kumar) Date: Tue, 6 Sep 2011 23:08:58 -0400 Subject: [Image-SIG] Regarding Python Imaging Library Message-ID: Hello Sir, Greetings, I was trying to install the python imaging library on my Mac OS X with Python 2.7. Can you send me the download and installation instructions for PIL? Thanks, With Regards, -- Anupam Kumar Grade 11 Nest+m High school New York -------------- next part -------------- An HTML attachment was scrubbed... URL: From Chris.Barker at noaa.gov Wed Sep 7 23:34:06 2011 From: Chris.Barker at noaa.gov (Chris.Barker) Date: Wed, 07 Sep 2011 14:34:06 -0700 Subject: [Image-SIG] Regarding Python Imaging Library In-Reply-To: References: Message-ID: <4E67E34E.3020009@noaa.gov> On 9/6/11 8:08 PM, Anupam Kumar wrote: > I was trying to install the python imaging library on my Mac OS X with > Python 2.7. Can you send me the download and installation instructions > for PIL? your best bet is the "unofficial" binary here: http://www.astro.washington.edu/users/rowen/python/ for python2.7, you want: PIL-1.1.7-python.org-32bit-py2.7-macosx10.3.dmg That is the build for the 32 bit PPC+Intel build of python from python.org. Unless you really need 64 bit, that's the one I recommend. -Chris > > Thanks, > > With Regards, > > -- > Anupam Kumar > Grade 11 > Nest+m High school > New York > > > > > > _______________________________________________ > Image-SIG maillist - Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/OR&R (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception Chris.Barker at noaa.gov From mankoff at gmail.com Fri Sep 9 18:17:47 2011 From: mankoff at gmail.com (Ken Mankoff) Date: Fri, 9 Sep 2011 12:17:47 -0400 (EDT) Subject: [Image-SIG] PIL and 16-bit images bug Message-ID: Hi, I know there is no official PIL support, but the site does suggest posting bug reports here. I think I have found two, both related to 16 bit images, one TIF and one PGM. It seems there is support for 8 bit and 32 bit, but not 16 bit images. Some more details here: http://stackoverflow.com/questions/7363735/python-and-16-bit-pgm http://stackoverflow.com/questions/7247371/python-and-16-bit-tiff It seems I should read with mode of "L;16" but "L" is hardcoded into File.c with PGM. I presume something similar with TIF file read. Cheers, -k. From rowen at uw.edu Mon Sep 12 19:17:54 2011 From: rowen at uw.edu (Russell E. Owen) Date: Mon, 12 Sep 2011 10:17:54 -0700 Subject: [Image-SIG] Regarding Python Imaging Library References: Message-ID: In article , Anupam Kumar wrote: > Hello Sir, > > Greetings, > > I was trying to install the python imaging library on my Mac OS X with > Python 2.7. Can you send me the download and installation instructions for > PIL? > > Thanks, > > With Regards, There is an unofficial binary installer here: it requires the 32-bit version of Python from python.org -- Russell From Craig.Coleman at ordnancesurvey.co.uk Thu Sep 8 13:07:47 2011 From: Craig.Coleman at ordnancesurvey.co.uk (Craig Coleman (C)) Date: Thu, 8 Sep 2011 12:07:47 +0100 Subject: [Image-SIG] What is the best way to anti-alias a very large resolution image in PIL Message-ID: Hi, I have a really thorny problem. I need to downsample a raster map that is 23622x23622 pixels to 7874x7874 pixels using the ANTIALIAS filter. I have the following Python code: >>> import Image >>> img = Image.open(r"C:\temp\24bit_nd.tif") >>> nimg = img.resize((7874,7874),Image.ANTIALIAS) As soon as the resize method is called, python crashes instantly. I presume this is a memory allocation issue. Is there another way of performing anti-aliasing on such a large image (its 2.7GB uncompressed although I'm using LZW for storage). I have tried converting the file to 8bit with a palette and this successfully downsamples but the ANTIALIAS is not performed. What am I doing wrong? Craig Coleman Technical Lead Information Systems, Ordnance Survey L0F2, Adanac Drive, SOUTHAMPTON, United Kingdom, SO16 0AS Phone: +44 (0) 2380 054641 www.ordnancesurvey.co.uk | craig.coleman at ordnancesurvey.co.uk Please consider your environmental responsibility before printing this email. 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 Adanac Drive Southampton SO16 0AS Tel: 08456 050505 http://www.ordnancesurvey.co.uk -------------- next part -------------- An HTML attachment was scrubbed... URL: From mratzburg at gmail.com Sat Sep 10 21:22:17 2011 From: mratzburg at gmail.com (Mark D. Ratzburg) Date: Sat, 10 Sep 2011 14:22:17 -0500 Subject: [Image-SIG] PIL 1.1.7 for Python 2.7 Windows Message-ID: To whom it may concern, I am currently experiencing trouble with the PIL installer not recognizing my Python install. I am running Python 2.7 on 64-bit Windows 7. The PIL installer reports that it cannot find the Python install. Python is installed from http://www.python.org/ftp/python/2.7.2/python-2.7.2.amd64.msi In the mean time I'll try to install from the source kit. Regards, Mark -------------- next part -------------- An HTML attachment was scrubbed... URL: From cgohlke at uci.edu Tue Sep 13 10:16:14 2011 From: cgohlke at uci.edu (Christoph Gohlke) Date: Tue, 13 Sep 2011 01:16:14 -0700 Subject: [Image-SIG] PIL 1.1.7 for Python 2.7 Windows In-Reply-To: References: Message-ID: <4E6F114E.3010705@uci.edu> On 9/10/2011 12:22 PM, Mark D. Ratzburg wrote: > To whom it may concern, > > I am currently experiencing trouble with the PIL installer not > recognizing my Python install. I am running Python 2.7 on 64-bit Windows > 7. The PIL installer reports that it cannot find the Python install. > > Python is installed from > http://www.python.org/ftp/python/2.7.2/python-2.7.2.amd64.msi > > In the mean time I'll try to install from the source kit. > > Regards, > Mark > Try PIL-1.1.7.win-amd64-py2.7.?exe from . Christoph From mankoff at 3m411.com Tue Sep 13 16:50:34 2011 From: mankoff at 3m411.com (Ken Mankoff) Date: Tue, 13 Sep 2011 16:50:34 +0200 (CEST) Subject: [Image-SIG] What is the best way to anti-alias a very large resolution image in PIL In-Reply-To: References: Message-ID: Newbie to Python here so please excuse dumb suggestions, but... Must you use pure Python and PIL? It seems PyLibTiff was written to solve something like this. https://code.google.com/p/pylibtiff/ Or you could perhaps load the TIFF with numpy which allows you to load just parts of the file, down-sample in segments, then combine. Or just use 3rd party tools (I have used gdal with very large files, though none larger than my RAM). -k. On Thu, 8 Sep 2011, Craig Coleman (C) wrote: > Hi, > > I have a really thorny problem. > > I need to downsample a raster map that is 23622x23622 pixels to > 7874x7874 pixels using the ANTIALIAS filter. > > I have the following Python code: > >>>> import Image >>>> img = Image.open(r"C:\temp\24bit_nd.tif") >>>> nimg = img.resize((7874,7874),Image.ANTIALIAS) > > As soon as the resize method is called, python crashes instantly. > I presume this is a memory allocation issue. > > Is there another way of performing anti-aliasing on such a large > image (its 2.7GB uncompressed although I'm using LZW for storage). > > I have tried converting the file to 8bit with a palette and this > successfully downsamples but the ANTIALIAS is not performed. > What am I doing wrong? > > Craig Coleman > Technical Lead > Information Systems, Ordnance Survey > L0F2, Adanac Drive, SOUTHAMPTON, United Kingdom, SO16 0AS > Phone: +44 (0) 2380 054641 > www.ordnancesurvey.co.uk | > craig.coleman at ordnancesurvey.co.uk > Please consider your environmental responsibility before printing this > email. > > 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 > Adanac Drive > Southampton SO16 0AS > Tel: 08456 050505 > http://www.ordnancesurvey.co.uk > From mankoff at gmail.com Tue Sep 13 16:51:10 2011 From: mankoff at gmail.com (Ken Mankoff) Date: Tue, 13 Sep 2011 16:51:10 +0200 (CEST) Subject: [Image-SIG] What is the best way to anti-alias a very large resolution image in PIL In-Reply-To: References: Message-ID: Newbie to Python here so please excuse dumb suggestions, but... Must you use pure Python and PIL? It seems PyLibTiff was written to solve something like this. https://code.google.com/p/pylibtiff/ Or you could perhaps load the TIFF with numpy which allows you to load just parts of the file, down-sample in segments, then combine. Or just use 3rd party tools (I have used gdal with very large files, though none larger than my RAM). -k. On Thu, 8 Sep 2011, Craig Coleman (C) wrote: > Hi, > > I have a really thorny problem. > > I need to downsample a raster map that is 23622x23622 pixels to > 7874x7874 pixels using the ANTIALIAS filter. > > I have the following Python code: > >>>> import Image >>>> img = Image.open(r"C:\temp\24bit_nd.tif") >>>> nimg = img.resize((7874,7874),Image.ANTIALIAS) > > As soon as the resize method is called, python crashes instantly. I > presume this is a memory allocation issue. > > Is there another way of performing anti-aliasing on such a large image > (its 2.7GB uncompressed although I'm using LZW for storage). > > I have tried converting the file to 8bit with a palette and this > successfully downsamples but the ANTIALIAS is not performed. What am I > doing wrong? > > Craig Coleman > Technical Lead > Information Systems, Ordnance Survey > L0F2, Adanac Drive, SOUTHAMPTON, United Kingdom, SO16 0AS > Phone: +44 (0) 2380 054641 > www.ordnancesurvey.co.uk | > craig.coleman at ordnancesurvey.co.uk > Please consider your environmental responsibility before printing this > email. > > > 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 > Adanac Drive > Southampton SO16 0AS > Tel: 08456 050505 > http://www.ordnancesurvey.co.uk > From charlie.clark at clark-consulting.eu Tue Sep 13 17:58:00 2011 From: charlie.clark at clark-consulting.eu (Charlie Clark) Date: Tue, 13 Sep 2011 17:58:00 +0200 Subject: [Image-SIG] What is the best way to anti-alias a very large resolution image in PIL In-Reply-To: References: Message-ID: Hi Craig, Am 08.09.2011, 13:07 Uhr, schrieb Craig Coleman (C) : > Hi, > I have a really thorny problem. > I need to downsample a raster map that is 23622x23622 pixels to > 7874x7874 pixels using the ANTIALIAS filter. > I have the following Python code: > >>>> import Image >>>> img = Image.open(r"C:\temp\24bit_nd.tif") >>>> nimg = img.resize((7874,7874),Image.ANTIALIAS) > As soon as the resize method is called, python crashes instantly. I > presume this is a memory allocation issue. I think you may be right. Do you have the full traceback the error produces? Is this using a 32-bit version of Python? Do you have access to a 64-bit system? For MS Windows there is a 64-bit PIL installer: http://www.lfd.uci.edu/~gohlke/pythonlibs/#pil > Is there another way of performing anti-aliasing on such a large image > (its 2.7GB uncompressed although I'm using LZW for storage). > I have tried converting the file to 8bit with a palette and this > successfully downsamples but the ANTIALIAS is not performed. What am I > doing wrong? Charlie -- Charlie Clark Managing Director Clark Consulting & Research German Office Helmholtzstr. 20 D?sseldorf D- 40215 Tel: +49-211-600-3657 Mobile: +49-178-782-6226 From chris.mit7 at gmail.com Tue Sep 13 16:15:22 2011 From: chris.mit7 at gmail.com (Chris Mitchell) Date: Tue, 13 Sep 2011 10:15:22 -0400 Subject: [Image-SIG] What is the best way to anti-alias a very large resolution image in PIL In-Reply-To: References: Message-ID: You can load parts of the image, resize+anti-alias those segments then reconstruct the entire image. You'll have some border effects which you can compensate for by using overlapping boundaries and excluding those boundaries in the reconstruction. Some untested code that is a rough approximation: downSample=float(7874/23622) resizeRatio = downSample*3937 #using 3937x3937 for 36 squares img = Image.open(file) newImg = Image.new(mode, (7874,7874), color) for i in xrange(0,23622,3937): for j in xrange(0,23622,3937): imgb = img.crop(i,j,i+3937,i+3937) imgb.resize((resizeRatio,resizeRatio), Image.ANTIALIAS) imgbData = imgb.getdata() newImg.putdata(imgbData,1.0, i) You can shift this and repeat it if you get lines where the squares meet On Thu, Sep 8, 2011 at 7:07 AM, Craig Coleman (C) < Craig.Coleman at ordnancesurvey.co.uk> wrote: > ** > > Hi, > > I have a really thorny problem. > > I need to downsample a raster map that is 23622x23622 pixels to 7874x7874 > pixels using the ANTIALIAS filter. > > I have the following Python code: > > >>> import Image > >>> img = Image.open(r"C:\temp\24bit_nd.tif") > >>> nimg = img.resize((7874,7874),Image.ANTIALIAS) > > As soon as the resize method is called, python crashes instantly. I > presume this is a memory allocation issue. > > Is there another way of performing anti-aliasing on such a large image (its > 2.7GB uncompressed although I'm using LZW for storage). > > I have tried converting the file to 8bit with a palette and this > successfully downsamples but the ANTIALIAS is not performed. What am I > doing wrong? > > *Craig Coleman* > *Technical Lead > Information Systems, Ordnance Survey > L0F2, Adanac Drive, SOUTHAMPTON, United Kingdom, SO16 0AS > Phone: +44 (0) 2380 054641 > **www.ordnancesurvey.co.uk* * | > craig.coleman at ordnancesurvey.co.uk* > *Please consider your environmental responsibility before printing this > email.* > > 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 > Adanac Drive > Southampton SO16 0AS > Tel: 08456 050505http://www.ordnancesurvey.co.uk > > > _______________________________________________ > Image-SIG maillist - Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From andrewwilson at alum.mit.edu Tue Sep 13 18:24:56 2011 From: andrewwilson at alum.mit.edu (Andrew Wilson) Date: Tue, 13 Sep 2011 12:24:56 -0400 Subject: [Image-SIG] What is the best way to anti-alias a very large resolution image in PIL In-Reply-To: References: Message-ID: Hello, I've had similar problems with PIL, you may want to take a look at OpenCV it can open rather large images and resize them. Thanks Andrew On Thu, Sep 8, 2011 at 7:07 AM, Craig Coleman (C) < Craig.Coleman at ordnancesurvey.co.uk> wrote: > ** > > Hi, > > I have a really thorny problem. > > I need to downsample a raster map that is 23622x23622 pixels to 7874x7874 > pixels using the ANTIALIAS filter. > > I have the following Python code: > > >>> import Image > >>> img = Image.open(r"C:\temp\24bit_nd.tif") > >>> nimg = img.resize((7874,7874),Image.ANTIALIAS) > > As soon as the resize method is called, python crashes instantly. I > presume this is a memory allocation issue. > > Is there another way of performing anti-aliasing on such a large image (its > 2.7GB uncompressed although I'm using LZW for storage). > > I have tried converting the file to 8bit with a palette and this > successfully downsamples but the ANTIALIAS is not performed. What am I > doing wrong? > > *Craig Coleman* > *Technical Lead > Information Systems, Ordnance Survey > L0F2, Adanac Drive, SOUTHAMPTON, United Kingdom, SO16 0AS > Phone: +44 (0) 2380 054641 > **www.ordnancesurvey.co.uk* * | > craig.coleman at ordnancesurvey.co.uk* > *Please consider your environmental responsibility before printing this > email.* > > 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 > Adanac Drive > Southampton SO16 0AS > Tel: 08456 050505http://www.ordnancesurvey.co.uk > > > _______________________________________________ > Image-SIG maillist - Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From Craig.Coleman at ordnancesurvey.co.uk Tue Sep 13 18:56:02 2011 From: Craig.Coleman at ordnancesurvey.co.uk (Craig Coleman (C)) Date: Tue, 13 Sep 2011 17:56:02 +0100 Subject: [Image-SIG] What is the best way to anti-alias a very large resolution image in PIL In-Reply-To: References: Message-ID: Hi all, Thanks for all of the response. In the end, I used a combination of GDAL and Image Magick which are fast, reliable, extremely flexible and free. Subsequently, we now use Python to call out GDAL and Image Magick as needed. I changed my process to export to high resolution PDF in order to preserve the quality as PDF is vector-based rather than use a very high resolution TIFF. I use gdal_translate with the --config GDAL_PDF_DPI=400 option to reduce the resolution to 7874 which also performs anti-aliasing on the fly as it happens. After that, I use Image Magick to map the 24-bit raster to an 8-bit raster using a colour palette in another image - GDALs rgc2pct script can do this but it always applies a dodgy Floyd Steinberg ditther which produces horrible results, Image Magick can avoid the dither altogether somehow (clever stuff). Finally, I use gdal_translate again to ensure the GeoTIFF tags are in place. Voila - 8bit, 400dpi tiff is produced. Thanks, Craig Coleman Technical Lead Information Systems, Ordnance Survey L0F2, Adanac Drive, SOUTHAMPTON, United Kingdom, SO16 0AS Phone: +44 (0) 2380 054641 www.ordnancesurvey.co.uk | craig.coleman at ordnancesurvey.co.uk Please consider your environmental responsibility before printing this email. ________________________________ From: andrew.k.wilson at gmail.com [mailto:andrew.k.wilson at gmail.com] On Behalf Of Andrew Wilson Sent: 13 September 2011 17:25 To: Craig Coleman (C) Cc: image-sig at python.org Subject: Re: [Image-SIG] What is the best way to anti-alias a very large resolution image in PIL Hello, I've had similar problems with PIL, you may want to take a look at OpenCV it can open rather large images and resize them. Thanks Andrew On Thu, Sep 8, 2011 at 7:07 AM, Craig Coleman (C) wrote: Hi, I have a really thorny problem. I need to downsample a raster map that is 23622x23622 pixels to 7874x7874 pixels using the ANTIALIAS filter. I have the following Python code: >>> import Image >>> img = Image.open(r"C:\temp\24bit_nd.tif") >>> nimg = img.resize((7874,7874),Image.ANTIALIAS) As soon as the resize method is called, python crashes instantly. I presume this is a memory allocation issue. Is there another way of performing anti-aliasing on such a large image (its 2.7GB uncompressed although I'm using LZW for storage). I have tried converting the file to 8bit with a palette and this successfully downsamples but the ANTIALIAS is not performed. What am I doing wrong? Craig Coleman Technical Lead Information Systems, Ordnance Survey L0F2, Adanac Drive, SOUTHAMPTON, United Kingdom, SO16 0AS Phone: +44 (0) 2380 054641 www.ordnancesurvey.co.uk | craig.coleman at ordnancesurvey.co.uk Please consider your environmental responsibility before printing this email. 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 Adanac Drive Southampton SO16 0AS Tel: 08456 050505 http://www.ordnancesurvey.co.uk _______________________________________________ Image-SIG maillist - Image-SIG at python.org http://mail.python.org/mailman/listinfo/image-sig 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 Adanac Drive Southampton SO16 0AS Tel: 08456 050505 http://www.ordnancesurvey.co.uk -------------- next part -------------- An HTML attachment was scrubbed... URL: From kevin at cazabon.com Tue Sep 13 20:27:16 2011 From: kevin at cazabon.com (Kevin Cazabon) Date: Tue, 13 Sep 2011 14:27:16 -0400 Subject: [Image-SIG] What is the best way to anti-alias a very large resolution image in PIL In-Reply-To: References: Message-ID: <21B4E010-5C40-4272-BBF3-615046CB7710@cazabon.com> If its a memory issue like people have suggested, then it's still possible to do. You could break the image into chunks, resize those, then re-assemble them. The .tile attribute will help you. I've personally worked with files up to about 1.5GB with PIL successfully - even on a 600mHz computer with only 2GB of RAM (back in about 2000), but I'm not sure where the limit actually is, if any. I'm looking for a good code sample to show you how to use the .tile attribute for this, but can't find any yet? the attached is pretty cryptic and horrible coding (from my "early" years :) with little useful documentation. Fredrik really helped me understand it back then, so if you search the newsgroup archives for ".tile" you should probably find something useful. You'd have to do something like: 1) open the image 2) modify the .tile attribute so that you're only working with a portion of the image (that you can handle in memory) 3) resize the image 4) save that portion of the image 5) repeat the above for all sections of the image 6) load them all and paste the resized ones back into one smaller image I'd suggest that you have a bit of overlap in the files though, or you'll have artifacts where you paste them together. This is due to the resampling errors right at the edge of an image. Good luck! Kevin. On Sep 8, 2011, at 7:07 AM, Craig Coleman (C) wrote: > Hi, > > I have a really thorny problem. > > I need to downsample a raster map that is 23622x23622 pixels to 7874x7874 pixels using the ANTIALIAS filter. > > I have the following Python code: > > >>> import Image > >>> img = Image.open(r"C:\temp\24bit_nd.tif") > >>> nimg = img.resize((7874,7874),Image.ANTIALIAS) > > As soon as the resize method is called, python crashes instantly. I presume this is a memory allocation issue. > > Is there another way of performing anti-aliasing on such a large image (its 2.7GB uncompressed although I'm using LZW for storage). > > I have tried converting the file to 8bit with a palette and this successfully downsamples but the ANTIALIAS is not performed. What am I doing wrong? > > Craig Coleman > Technical Lead > Information Systems, Ordnance Survey > L0F2, Adanac Drive, SOUTHAMPTON, United Kingdom, SO16 0AS > Phone: +44 (0) 2380 054641 > www.ordnancesurvey.co.uk | craig.coleman at ordnancesurvey.co.uk > Please consider your environmental responsibility before printing this email. > > 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 > Adanac Drive > Southampton SO16 0AS > Tel: 08456 050505 > http://www.ordnancesurvey.co.uk > > _______________________________________________ > Image-SIG maillist - Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: build_image.py Type: text/x-python-script Size: 3205 bytes Desc: not available URL: -------------- next part -------------- An HTML attachment was scrubbed... URL: From kevin at cazabon.com Tue Sep 13 21:48:40 2011 From: kevin at cazabon.com (Kevin Cazabon) Date: Tue, 13 Sep 2011 15:48:40 -0400 Subject: [Image-SIG] What is the best way to anti-alias a very large resolution image in PIL In-Reply-To: References: Message-ID: <2F28130D-9C61-4979-922E-BE6892B56CD7@cazabon.com> I just found an article that Fredrik wrote based on a discussion we had on memory limits back in 1999. Using the .tile attribute and doing your work in chunks is one sure-fire way of getting there, although it'll take some effort. I hope this helps! http://effbot.org/zone/pil-large-images.htm Kevin. On Sep 8, 2011, at 7:07 AM, Craig Coleman (C) wrote: > Hi, > > I have a really thorny problem. > > I need to downsample a raster map that is 23622x23622 pixels to 7874x7874 pixels using the ANTIALIAS filter. > > I have the following Python code: > > >>> import Image > >>> img = Image.open(r"C:\temp\24bit_nd.tif") > >>> nimg = img.resize((7874,7874),Image.ANTIALIAS) > > As soon as the resize method is called, python crashes instantly. I presume this is a memory allocation issue. > > Is there another way of performing anti-aliasing on such a large image (its 2.7GB uncompressed although I'm using LZW for storage). > > I have tried converting the file to 8bit with a palette and this successfully downsamples but the ANTIALIAS is not performed. What am I doing wrong? > > Craig Coleman > Technical Lead > Information Systems, Ordnance Survey > L0F2, Adanac Drive, SOUTHAMPTON, United Kingdom, SO16 0AS > Phone: +44 (0) 2380 054641 > www.ordnancesurvey.co.uk | craig.coleman at ordnancesurvey.co.uk > Please consider your environmental responsibility before printing this email. > > 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 > Adanac Drive > Southampton SO16 0AS > Tel: 08456 050505 > http://www.ordnancesurvey.co.uk > > _______________________________________________ > Image-SIG maillist - Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig -------------- next part -------------- An HTML attachment was scrubbed... URL: From eguevara2012 at gmail.com Thu Sep 15 01:14:49 2011 From: eguevara2012 at gmail.com (Ernesto Guevara) Date: Wed, 14 Sep 2011 20:14:49 -0300 Subject: [Image-SIG] Bug to save original resized image Message-ID: Hello! I use Django 1.3 and have a signal pre_save() function to save original_image and create your thumbnail. Here is the code: class Photo(models.Model): title = models.CharField(max_length=255) pub_date = models.DateField(auto_now = True) original_image = models.ImageField(upload_to='photos') thumbnail_image = models.ImageField(upload_to="photos/thumbs/") slug_photo = AutoSlugField(populate_from=('title'), unique=True, max_length=255, overwrite=True) def __unicode__(self): return self.title def get_absolute_url(self): return "/imobiliaria/imovel/photo/%s/" % (self.slug_photo) def photo_pre_save(signal, instance, sender, **kwargs): i = instance.original_image THUMBNAIL_SIZE = (128, 128) image = Image.open(i) if image.mode not in ('L', 'RGB'): image = image.convert('RGB') print image.size # size (1007, 1531) basewidth = 200 wpercent = (basewidth/float(image.size[0])) hsize = int((float(image.size[1])*float(wpercent))) original = image.resize((basewidth,hsize), Image.ANTIALIAS) original.save(os.path.split(i.path)[-1], format='jpeg') # why is save with size (1007, 1531)? print original.size # size (200, 304) image.thumbnail(THUMBNAIL_SIZE, Image.ANTIALIAS) # Save the thumbnail temp_handle = StringIO() image.save(temp_handle, 'jpeg') temp_handle.seek(0) # Save to the thumbnail field suf = SimpleUploadedFile(os.path.split(i.name)[-1],temp_handle.read(), content_type='image/jpeg') instance.thumbnail_image.save(suf.name, suf, save=False) signals.pre_save.connect(photo_pre_save, sender=Photo) Here is the problem: print image.size # size (1007, 1531) basewidth = 200 wpercent = (basewidth/float(image.size[0])) hsize = int((float(image.size[1])*float(wpercent))) original = image.resize((basewidth,hsize), Image.ANTIALIAS) original.save(os.path.split(i.path)[-1], format='jpeg') # why is save with size (1007, 1531)? print original.size # size (200, 304) If i upload a 1.3MB image, i want resize to a small size in line: original = image.resize((basewidth,hsize), Image.ANTIALIAS) And then, save this original image size: original.save(os.path.split(i.path)[-1], format='jpeg') But this image still save in uploaded size (1007, 1531) instead (200, 304). is a bug? Thanks! Regards! -------------- next part -------------- An HTML attachment was scrubbed... URL: From isaac at igloomultimedia.com Thu Sep 15 04:45:33 2011 From: isaac at igloomultimedia.com (Isaac Feldman) Date: Wed, 14 Sep 2011 16:45:33 -1000 Subject: [Image-SIG] Help installing PIL Message-ID: <454428CF-C7EB-445D-BC80-CA25F2CBAA4D@igloomultimedia.com> Hi, I am trying to install PIL 1.7.7 on Mac OS X 10.6 running python 2.7.2 I am getting the following error: > $ python setup.py build_ext -i > running build_ext > --- using frameworks at /System/Library/Frameworks > building '_imaging' extension > gcc-4.0 -fno-strict-aliasing -fno-common -dynamic -arch ppc -arch i386 -g -O2 -DNDEBUG -g -O3 -DHAVE_LIBJPEG -DHAVE_LIBZ -I/System/Library/Frameworks/Tcl.framework/Headers -I/System/Library/Frameworks/Tk.framework/Headers -IlibImaging -I/sw/include/freetype2 -I/sw/include -I/Library/Frameworks/Python.framework/Versions/2.7/include -I/usr/local/include -I/usr/include -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c _imaging.c -o build/temp.macosx-10.3-fat-2.7/_imaging.o > unable to execute gcc-4.0: No such file or directory > error: command 'gcc-4.0' failed with exit status 1 I think it is because I don't have Python's build support files "python-dev", "python-devel", or similar. If that sounds like the culprit, can you tell me how I can get those for the Mac? I've looked on the Python.org site but don't see any mention of those files. Thanks, Isaac igloo multimedia simple by design isaac at igloomultimedia.com http://igloomultimedia.com From johnson at pharmacy.arizona.edu Sat Sep 17 00:23:45 2011 From: johnson at pharmacy.arizona.edu (Bruce Johnson) Date: Fri, 16 Sep 2011 15:23:45 -0700 Subject: [Image-SIG] Help installing PIL In-Reply-To: <454428CF-C7EB-445D-BC80-CA25F2CBAA4D@igloomultimedia.com> References: <454428CF-C7EB-445D-BC80-CA25F2CBAA4D@igloomultimedia.com> Message-ID: On Sep 14, 2011, at 7:45 PM, Isaac Feldman wrote: > Hi, > > I am trying to install PIL 1.7.7 on Mac OS X 10.6 running python 2.7.2 > > I am getting the following error: > >> $ python setup.py build_ext -i >> running build_ext >> --- using frameworks at /System/Library/Frameworks >> building '_imaging' extension >> gcc-4.0 -fno-strict-aliasing -fno-common -dynamic -arch ppc -arch i386 -g -O2 -DNDEBUG -g -O3 -DHAVE_LIBJPEG -DHAVE_LIBZ -I/System/Library/Frameworks/Tcl.framework/Headers -I/System/Library/Frameworks/Tk.framework/Headers -IlibImaging -I/sw/include/freetype2 -I/sw/include -I/Library/Frameworks/Python.framework/Versions/2.7/include -I/usr/local/include -I/usr/include -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c _imaging.c -o build/temp.macosx-10.3-fat-2.7/_imaging.o >> unable to execute gcc-4.0: No such file or directory >> error: command 'gcc-4.0' failed with exit status 1 > > I think it is because I don't have Python's build support files "python-dev", "python-devel", or similar. No, it's because you don't have gcc-4.0 or at least don't have it on your $PATH. You need to have Apple's Developer Tools installed or build up a dev environment with MacPorts to do this. It's simplest to just install Apples dev tools: (note, you do NOT need the $99 Mac Developer Program to download the dev tools. You DO need to pay the $99 if you want to put your apps on the App Store.) -- Bruce Johnson University of Arizona College of Pharmacy Information Technology Group Institutions do not have opinions, merely customs From Chris.Barker at noaa.gov Sat Sep 17 09:31:01 2011 From: Chris.Barker at noaa.gov (Chris Barker) Date: Sat, 17 Sep 2011 00:31:01 -0700 Subject: [Image-SIG] Help installing PIL In-Reply-To: References: <454428CF-C7EB-445D-BC80-CA25F2CBAA4D@igloomultimedia.com> Message-ID: <4E744CB5.2090909@noaa.gov> On 9/16/11 3:23 PM, Bruce Johnson wrote: > On Sep 14, 2011, at 7:45 PM, Isaac Feldman wrote: >> I am trying to install PIL 1.7.7 on Mac OS X 10.6 running python 2.7.2 > No, it's because you don't have gcc-4.0 or at least don't have it on your $PATH. > > You need to have Apple's Developer Tools installed or build up a dev environment with MacPorts to do this. > > It's simplest to just install Apples dev tools: > > Correct, though PIL requires some dependencies as well, so it's not that simple. What is simple is to use Russel Owen's "unofficial" binaries: http://www.astro.washington.edu/users/rowen/python/ for python2.7, you want: PIL-1.1.7-python.org-32bit-py2.7-macosx10.3.dmg That is the build for the 32 bit PPC+Intel build of python from python.org. Unless you really need 64 bit, that's the one I recommend. -Chris -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/OR&R (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception Chris.Barker at noaa.gov From charlie.clark at clark-consulting.eu Sat Sep 17 13:41:56 2011 From: charlie.clark at clark-consulting.eu (Charlie Clark) Date: Sat, 17 Sep 2011 13:41:56 +0200 Subject: [Image-SIG] Help installing PIL In-Reply-To: <4E744CB5.2090909@noaa.gov> References: <454428CF-C7EB-445D-BC80-CA25F2CBAA4D@igloomultimedia.com> <4E744CB5.2090909@noaa.gov> Message-ID: Am 17.09.2011, 09:31 Uhr, schrieb Chris Barker : > That is the build for the 32 bit PPC+Intel build of python from > python.org. Unless you really need 64 bit, that's the one I recommend. Alternatively, if you install MacPorts installing binary packages are as easy as: sudo port install py27-pil or, even better once you have virtualenv installed: virtualenv-2.7 --no-site-packages mypythonfolder cd mypythonfolder bin/pip install pillow For most Python users I'd suggest MacPorts is the way to go because it handles necessary libraries and allows for uninstalling. Caveat is that from Snow Leopard on the builds are generally x86_64 only. Charlie -- Charlie Clark Managing Director Clark Consulting & Research German Office Helmholtzstr. 20 D?sseldorf D- 40215 Tel: +49-211-600-3657 Mobile: +49-178-782-6226 From aclark at aclark.net Thu Sep 22 00:37:51 2011 From: aclark at aclark.net (Alex Clark) Date: Wed, 21 Sep 2011 18:37:51 -0400 Subject: [Image-SIG] PIL 1.1.7 PNG bug? Message-ID: Hi, Can anyone comment on the following with any intelligence? - https://github.com/collective/Pillow/issues/10 As Pillow is primarily a packaging fork, I don't really want to go changing the image code ;-). But, if it looks like a reasonable fix I may consider it. Thanks, Alex -- Alex Clark ? http://aclark.net From charlie.clark at clark-consulting.eu Thu Sep 22 10:39:21 2011 From: charlie.clark at clark-consulting.eu (Charlie Clark) Date: Thu, 22 Sep 2011 10:39:21 +0200 Subject: [Image-SIG] PIL 1.1.7 PNG bug? In-Reply-To: References: Message-ID: Hi Alex, Am 22.09.2011, 00:37 Uhr, schrieb Alex Clark : > Hi, > Can anyone comment on the following with any intelligence? > - https://github.com/collective/Pillow/issues/10 > As Pillow is primarily a packaging fork, I don't really want to go > changing the image code ;-). But, if it looks like a reasonable fix I > may consider it. I'd suggest that the issue be extended to include a test file and result and tested against PIL 1.1.7. As a happy user of Pillow I wouldn't like it to see it gain any internal patches. Charlie -- Charlie Clark Managing Director Clark Consulting & Research German Office Helmholtzstr. 20 D?sseldorf D- 40215 Tel: +49-211-600-3657 Mobile: +49-178-782-6226 From aclark at aclark.net Thu Sep 22 14:20:56 2011 From: aclark at aclark.net (Alex Clark) Date: Thu, 22 Sep 2011 08:20:56 -0400 Subject: [Image-SIG] PIL 1.1.7 PNG bug? In-Reply-To: References: Message-ID: On 9/22/11 4:39 AM, Charlie Clark wrote: > Hi Alex, > > Am 22.09.2011, 00:37 Uhr, schrieb Alex Clark : > >> Hi, >> Can anyone comment on the following with any intelligence? >> - https://github.com/collective/Pillow/issues/10 >> As Pillow is primarily a packaging fork, I don't really want to go >> changing the image code ;-). But, if it looks like a reasonable fix I >> may consider it. > > I'd suggest that the issue be extended to include a test file and result > and tested against PIL 1.1.7. As a happy user of Pillow I wouldn't like > it to see it gain any internal patches. Right, in other words if I understand you correctly any internal patches should only be applied if they directly correspond to previous or upcoming changes in PIL itself. Even then, the preferred approach would be to bulk-import the next PIL release into Pillow (and replace the 1.1.7 release code). So, this issue should be filed against PIL where we can track it appropriately (whether that means we wait for a new PIL release then re-package it, or cherry pick and include specific things we know will be in the next PIL release would depend on the circumstances.) (IIRC there may have be one other fix like this, I'll dig back through and check.) Alex > > Charlie -- Alex Clark ? http://aclark.net From charlie.clark at clark-consulting.eu Thu Sep 22 14:45:10 2011 From: charlie.clark at clark-consulting.eu (Charlie Clark) Date: Thu, 22 Sep 2011 14:45:10 +0200 Subject: [Image-SIG] PIL 1.1.7 PNG bug? In-Reply-To: References: Message-ID: Am 22.09.2011, 14:20 Uhr, schrieb Alex Clark : > Right, in other words if I understand you correctly any internal patches > should only be applied if they directly correspond to previous or > upcoming changes in PIL itself. Even then, the preferred approach would > be to bulk-import the next PIL release into Pillow (and replace the > 1.1.7 release code). Personally, I would like to see *no* internal changes in Pillow. It should just be the pip/easy_install compatible form of PIL, hopefully folded back in when distutils2 rules the waves. > So, this issue should be filed against PIL where we can track it > appropriately (whether that means we wait for a new PIL release then > re-package it, or cherry pick and include specific things we know will > be in the next PIL release would depend on the circumstances.) The bug preferably with tests and patch should be passed upstream and if necessary another release of PIL cut. That would fit my definition of playing nicely with Fredrik's hard work. BTW. Could you update the docs of Pillow to point to MacPorts or Brew as well as Fink for managing the required libraries? And it would be nice if we could get Pillow to hook up to the Windows binaries if possible. Charlie -- Charlie Clark Managing Director Clark Consulting & Research German Office Helmholtzstr. 20 D?sseldorf D- 40215 Tel: +49-211-600-3657 Mobile: +49-178-782-6226 From aclark at aclark.net Thu Sep 22 15:35:24 2011 From: aclark at aclark.net (Alex Clark) Date: Thu, 22 Sep 2011 09:35:24 -0400 Subject: [Image-SIG] PIL 1.1.7 PNG bug? In-Reply-To: References: Message-ID: On 9/22/11 8:45 AM, Charlie Clark wrote: > Am 22.09.2011, 14:20 Uhr, schrieb Alex Clark : > >> Right, in other words if I understand you correctly any internal >> patches should only be applied if they directly correspond to previous >> or upcoming changes in PIL itself. Even then, the preferred approach >> would be to bulk-import the next PIL release into Pillow (and replace >> the 1.1.7 release code). > > Personally, I would like to see *no* internal changes in Pillow. It > should just be the pip/easy_install compatible form of PIL, hopefully > folded back in when distutils2 rules the waves. Roger that. > >> So, this issue should be filed against PIL where we can track it >> appropriately (whether that means we wait for a new PIL release then >> re-package it, or cherry pick and include specific things we know will >> be in the next PIL release would depend on the circumstances.) > > The bug preferably with tests and patch should be passed upstream and if > necessary another release of PIL cut. That would fit my definition of > playing nicely with Fredrik's hard work. I have no problem with, and I am interested in passing bugs upstream. And indeed Pillow aims to be the "friendly" PIL fork :-). My concern (in this case) lies with the release cycle. If I can get a fix into Pillow and release it to PyPI within 24 hours, then I am strongly tempted to do so. However, I certainly don't want to be irresponsible or disrespectful. So if I did do this, I'd probably try to have a "good" explanation (something along the lines of "this is going into PIL 1.1.8 anyway"). Another issue I just remembered: one of the things I'm tempted to do with Pillow is research Python 3 compatibility. I suspect with the "freedom" of the fork we might be able to produce some beta Pillow releases that work on Python 3 (after doing all the hard work, of course). This development would also be available to go upstream into PIL as needed or desired. > > BTW. Could you update the docs of Pillow to point to MacPorts or Brew as > well as Fink for managing the required libraries? I have a ticket for this but haven't had a chance to work on it yet: - https://github.com/collective/Pillow/issues/1 If anyone on this list has any direct and/or current experience with MacPorts or Fink please feel free to send a pull request. I have used all three and I currently use Brew, but I'm not sure what the instructions for Brew would look like because I never use it to install Pillow. And it would be nice > if we could get Pillow to hook up to the Windows binaries if possible. The latest Pillow has a Windows binaries volunteer, if that helps. You can download various win32 binaries for py2.4-py2.7 here: - http://pypi.python.org/pypi/Pillow/1.7.5 Alex > > Charlie -- Alex Clark ? http://aclark.net From czarkoff at gmail.com Thu Sep 22 13:39:44 2011 From: czarkoff at gmail.com (Dmitrij D. Czarkoff) Date: Thu, 22 Sep 2011 13:39:44 +0200 Subject: [Image-SIG] Is the development source tree available? Message-ID: <20110922113944.GA20417@ao531h.bedova> Hello, everybody! I failed to find any notice about the location of development tree of PIL. Can anyone point me to a file archieve (or even better a repository) with the latest development version of the library? Thanks in advance and sorry if I missed something evident. -- Dmitrij D. Czarkoff From patrick.surry at gmail.com Thu Sep 22 20:10:26 2011 From: patrick.surry at gmail.com (Patrick Surry) Date: Thu, 22 Sep 2011 14:10:26 -0400 Subject: [Image-SIG] Image.blend() loses brightness Message-ID: Image.blend() tends to lose half a unit of brightness (on a scale of 0-255) wherever the two input images differ. I noticed this while blending a series of greyscale book page images (black background, white text) in a loop, blending the n-th page in to the composite of the previous ones with alpha=1/n ? i.e. first page is taken at full value, then second blended at alpha=1/2, third blended to that result with alpha = 1/3 etc. But this inevitably results in an all-black image. But it should result in a final image where all pages have equal weight. Turns out that there's a roundoff problem in Image.blend(im1,im2,alpha) which calculates (UINT8)(im1 + alpha*(im2-im1)) at each pixel, but since UINT8 acts like floor() the result of the calculation is always rounded down. The right fix is to add half a unit before the floor, i.e. instead calculate (uint8) (im1 + alpha*(im2-im1)+0.5). This has no effect on points where the images match (the 0.5 just gets discarded again), but removes the downward bias when they don?t. You can work around this using a combination of ImageChops.add() and subtract(), remembering that subtract truncates negative values at 0: def blend_unbiased (im1,im2,alpha): # because subtract() truncates at zero, we have to use two steps to include both the positive and negative differences, # essentially calculating: # floor(im + max(0,(im2-im1)*alpha + 0.5) - max(0,(im1-im2)*alpha+0.5)) im=ImageChops.add(im1,ImageChops.subtract(im2,im1,1/alpha,0.5)) im=ImageChops.subtract(im1,ImageChops.subtract(im1,im2,1/alpha,0.5)) return im This ends up with the expected final image after a sequence of merge steps. (This same issue likely applies to other image composition operations) Cheers, Patrick -------------- next part -------------- An HTML attachment was scrubbed... URL: From aclark at aclark.net Wed Sep 28 02:48:24 2011 From: aclark at aclark.net (Alex Clark) Date: Tue, 27 Sep 2011 20:48:24 -0400 Subject: [Image-SIG] Is the development source tree available? In-Reply-To: <20110922113944.GA20417@ao531h.bedova> References: <20110922113944.GA20417@ao531h.bedova> Message-ID: On 9/22/11 7:39 AM, Dmitrij D. Czarkoff wrote: > Hello, everybody! > > I failed to find any notice about the location of development tree of PIL. Can > anyone point me to a file archieve (or even better a repository) with the > latest development version of the library? > > Thanks in advance and sorry if I missed something evident. According to: - http://effbot.org/zone/pil-index.htm It is here: - http://hg.effbot.org/pil-2009-raclette Alex > -- Alex Clark ? http://aclark.net