Re: [Image-SIG] Help for to do a script

2012-03-27 Thread Alec Bennett
There's a lot wrong with it. I don't have the modules so I can't test, but you need to chnage these two lines: if (data[0][i][j] > 199.5 and (data[0][i][j] < 200.5 count = count + 1; To something like: if data[0][i][j] > 199.5 and data[0][i][j] < 20

Re: [Image-SIG] memoryError in FpxImageUploadPlugin.py

2011-04-17 Thread Alec Bennett
Agreed in a web form situation it seems reasonable to expect the file to have the correct file extension. And in fact that's the usual safeguard against people uploading php scripts or whatever containing malicious code. But if you really want to be able to detect file type independently of the

Re: [Image-SIG] memoryError in FpxImageUploadPlugin.py

2011-04-16 Thread Alec Bennett
> i only care about JPG/PNG/GIF... > is there any way do a fileformat-whitelist? Seems almost too obvious to mention, but you could do something like: fname = "something.jpg" image_extensions = (".jpg", ".png", ".gif") extension = os.path.splitext(fname)[1].lower() if extension in image_extens

[Image-SIG] Creating images with layers editable by Photoshop?

2011-03-02 Thread Alec Bennett
I'm trying to create a collage of a few images, and have the images appear as different layers in Photoshop. Is such a thing possible with the PIL? ___ Image-SIG maillist - Image-SIG@python.org http://mail.python.org/mailman/listinfo/image-sig

Re: [Image-SIG] Locate The Center of WhiteDot from a Image

2011-01-11 Thread Alec Bennett
I need to do this too. Could you possibly keep the list updated with your findings? On Fri, Jan 7, 2011 at 8:26 PM, Narendra Sisodiya < naren...@narendrasisodiya.com> wrote: > > > On Sat, Jan 8, 2011 at 1:44 AM, Christopher Barker > wrote: > >> On 1/7/11 10:14 AM, Narendra Sisodiya wrote: >> >

Re: [Image-SIG] how extract/read text from image files

2010-10-28 Thread Alec Bennett
Wow, thanks for posting that, works very very well. ___ Image-SIG maillist - Image-SIG@python.org http://mail.python.org/mailman/listinfo/image-sig

Re: [Image-SIG] that's enough

2010-08-01 Thread Alec Bennett
meant is: bmp = wx.Image("a_4.jpg", wx.BITMAP_TYPE_ANY).ConvertToBitmap() On Sat, Jul 31, 2010 at 7:21 PM, Alec Bennett wrote: > Since Python uses indenting as part of its syntax, I used periods to > symbolize indentation, since otherwise most email readers would scrub out my

Re: [Image-SIG] that's enough

2010-08-01 Thread Alec Bennett
in the "self.mainPic" line. I've no idea what the problem is. > >Regards, >Jack > "Trust me. I have a lot of experience at this." > General Custer's unreme

Re: [Image-SIG] that's enough

2010-07-30 Thread Alec Bennett
You didn't delete the periods that I put in to simulate indentations. On Fri, Jul 30, 2010 at 9:06 AM, donn wrote: > On 30/07/2010 17:48, Jack Uretsky wrote: > >> def__init__(self, parent, id): >> ^ >> SyntaxError: invalid syntax >> > I imagine the spacing in the email was not preserved, but e

Re: [Image-SIG] that's enough

2010-07-14 Thread Alec Bennett
htly more complex example. > > -Chris > > > > > > > "Trust me. I have a lot of experience at this." >> General Custer's unremembered message to his men, >>just before leading them into the Little Big Horn Valley >> >

Re: [Image-SIG] that's enough

2010-07-14 Thread Alec Bennett
My understanding is that show() is mainly for debugging and tests, and that it doesn't offer very much control or efficiency. That's not to say that what you're after can't be done, maybe someone else can help you with that, I just don't know. Personally I'd suggest using WXPython, which can do wh

Re: [Image-SIG] When to use antialiasing when resizing?

2010-07-05 Thread Alec Bennett
I use antialiasing all the time too. But wow, try it on an Atom processor (i.e. netbook) sometime, very very very slow. When no filter is specified, does it use the Bilinear filter? ___ Image-SIG maillist - Image-SIG@python.org http://mail.python.org/m

[Image-SIG] When to use antialiasing when resizing?

2010-06-28 Thread Alec Bennett
I'm wondering if there's some general rule as to when to use the Antialias filter when resizing an image? It seems that logo type images benefit greatly from it, but regular pictures get less of a benefit? I recently discovered that Atom-processor netbooks have a very hard time with antialiasing,

Re: [Image-SIG] How to improve rotation quality?

2010-02-22 Thread Alec Bennett
> Ideally, you should use whatever color is going to be in the background when you show the image. Agreed, but the problem is I'm making a collage of pictures where the new pictures are placed above previous pictures, so there's no one consistent background color. > Even better would be if you co

Re: [Image-SIG] How to improve rotation quality?

2010-02-19 Thread Alec Bennett
> So I tried adding a black background to the image first, then rotating it -- much better. > See the enclosed version of your test code, and a rotated image. Wow, what a difference! Even if the border is a single pixel, much better results. I set the border color to grey, which seems to work as w

[Image-SIG] How to improve rotation quality?

2010-02-17 Thread Alec Bennett
I'm wondering if anyone has any idea how to get better results from PIL's rotate() function? No matter what filter I use I'm getting very jagged edges after rotating an image. Here's how I'm invoking the filters: pic = pic.rotate(random_rotation, resample=Image.NEAREST, expand=1) pic = pic.rotate

[Image-SIG] How to "crop" along a mask?

2010-01-25 Thread Alec Bennett
I'm trying to take a group of pictures and give them rounded edges. I have a source image (a rectangle with rounded edges, transparent PNG) and I'd like to use this as a template. All the target images would become transparent wherever this source image is transparent. In other words, I'd be makin

[Image-SIG] How to open "raw" images using PIL?

2009-06-16 Thread Alec Bennett
I have some "raw" images shot from a Canon DSLR that I'd like to manipulate using the PIL. I know I can convert them using another program, but if possible I'd like to do so directly using PIL. Is this possible with the PIL? Currently I get something like: f = "IMG_0025.CR2" im = Image.open(f)

[Image-SIG] Filter Factory filters in PIL?

2009-05-14 Thread Alec Bennett
Does anyone know if its possible to use Filter Factory (aka 8bf) files in PIL, or any other way from Python or commandline? Apparently there's a plugin for Gimp: http://registry.gimp.org/node/10902 But I'd really like to be able to use these filters from Python if possible. For anyone who doesn'

Re: [Image-SIG] how to draw a stroke/outline around text with PIL?

2009-05-14 Thread Alec Bennett
For anyone else who comes down this road, I found a way to do this in the videocapture.py module. Seems to work well. Here's my code adapted: import Image, ImageFont, ImageDraw import win32api, os x, y = 10, 10 fname1 = "c:/test.jpg" im = Image.open(fname1) pointsize = 30 fillcolor = "red" sha

[Image-SIG] how to draw a stroke/outline around text with PIL?

2009-05-14 Thread Alec Bennett
I'm trying to draw an outline (what Photoshop calls a stroke) around some text. Does anyone have any pointers? Here's the code I'm using to draw the basic text: import Image, ImageFont, ImageDraw import win32api im = Image.open("test.jpg") pointsize = 30 textcolor = "red" font = win32api.GetWin

[Image-SIG] question about DPI

2009-05-12 Thread Alec Bennett
I'm pasting a few images onto a canvas, resizing them, and saving the canvas in 300 dpi. The idea that even though I'm resizing those pictures, I'd like to preserve as much of their data as possible. In other words I'd like them to be very high quality. I'm not sure I'm doing this correctly, howev

[Image-SIG] text along a curve?

2009-04-04 Thread Alec Bennett
I'm wondering if its possible to do text along a curve in PIL? Or if anyone can think of another way, short of Photoshop? Thanks for the help. ___ Image-SIG maillist - Image-SIG@python.org http://mail.python.org/mailman/listinfo/image-sig

Re: [Image-SIG] Mutable images

2008-11-21 Thread Alec Bennett
Seems too obvious to mention, but: src_image2 = src_image.resize( (20,20) ) On Fri, Nov 21, 2008 at 12:22 PM, Christopher Brooks <[EMAIL PROTECTED]>wrote: > I want to resize an image using something like: > > src_image.resize( (20,20) ) > > This doesn't work, since resize() returns the new im

[Image-SIG] Sepia with the PIL?

2008-07-14 Thread Alec Bennett
I'm wondering if there's some snazzy way to get sepia image conversion with PIL? I'm currently getting black and white like this, which works great: enhancer.enhance(0) Thanks for any help. ___ Image-SIG maillist - Image-SIG@python.org http://mail.pyt

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

2008-02-13 Thread Alec Bennett
Python, of course! Just kidding, I don't know enough about Matlab to answer that question well. Python's great for image processing though. As far as your code, my guess is the output of split() when fed a gif isn't in r g b format? Try running your code on a JPEG, works just fine. But with a GIF

Re: [Image-SIG] Conversion to ARGB format.

2008-01-29 Thread Alec Bennett
im = Image.open("whatever.jpg").convert('RGBA') 2008/1/29 KwangYul Seo <[EMAIL PROTECTED]>: > Hi, > > Is it possible to convert a RGB image to ARGB format? The following code > did not work. > > import PIL.Image > im = PIL.Imageim.new("RGB", (100, 100)) > im.convert("ARGB") > > > Thanks, > Kwa

Re: [Image-SIG] PIL - How do I resize an image while keeping the IPTC and EXIF info?

2008-01-26 Thread Alec Bennett
I don't know if the PIL has a way to preserve it, but if not you could of course read the data before resizing then write the data to the new image. http://simonwillison.net/2003/Nov/13/exif/ 2008/1/24 Samuel Moore <[EMAIL PROTECTED]>: > > > Hi, > I'm using the Python Imaging Library (PIL v1

Re: [Image-SIG] Handling "image file is not of type 17" errors...

2007-11-25 Thread Alec Bennett
Indeed it does, I'm sure you're right. For anyone else coming down this path, here's how I handled the situation. None too graceful but so far so good: try: w, h = im.size # check integrity of image file im.save("whatever.jpg", quality=100) except: print "Whoops, bad file" What's inte

[Image-SIG] Handling "image file is not of type 17" errors...

2007-11-24 Thread Alec Bennett
Running PIL 1.1.6 with Python 2.4 on Windows XP I occasoinally get an error "Image file is not of type 17". Unfortunately this error doesn't throw an exception, instead it pops up a modular dialog box that completely halts my program. I know (or think) its caused by a thread conflict, one thread a

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

2007-01-17 Thread Alec Bennett
Douglas helped me off list, wanted to post the complete code in case anyone else comes looking. So here's the code to rotate an image and paste it onto another image without creating a black bounding box: from PIL import Image collage = Image.open("cheese.jpg") # open the pic and give it an al

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

2007-01-17 Thread Alec Bennett
Hmm, still getting a black box. The code as it stands now in case anything jumps out at you: from PIL import Image collage = Image.open("collage.jpg") # open the pic and give it an alpha channel so it's transparent im1 = Image.open("pic1.jpg") im1.convert('RGBA') # rotate it and expand it's ca

[Image-SIG] rotate image with transparent background?

2007-01-17 Thread Alec Bennett
I'm trying to rotate an image and have the expanded background be transparent. For example: im = Image.open("pic1.jpg") im2 = im.rotate(32, expand = 1) im2.show() In the above, im2 is a copy of pic1.jpg that has been rotated 32 degrees. The problem is that the background over where it was rotate

[Image-SIG] centering graphical text with PIL?

2006-12-12 Thread Alec Bennett
I'm trying to center some graphical text using the PIL. Anyone have a clue how to do this? If there's some way of knowing how big the resulting graphical word is, I could obviously center it. For example: import ImageFont, ImageDraw, Image image_file = "button.jpg" image = Image.open(image_fil

[Image-SIG] centering graphical text with PIL?

2006-12-11 Thread Alec Bennett
I'm trying to center some graphical text using the PIL. Anyone have a clue how to do this? If there's some way of knowing how big the resulting graphical word is, I could obviously center it. For example: import ImageFont, ImageDraw, Image image_file = "button.jpg" image = Image.open(image_file

[Image-SIG] compile problem

2006-03-30 Thread Alec Bennett
I'm trying to compile a module (VideoCapture.py) that uses a PIL font, and after compiling (both with PY2EXE and Pyinstaller) I get an error "cannot find font file".The offending line is:self.normalfont = ImageFont.load_path('helvetica-10.pil')    self.boldfont = ImageFont.load_path('helvB08.p