Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Fill text box from file
#1
Hi everyone,

Does anyone know of a way to import text from a text file (a .csv file, for example) into a text box?
Reply
#2
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.

   
Reply
#3
@ohms_law

Just a query. Is this more of a scripting or batch requirement. Add various text to many images ?
Reply
#4
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...

   
Reply
#5
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
Reply
#6
Interesting. I'd have to learn another tool, but...

Food for thought. Thanks!
Reply


Forum Jump: