pil

Unable to find the Python PIL library.Google App Engine

Installed the Google App Engine SDK.Python 2.6 perfect. Wanted to go into images, and test locally.Installed PIL Installed Python, then ran the PIL install, worked this time. Things seemed good, but trying to do localhost image manipulation gives: "NotImplementedError: Unable to find the Python PIL library. Please view the SDK documen...

Remove ppc from compilation flags in python setup scripts

I'm trying to install PIL on an Intel Mac OS X Leopard machine. Unfortunately, "setup.py build" thinks it should be compiling for ppc. gcc -arch ppc -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -fno-strict-aliasing -Wno-long-double -no-cpp-precomp -mno-fused-madd -fno-common -dynamic -DNDEBUG -g -O3 -DHAVE_LIBJPEG -DHAVE_LIBZ -...

PIL does not save transparency

from PIL import Image img = Image.open('1.png') img.save('2.png') The first image has a transparent background, but when I save it, the transparency is gone (background is white) What am I doing wrong? ...

How do I use PIL with Tkinter?

I'm missing something at a very basic level when it comes to loading an image using PIL and displaying it in a window created by Tkinter. The simplest form of what I'm trying to do is: import Tkinter as TK from PIL import Image, ImageTk im = Image.open("C:\\tinycat.jpg") tkIm = ImageTk.PhotoImage(im) tkIm.pack() TK.mainloop() When I ...

PIL Image.resize() not resizing the picture

I have some strange problem with PIL not resizing the image. def handle_uploaded_image(i, u): # resize image from PIL import Image img = Image.open(i) if img.mode not in ('L', 'RGB'): img = img.convert('RGB') width, height = img.size if width == height: img.thumbnail(settings.THUMB_SIZE, Image.ANTIAL...

Speed up image display

Hello, I am using the PIL (python image library) to crop a very large image and present the cropped area to the interface. The problem Im having is that the process is taking too long. When the user clicks on the image to crop it, the image takes quite a long time to show up on the sizer I attach it to. I tried doing this two ways: ...

Django ImageField validation & PIL

Hello On sunday, I had problems with python modules, when I installed stackless python. Now I have compiled and installed : setuptools & python-mysqldb and i got my django project up and running again. (i also reinstalled django-1.1), Then I compiled and installed, jpeg, freetype2 and PIL. I also started using mod_wsgi instead of ...

Transparency in PNGs with reportlab 2.3

I have two PNGs that I am trying to combine into a PDF using ReportLab 2.3 on Python 2.5. When I use canvas.drawImage(ImageReader) to write either PNG onto the canvas and save, the transparency comes out black. If I use PIL (1.1.6) to generate a new Image, then paste() either PNG onto the PIL Image, it composits just fine. I've double...

Rescale intensities of a PIL Image

What is the simplest/cleanest way to rescale the intensities of a PIL Image? Suppose that I have a 16-bit image from a 12-bit camera, so only the values 0–4095 are in use. I would like to rescale the intensities so that the entire range 0–65535 is used. What is the simplest/cleanest way to do this when the image is represented as PIL'...

Python (Imaging library): Resample string as argument

Python beginner question. Code below should explain my problem: import Image resolution = (200,500) scaler = "Image.ANTIALIAS" im = Image.open("/home/user/Photos/DSC00320.JPG") im.resize(resolution , scaler) RESULT: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python2.6/dist-packages/PI...

How does Django determine if an uploaded image is valid?

I'm trying to add images to my models in my Django app. models.py class ImageMain(models.Model): """This is the Main Image of the product""" product = models.ForeignKey(Product) photo = models.ImageField(upload_to='products') In development mode, every time I try to upload the image via Django admin, I keep getting: Upload a...

PIL: Thumbnail and end up with a square image

Calling image = Image.open(data) image.thumbnail((36,36), Image.NEAREST) will maintain the aspect ratio. But I need to end up displaying the image like this: <img src="/media/image.png" style="height:36px; width:36px" /> Can I have a letterbox style with either transparent or white around the image? ...

PIL: Image resizing : Algorithm similar to firefox's

I'm getting about the same bad looking resizing from all the 4 algorithms of PIL >>> data = utils.fetch("http://wavestock.com/images/beta-icon.gif") >>> image = Image.open(StringIO.StringIO(data)); image.save("/home/ptarjan/www/tmp/metaward/original.png") >>> >>> image = Image.open(StringIO.StringIO(data)); image.resize((36,36), Image.A...

Problems with Snow Leopard, Django & PIL

Hi I am having some trouble getting Django & PIL work properly since upgrading to Snow Leopard. I have installed freetype, libjpeg and then PIL, which tells me: --- TKINTER support ok --- JPEG support ok --- ZLIB (PNG/ZIP) support ok --- FREETYPE2 support ok but when I try to upload a jpeg through the django admin interface I get: ...

How to adjust the quality of a resized image in Python Imaging Library?

Hi, thanks for taking time to read my question. I am working on PIL and need to know if the image quality can be adjusted while resizing or thumbnailing an image. From what I have known is the default quality is set to 85. Can this parameter be tweaked during resizing? I am currently using the following code: image = Image.open(filena...

Installing Python Imaging Library (PIL) on Snow Leopard with updated Python 2.6.2

I have a fresh install (started with a wiped drive) of Snow Leopard with the developer tools installed during the Snow Leopard installation. I then installed Python 2.6.2, replacing the Snow Leopard default python 2.6.1. I've tried to install PIL by (1) easy_install (2) pip and (3) downloading source and running "python setup.py build" m...

PIL not rendering fonts uniformly across machines

I wrote some code that spits out an image. The code ran on my local machine yields this image: and on my webhost, it looks like this: As you can see they are different. The top is much nicer. Both are using the same code, and the same font file (VeraMoBd.ttf), the same version of PIL (1.1.6), and the same Python version (2.6). I g...

How can I make images so that appengine doesn't make transparent into black on resize?

I'm on the google appengine, and trying to resize images. I do : from google.appengine.api import images image = images.resize(contents, w, h) And for some images I get a nice transparent resize, and others I get a black background. How can I keep the transparency for all images? Original : http://www.stdicon.com/g-flat/application...

Why can't I crop this image in Python PIL? (simple syntax problem?)

from PIL import Image im = Image.open(f) #the size is 500x350 box = (0,0,100,100) kay = im.crop(box) It seems like there's nothing wrong with this, right? That last line will result in an error and won't continue, but I don't know what the error is because it's AJAX and I can't debug ATM. ...

Resize image twice in Django using PIL

I have a function in which I'm trying to resize a photo twice from request.FILES['image']. I'm using the image.thumbnail() with the Parser as well. This works fine when I create one thumbnail, but in my view if I repeat the exact same thing again, it fails in the parser via IOError cannot parse image. I'm very confused. I've created Stri...