Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Insert a text chunk into a png image

Tags:

linux

png

I'm looking for a simple command-line tool (on Linux) to insert a text chunk (e.g. copyright) into a png file, resulting in a new png file:

> png-insert-text-chunk "here's my text chunk" < in.png > out.png

Note: by "insert a text chunk", I do not mean "draw some text on the image". I mean: insert the text into the png file as a chunk, in the technical sense. This can be used, for example, to insert a copyright message that isn't displayed on the actual image.

like image 551
gcbenison Avatar asked Jan 27 '12 15:01

gcbenison


1 Answers

Use ImageMagick's convert and the -set option:

convert IN.png \
        -set 'Copyright' 'CC-BY-SA 4.0' \
        -set 'Title' 'A wonderful day' \
        -set comment 'Photo taken while running' \
        OUT.png

The -set option is used to set metadata elements. In the case of PNG these often go into tEXt chunks.

like image 134
gioele Avatar answered Oct 28 '22 17:10

gioele