PAID: Extract copyright from comment and annotate image

Do you need consulting from ImageMagick experts and are willing to pay for their expertise? Or are you well versed in ImageMagick and offer paid consulting? If so, post here otherwise post elsewhere for free assistance.
Post Reply
centesimiae
Posts: 18
Joined: 2014-03-14T10:10:54-07:00
Authentication code: 6789

PAID: Extract copyright from comment and annotate image

Post by centesimiae »

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?
User avatar
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

Post by fmw42 »

What is your IM version and platform?

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
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.
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: PAID: Extract copyright from comment and annotate image

Post by glennrp »

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.

Code: Select all

Properties:
    Copyright: � 2013,2015 John Cunningham Bowler
    date:create: 2017-08-14T17:12:35-04:00
but does not show up in the info:

So I suppose we have a bug on our hands, in both IM6 and IM7.
User avatar
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

Post by fmw42 »

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.
snibgo
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

Post by snibgo »

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:

Code: Select all

convert aga_3364.jpg -resize 600x600 -pointsize 25 -gravity SouthEast -annotate +0+0 %[EXIF:Copyright] x.png
(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

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
Post Reply