Gimp-Forum.net
Fill text box from file - Printable Version

+- Gimp-Forum.net (https://www.gimp-forum.net)
+-- Forum: GIMP (https://www.gimp-forum.net/Forum-GIMP)
+--- Forum: General questions (https://www.gimp-forum.net/Forum-General-questions)
+--- Thread: Fill text box from file (/Thread-Fill-text-box-from-file)



Fill text box from file - ohms_law - 03-20-2023

Hi everyone,

Does anyone know of a way to import text from a text file (a .csv file, for example) into a text box?


RE: Fill text box from file - PixLab - 03-20-2023

2 options

open the .csv with a text editor (you will get all the separators like comas and so) select all > Copy (Ctrl+C), open GIMP if not yet opened, select the text tool, click on the canvas and past (Ctrl+V)

or open your csv with LibreOffice Calc, select what you need, Copy (Ctrl+C), go to GIMP, select the text tool, click on the canvas to activate the text tool on the canvas, then just paste (Ctrl+V), this later method is nice as it will keep the text formatted as column alike.

[attachment=9560]


RE: Fill text box from file - rich2005 - 03-20-2023

@ohms_law

Just a query. Is this more of a scripting or batch requirement. Add various text to many images ?


RE: Fill text box from file - ohms_law - 03-20-2023

Yeah, it's more of a scripting thing ultimately. I'm laying out hundreds of little game tiles. But I guess I'm trying to take one step at a time...

[attachment=9568]


RE: Fill text box from file - rich2005 - 03-20-2023

Well lets see what replies get posted for Gimp use

but as a possible alternative there is ImageMagick (IM) http://www.imagemagick.org command line.

The bare bones
There is a linux utility sed and as far as I know a Windows version exists that can extract a line of text
Code:
sed '2q;d' lots-of-lines.txt > temp
That takes the second line from a text file and writes to a new file temp

then using IM
Code:
magick mogrify -font Futura-Bold.ttf -pointsize 30 -gravity Center -annotate +0+0 @temp  tile.png
That writes the text from temp into the graphic tile.png using the font and font size

Those would have to be wrapped up in a batch file to cycle through the lines of text and the tiles. The place to ask questions about IM is https://github.com/ImageMagick/ImageMagick/discussions


RE: Fill text box from file - ohms_law - 03-20-2023

Interesting. I'd have to learn another tool, but...

Food for thought. Thanks!