Op woensdag 14-01-2009 om 16:49 uur [tijdzone +0100], schreef Frédéric: > Le 14/1/2009, "Bernard Rankin" <beranki...@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. And you would get 2 and 3 also for free. For both steps you can use the watermark action: once with a fixed translucent white bar image (.png) and once with the logo.
> > 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. Phatch has already a text action which has done the hard work already as well. Just start from that as a base and hack it to use a csv file as input instead of a fixed text. If you have played with python and PIL already, it should be not that hard. BTW Phatch can be used as a desktop application but also as a server process without a GUI, once you have your action configured. Phatch is available in Ubuntu Intrepid, Fedora, Suse, Arch Linux, ... in the usual repositories. The latest version is 0.1.x (where x are bug fix releases which you probably don't need). Stani _______________________________________________ Image-SIG maillist - Image-SIG@python.org http://mail.python.org/mailman/listinfo/image-sig