Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Add text with script fu
#1
Hello from France,
I have been using Gimp for a long time, having been using GNU/Linux for 20 years.
I'm working on a poster without date. I need, from this file, make 30 similar posters, just adding a different date to each one.
Last year I did it by changing the date by hand.
I wonder if it would not be possible with a Fu script.
- Added slap
- add the text field to the right place and the right size
- choice of the police, size, color, alignment
- adding text (if possible with a dialog box)
- record new file ?

I do not know fu scripts yet but I have programming basics. That does not put me off.
Nevertheless, I just read a lot of pages and I found no example to add a simple text on an image.

So if you could tell me if it's possible and give me some leads, it would be great.

Thank you all in advance,
Carl
Reply
#2
It might be possible with script-fu or python-fu, an expert might look in soon.

However, my first thought was not Gimp but ImageMagick. That should be in your linux repository.

If I create a text file for each date, 01.poster 02.poster ....30.poster then for a single file

Code:
magick poster.jpg -font Futura-Bold.ttf  -pointsize 24 -fill red -annotate +420+1030  @01.poster  01-poster.jpg

writes the content of 01.poster text at the given offset.

For 30 new images then something like a bash file
Code:
#!/bin/bash

find . -name "*.poster" | while read fname ; do
     echo "Doing:  $fname"
     magick poster.jpg -font Futura-Bold.ttf  -pointsize 24 -fill red -annotate +420+1030  @$fname  $fname.jpg
done

creates a new image for each text file and names them 01.poster.jpg 02.poster.jpg ....

As a note I am using kubuntu 18.04 which comes with ImageMagick (IM) 6.9.7 That would use the convert in place of the magick command. For some reason convert throws up errors.
My compiled IM 7.0.8 and magick works fine. If you go down this route and have problems ask on the IM forum https://www.imagemagick.org/discourse-server/ In the Users section.

(edit: The not working convert problem is due to the IM6 security policy held in a policy.xml file. Disabled that and IM6 convert works fine )
Reply
#3
Doable with script-fu, or python-fu, but this is really best done outside of Gimp with a shell script that uses ImageMagick.
Reply
#4
Thank a lot for these answer. 
I didn't think about Imagemagick I use for other think.
Is a good idea.
I'll try that.
Reply


Forum Jump: