[Image-SIG] adding overlay & text to many file

Laura & Edward Cannon cannon.el at gmail.com
Wed Jan 14 17:27:55 CET 2009


Reading gimp files is tricky. Resizing photos is not hard just
remember that PIL thinks in pixels, so just multiply your PPI by the
dimension to get the size in pixels. Look at the paste function in the
Image module for details on adding logos and bars. The ImageDraw
function might be useful for the rest of the process. There is a
method on font objects, getsize, that will tell you how large your
text will be, this would allow you to choose a smaller font if
necessary.
Happy programing

On Wed, Jan 14, 2009 at 7:26 AM, Bernard Rankin <berankin99 at yahoo.com> wrote:
> Hello,
>
> I'm sure this must be a common question, but I could not find any docs on this.  Perhapse my google skills needs improvment.
>
> Basically, I've got a bunch of pictures from a party/event that I want to do several things to:
>
> 1)  Resize to 4x6 @ 300 PPI
> 2)  Add a slightly translucent ~ 1" white bar on top of the image (across the bottom).
> 3)  Over the white bar, on the left, place a small 1"x1" logo.
> 4)  Over the white bar, centered on the remainder, put the names of the people in the photo. (Reducing text size if needed to fit on one line.)
> 5)  Over the white bar, centered on the remainder, put the name of the event on the next line.
> 6)  Add a black border to entire image.
> 7)  Export as JPEG.
>
> There is a CSV file that contains the "names of the people in each photo" to file name mapping.  (One line per image file.)
>
> Can this be automated with the PIL?
>
> The biggest challenge I imagine would be the step 4 that needs to auto-resize text to fit in a certain area....  That is, it's a single-line text box such that the text inside starts out at some desired size, but is
> automatically shrunk (in font size) to fit the width of the box if the
> supplied text is too long.
>
> Additionally, for the overlay, it would be nice to use a GIMP file with dummy text as a template that I can supply the correct text and base image file.  Is this possible with PIL?
>
> Thank you,
> :)
>
>
>
>
>
> _______________________________________________
> Image-SIG maillist  -  Image-SIG at python.org
> http://mail.python.org/mailman/listinfo/image-sig
>


More information about the Image-SIG mailing list