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

Frédéric frederic.mantegazza at gbiloba.org
Wed Jan 14 16:49:34 CET 2009


Le 14/1/2009, "Bernard Rankin" <berankin99 at yahoo.com> a écrit:

>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?

I think that it is possible to do all you want. First, I would suggest
you have a look at Phatch, a great batch processor, build on PIL. Step
1, 6 and 7 are already done in Phatch default actions.

Then, I would write a few Phatch actions to match your needs. I would
first build an transparent image with the logo and names, then merge
this image with the original.

I agree that the tricky part is the text. Anyway, you can start to
prototype this with PIL, then turn your code into a Phatch action to
have a great batch processor.

--
   Frédéric


More information about the Image-SIG mailing list