PAID: Extract copyright from comment and annotate image
-
- Posts: 18
- Joined: 2014-03-14T10:10:54-07:00
- Authentication code: 6789
PAID: Extract copyright from comment and annotate image
I know I can read the copyright in the comments property, but is there a single command to extract the comment from the image metadata and put in the lower right hand side of the image?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: PAID: Extract copyright from comment and annotate image
What is your IM version and platform?
In IM 6 on unix, you could do
In IM 7 (unix or windows), you can do
Change the pint-size and font as desired. If you font is not in your type.xml file, you can use the path2/fontname.ttf in place of just the font name.
In IM 6 on unix, you could do
Code: Select all
comment=`convert image -format "%c" info:`
convert image -fill black -pointsize 24 -font arial -gravity southeast -annotate +0+0 "$comment" result
In IM 7 (unix or windows), you can do
Code: Select all
magick image -fill black -pointsize 24 -font arial -gravity southeast -annotate +0+0 "%[comment]" result
Re: PAID: Extract copyright from comment and annotate image
This does not seem to work with a PNG image that contains a tEXt chunk with copright. The copyright
line does show up in the output of identify -verbose as a Copyright property.
but does not show up in the info:
So I suppose we have a bug on our hands, in both IM6 and IM7.
line does show up in the output of identify -verbose as a Copyright property.
Code: Select all
Properties:
Copyright: � 2013,2015 John Cunningham Bowler
date:create: 2017-08-14T17:12:35-04:00
So I suppose we have a bug on our hands, in both IM6 and IM7.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: PAID: Extract copyright from comment and annotate image
No, you just said the "comment field". There is a comment field in IM that is unrelated to PNG chucks. That is what I told you how to get. I do not know how to access PNG chunk. For that you need help from the IM PNG developer, glennrp.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: PAID: Extract copyright from comment and annotate image
The copyright notice might appear in a number of places. Cameras put it in an exif field, so we can write it into the image like this:
(In v7, use "magick" instead of "convert".)
From my camera (Nikon D800) the copyright notice is padded on the right with spaces, so the text doesn't appear on the right in the output image. We want to strip the trailing spaces. IM doesn't contain string-handling functions, so we have to do that outside IM. For example, Windows CMD syntax, using sed:
Code: Select all
convert aga_3364.jpg -resize 600x600 -pointsize 25 -gravity SouthEast -annotate +0+0 %[EXIF:Copyright] x.png
From my camera (Nikon D800) the copyright notice is padded on the right with spaces, so the text doesn't appear on the right in the output image. We want to strip the trailing spaces. IM doesn't contain string-handling functions, so we have to do that outside IM. For example, Windows CMD syntax, using sed:
Code: Select all
for /F "usebackq tokens=*" %L in (`convert aga_3364.jpg -format %[EXIF:Copyright] info:`) do set COPYR=%L
for /F "usebackq tokens=*" %L in (`echo %COPYR% ^| sed -e 's/[ \t]*$//'`) do set COPY2=%L
convert aga_3364.jpg -resize 600x600 -pointsize 25 -gravity SouthEast -annotate +0+0 "%COPY2%" x.png
snibgo's IM pages: im.snibgo.com