pil

How to install imagingft in OSX and Ubuntu?

I'm using PIL 1.1.6 to render a truetype font on my local Windows machine. I'd like to be able to get the application running in OSX and Ubuntu (server). So far the instructions I've found all deal with specific ports repositories on OSX (Darwinports, Macports, etc.) or very outdated instructions for Linux. Has anyone recently got ima...

Center-/middle-align text with PIL?

How would I center-align (and middle-vertical-align) text when using PIL? ...

Image library with advanced text effects?

What would be the best Python library to use when producing text-based images requiring things such as leading, kerning, outlines, drop-shadows, etc? I've worked with PIL before for resizing images, but the methods for working with text seem rather limited. Is there a better alternative? ...

Separate image of text into component character images

I'd like to separate an image of text into it's component characters, also as images. For example, using the sample below I'd end up with 14 images. I'm only going to be using text on a single line, so the y-height is unimportant - what I need to find is the beginning and end of each letter and crop to those coordinates. That way I wou...

Convert an image to RGBA mode with python

I tried the code listed at Using PIL to make all white pixels transparent to convert some .ico files to .png images with transparent background. It doesn't work on all .ico images, some time it just outputs an image with black background. Sample .ico files can be located here ...

Optimize .png images with PIL

All i need is create a .png image with transparent background, draw some text in black on it and save it using img.save('target.png', option='optimize') It looks like to save .png images in 32-bit mode automatically. Can I reduce the color depth while not make the output images looks much worse before saving? Since it contains only blac...

Faster method of reading screen pixel in Python than PIL?

Currently I'm using a pixel reader via AutoItv3 to perform some actions in a program that is running direct X; A game. Right now the program works fine but as an exercise I've been rewriting it in python. Right now I can do: import ImageGrab # Part of PIL image = ImageGrab.grab() #Define an area to capture. rgb = image.getpix...

making undo in python

hello first of all .. sorry if my english was bad. its my 3rd language im working on a paint software that draw over images and save them again ( for commenting propose ) i use pile and wxpython. but im still having problems with some features .. what is the ideal way to make the undo option ? another question .. when the user scal...

Got Django and Buildout working, but what about PIL and Postgres?

Hello. I'm on Mac OSX 10.5.8. I have followed Jacob Kaplan-Moss's article on setting up Django with Buildout: http://jacobian.org/writing/django-apps-with-buildout/ Finally, I have got this Buildout to work! ...but I'm now needing PIL and Postgres for a complete isolated Django development area. I've tried to modify my buildout.cfg with...

adding lighting effects to an image in python

hi, I want to specify a light source at a particular location in an image using Python. PIL's ImageEnhance module does provide a way to briten an image. but I want to have a control over light source placement to acheieve special effects. Does anyone know how to do this? thank you! ...

Python Image Library produces a crappy quality jpeg when I resize a picture.

I use the Python Image Library (PIL) to resize an image and create a thumbnail. Why is it that my code produces an image that is so crappy and low-quality? Can someone tell me how to modify the code so that it's the highest quality JPEG? def create_thumbnail(buffer, width=100, height=100): im = Image.open(StringIO(buffer)) if im...

Image embossing in Python with PIL -- adding depth, azimuth etc

I am trying to emboss an image using PIL. PIL provides a basic way to emboss an image ( using ImageFilter.EMBOSS). In image editing packages like GIMP, you can vary parameters like Azimuth, depth and elevation in this embossed image. Does anyone know how to do this with PIL? At the very least I want to adjust the "depth" of the em...

Dithering in text using PIL and truetype fonts

Consider the following code: from PIL import Image, ImageDraw, ImageFont def addText(img, lTxt): FONT_SIZE = 10 INTERLINE_DISTANCE = FONT_SIZE + 1 font = ImageFont.truetype('arial.ttf', FONT_SIZE) lTxtImageHeight = INTERLINE_DISTANCE * len(lTxt) # create text image lTxtImg = Image.new('RGBA', (img.size[1], l...

wx.Font uses a facename & PIL.ImageFont uses a filename... Is there any way to relate the two??

Hey guys, sorry but this is going to be a big one.. ;) I'm running into an annoying little snag right now. I'm creating an RSS-style app for work which will be placed on some large LCD displays across the office. The basic concept is to have a client/server setup where the user would use a custom editor to create the individual articles...

Strange bug while combining images in Python

I have a hundred 10x10 px images, and I want to combine them into a big 100x100 image. I'm using the Image library to first create a blank image and then paste in the smaller images: blank = Image.new('P',(100,100)) blank.paste(im,box) The smaller images are in color, but the resulting image turns out in all grayscale. Is there a fix ...

Installing PIL (Python Imaging Library) in Win7 64 bits, Python 2.6.4

I'm trying to install said library for use with Python. I tried downloading the executable installer for Windows, which runs, but says it doesn't find a Python installation. Then tried registering (http://effbot.org/zone/python-register.htm) Python, but the script says it can't register (although the keys appear in my register). Then I ...

How can I find out why PIL isn't drawing the font correctly?

Here's the code I'm using: from PIL import Image import ImageFont, ImageDraw import sys import pdb img = Image.new("RGBA",(300,300)) draw = ImageDraw.Draw(img) font = ImageFont.truetype(sys.argv[1],30) draw.text((0,100),"world",font=font,fill="red") del draw img.save(sys.argv[2],"PNG") and here's the image that results: ( for some r...

Can I get the kerning value of two characters using PIL?

Is it possible to get the kerning value of two characters in a font using PIL? ...

Creating very large images using Python Image Library

I'm trying to create a very large image (25000x25000) by pasting together many smaller images. Upon calling Image.new() with such large dimensions, python runs out of memory and I get a MemoryError. Is there a way to write out an image like this incrementally, without having the whole thing resident in RAM? EDIT: Using ImageMagick's m...

Getting invalid image error in Django, but PIL is installed and passes all tests

So I've finally successfully installed PIL (after many difficulties) on RHEL5 with Django (development version) and Python 2.6 installed at /opt/python2.6. Running selftest.py shows that everything appears to be installed correctly: $ python2.6 selftest.py 57 tests passed. I can upload .png files and .gif files without difficulties,...