Imprint Identify output into image

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
HarryS
Posts: 3
Joined: 2016-09-01T09:04:31-07:00
Authentication code: 1151

Imprint Identify output into image

Post by HarryS »

Hi,

I am new to IM and I have a folder with some hundred images that need to be analysed.
I want IM to create copies of these images with the imprinted information of the "indetify -verbose image.tif" output.

How to do that ?

Thanks !!
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Imprint Identify output into image

Post by snibgo »

You can write text from identify to a file, then use one of the methods shown on http://www.imagemagick.org/Usage/text/ to write the text in that file to an image. For example:

Code: Select all

identify -verbose r.tiff >t.txt

convert r.tiff -background None label:@t.txt -gravity Center -layers merge withtext.tiff
Or you can do this in one step, with piping.
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Imprint Identify output into image

Post by fmw42 »

The verbose information is rather long. Where do you want to put that information? In a meta tag such as the comment tag or imbedded onto the pixel data so that it shows in the image? If your image is not very big, that much text may not be readable if imbedded onto the image

Please always provide your IM version and platform, since syntax may differ.

If imbedded, as snibgo shows, then I would use caption: so that it wraps to the size of your image or some specified width and or height rather than label:, which will try to put it all in one line.
HarryS
Posts: 3
Joined: 2016-09-01T09:04:31-07:00
Authentication code: 1151

Re: Imprint Identify output into image

Post by HarryS »

Thanks,

I am using IM 7 on a Win64 DOS shell.

I want the stats embedded in pixeldata, images are about 5000x5000 pixels.
I guess snibgos solution with caption: will work for me. Will try tomorrow.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Imprint Identify output into image

Post by fmw42 »

label: also works (because that text has line breaks), but you may want to specify a pointsize or the height of the image to the text part so that it is readable as desired.

Perhaps you should post your image to some free hosting service such as dropbox.com and put the URL here so we can access your image to help you further.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Imprint Identify output into image

Post by snibgo »

You may also need other refinements, eg because black text doesn't show clearly against dark images.
snibgo's IM pages: im.snibgo.com
HarryS
Posts: 3
Joined: 2016-09-01T09:04:31-07:00
Authentication code: 1151

Re: Imprint Identify output into image

Post by HarryS »

Thanks,

Code: Select all

identify -verbose r.tiff >t.txt
convert r.tiff -background None -size 5000x5000 -fill white -gravity Center label:@t.txt -layers merge withtext.tiff
works for me perfectly.

This brings me to another question:
How can I embedd a histogram into these images (instead of the identify output) ?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Imprint Identify output into image

Post by snibgo »

By "histogram", do you mean the histogram text data, or a histogram image?

Code: Select all

convert input.png -define histogram:unique-colors=true histogram:info:h.txt
h.txt is histogram text data.

Code: Select all

convert input.png -define histogram:unique-colors=false histogram:h.png
h.png is a histogram image.

You can "-composite" an image over another, eg:

Code: Select all

convert input.png h.png -composite out.png
("histogram:" is an output coder that writes to a file or pipe, not an option that creates an in-memory image, so we can't read an image, create its histogram image, and composite them together in a single convert command, as far as I can see.)
snibgo's IM pages: im.snibgo.com
Post Reply