Re: [Image-SIG] downscaling by area averaging

2005-05-06 Thread Douglas Bagnall
I've added stretched versions to http://halo.gen.nz/pil/examples.html With javascript, clicking on the top image should cycle through the unscaled, area averaged, anti-aliased, and nearest-neighbour-stetched images. + I'm beginning to wonder if there's not an off-by-something error lurking

Re: [Image-SIG] CAPTCHA antibot

2005-05-09 Thread Douglas Bagnall
Lorenzo Bolognini wrote: from PIL import Image, ImageDraw, ImageFont im = Image.new(RGB, (150,70), #fff) draw = ImageDraw.Draw(im, RGB) font = ImageFont.truetype(trebuc.ttf, 30) draw.text((20,20), Hello World!, fill=#ff, font=font) im.save(C:\\pippo.png, PNG) [...] So the question is:

Re: [Image-SIG] Converting to zebra (ZPL) format

2005-06-19 Thread Douglas Bagnall
hi Peter, Thanks for the reply folks. Here is the code I have produced so far... #! /usr/bin/python import sys import string Don't use the string module, use the string type methods: http://python.org/doc/2.3.5/lib/string-methods.html Read the next page too, about string formatting.

Re: [Image-SIG] rotate image with transparent background?

2007-01-17 Thread Douglas Bagnall
, expand = 1) im2.show() Douglas Bagnall ___ Image-SIG maillist - Image-SIG@python.org http://mail.python.org/mailman/listinfo/image-sig

Re: [Image-SIG] rotate image with transparent background?

2007-01-17 Thread Douglas Bagnall
Alec Bennett wrote: Hmm, still getting a black box. The code as it stands now in case anything jumps out at you: # open the pic and give it an alpha channel so it's transparent im1 = Image.open(pic1.jpg) im1.convert('RGBA') That should be im1 = Image.open(pic1.jpg) im1 =

Re: [Image-SIG] rotate image with transparent background?

2007-01-17 Thread Douglas Bagnall
Alec Bennett wrote: collage.paste(im2, (30, 30) ) From http://effbot.org/imagingbook/image.htm#Image.paste : im.paste(image, box, mask) Same as above, but updates only the regions indicated by the mask. You can use either 1, L or RGBA images (in the latter case, the alpha band is used

Re: [Image-SIG] Creating a grayscale ramp

2007-01-22 Thread Douglas Bagnall
Cochran, Travis wrote: I'm trying to use the PIL to create a grayscale ramp, dark to light. I am able to generate an image but it is solid black. Am I using frombuffer wrong? Here is my code. from PIL import Image #Creates the list of codes from 0 to 255 data = range(256) #Creates an

Re: [Image-SIG] Comparison of PIL and GD speed for setting pixels through python

2007-02-04 Thread Douglas Bagnall
hi John, Method Time (s)Times slower than fastest +-+ +---+ ++ ctypes,c,GD raw 0.00082 1.0 ctypes,c,GD 0.00177 2.2 PIL - 'load'0.03226 39.4 ctypes, GD 0.14428 176.4 PIL, numpy *

Re: [Image-SIG] Two PIL based Hill Shading Implementations, using Python Python/C.

2007-02-06 Thread Douglas Bagnall
John Barratt wrote: http://www.langarson.com.au/blog/?p=14 This is an observation, not a recommendation, but you could *almost* do all of this in pure PIL, without explicit loops. You could find the slope like so: dxfilter = ImageFilter((3,3), [1, 0, -1,

Re: [Image-SIG] ImageStat median calculation off?

2007-04-26 Thread Douglas Bagnall
Bill Janssen wrote: I keep getting different values for s.median than I get for h.index(v). Shouldn't they be the same value? Am I missing something? Isn't it *mode* that you are calculating, not median? The median would be calculated by adding up the histogram values until you have

Re: [Image-SIG] Font colour

2007-04-28 Thread Douglas Bagnall
Lad wrote: But I would like to write the text to the lower left bottom, starting 30 pixels from left and 30 from the bottom. So I use textpos=(im.size[0]-30,im.size[1]-30) but it does not work. There si no text written. Can you please tell me why? 30 pixels from the left, with the top

[Image-SIG] crop is a little too lazy (with patch)

2007-09-23 Thread Douglas Bagnall
A cropped image does not return a pixel access object when load()ed. This seems to be a simple oversight. im = Image.new('L',(50,50)) im.load() PixelAccess object at 0xb7d900f0 im2 = im.crop((0, 0, 20, 20)) im2.load() None There is an easy workaround: im2.im.pixel_access()

Re: [Image-SIG] Remove noise from high ISO photos

2007-12-19 Thread Douglas Bagnall
Daniel Felix Ferber wrote: When taking a photo with high ISO on a digital camera, there will be many pixels that have a random color that is completely different color from the expected one. But the photo still has a good sharpness ImageMagic uses a stategy that is similar to the median

Re: [Image-SIG] less disk IO

2008-01-02 Thread Douglas Bagnall
Carl Karsten wrote: I am trying to convert a pdf (data in string, not disk file) to a png. This will be run in a django view on a server (PyCon's even) so it would be good if it didn't hit the disk as much. Shouldn't I be able to use .tostring if I can use .save? use cStringIO.

Re: [Image-SIG] Poor Image Quality When Resizing a GIF

2008-01-09 Thread douglas bagnall
hi Andy Here's the resized gif with the original code I pasted. You'll see a bunch of 'dots' throughout the image: http://www.andymccurdy.com/resized_1.gif PIL uses the so-called web palette by default. Your image uses #fdfdfd for white, but the web palette uses #ff. So it dithers to

Re: [Image-SIG] Poor Image Quality When Resizing a GIF

2008-01-09 Thread douglas bagnall
Andy McCurdy [EMAIL PROTECTED] wrote: I interpreted your response as a setting to change to make this specific image resize better. I'm using PIL to resize images that users upload to my website. Since I don't have control over the media, I need generic settings that will be good for all

Re: [Image-SIG] RMS difference patch

2008-01-16 Thread Douglas Bagnall
I wrote: 2 ** (31-20) ** 0.5 9.9633077752473778 A pixel difference of 10 across the 1 megapixel image will wrap the sum and crash. But now I've read it and it looks like it should have been (2 ** (31-20)) ** 0.5 45.254833995939045 So, not so bad, but nonetheless a problem. douglas

Re: [Image-SIG] matlab vs Python for Image Processing applications

2008-02-11 Thread Douglas Bagnall
TAN TH wrote: import Image im = Image.open(D:/test.gif) print im.format, im.size, im.mode GIF (409, 460) P The P is telling you that the image is in palette mode (as all gifs are), but here you are assuming it is RGB mode: r, g, b = im.split() What you really want is r, g, b =

Re: [Image-SIG] Filtering out all but black pixels for OCR

2008-07-04 Thread Douglas Bagnall
Karsten Hiddemann schrieb: Fredrik has written something about the performance on pixel access with some timings here: http://effbot.org/zone/pil-pixel-access.htm As that page also mentions, PIL images have the point method for doing this kind of thing. see

Re: [Image-SIG] remove an image background using PIL

2009-05-31 Thread Douglas Bagnall
Peter Yen colorp...@gmail.com wrote: Thanks for your quick response. The background is unknown at the time of processing. Actually I don't need a very accurate methodology to remove all background, removing partially is good enough. I once wrote a (GPL'd) C module that fairly reliably

Re: [Image-SIG] Lanczos interpolation

2009-06-02 Thread Douglas Bagnall
If you want the downsampling algorithm used by the Gimp and (I think) Photoshop, try: def stretch(im, size, filter=Image.NEAREST): im.load() im = im._new(im.im.stretch(size, filter)) return im In 2005 I found it to be a few times quicker than ANTIALIAS resizing, and the results were