[Image-SIG] Embedding text in image files
kent at springfed.com
Sun Apr 25 06:04:08 EDT 2004
Sorry, I didn't make myself clear.
By "options" I mean things like
EXIF, IPTC, jpeg comments ...
I want to store text (data) in the file,
not the image.
Bernd Preusing wrote:
> On Sat, 24 Apr 2004 14:43:56 -0500, Kent Tenney <kent at springfed.com> wrote:
>> I'm using PIL 1.1.5a1 with Python 2.3.3 on Windows,
>> and would like to put textual information in
>> image files.
>> What options are available for writing
>> text to jpeg, gif and png ?
> what do you mean by "options"?
> IMHO the simplest way is something like this:
> from PIL import ImageDraw, ImageFont
> # input: img, fontPath, text1
> font1 = ImageFont.load(fontPath)
> draw1 = ImageDraw.Draw(img)
> tSizeX, tSizeY = draw1.textsize(text, font=font1)
> # calculate x and y...
> draw.text((x, y), text1, font=font1, fill='#000000')
> ... save img
> I have used this with PIL 1.1.4 only.
> To my experience text looks nicer on RGB images
> (jpeg), so I convert palette images to RGB before
> placing objects.
> If you want more complex effects like shadow text
> or transparent text, take a look at the filters page
> and source code of PyAlbum http://pyalbum.sourceforge.net/Filters.html
> Best regards
> Image-SIG maillist - Image-SIG at python.org
More information about the Image-SIG