Mogrify: Apply vs. Convert to Profile

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
rcgordon
Posts: 2
Joined: 2017-01-19T21:03:32-07:00
Authentication code: 1151

Mogrify: Apply vs. Convert to Profile

Post by rcgordon »

I have installed ImageMagick on a Linux server hosting a WordPress site.

If I run the command

Code: Select all

mogrify -profile PATH/TO/sRGB.icm MY_TARGET_IMAGE
…will that apply/assign the profile or convert the image to that profile?

The docs seem to be confusing on this issue.

The top of http://www.imagemagick.org/script/mogrify.php says:

"Use the mogrify program to resize an image, blur, crop, despeckle, dither, draw on, flip, join, re-sample, and much more. This tool is similar to convert except that the original image file is overwritten (unless you change the file suffix with the -format option) with any changes you request."

…which makes me think conversion.

But http://www.imagemagick.org/script/comma ... hp#profile says:

"Using -profile filename adds an ICM (ICC color management), IPTC (newswire information), or a generic profile to the image."

…which suggests assignment/application.

But then, this, from the same page, a couple paragraphs down:

"It is important to note that results may depend on whether or not the original image already has an included profile. Also, keep in mind that -profile is an "operator" (as opposed to a "setting") and therefore a conversion is made each time it is encountered, in order, in the command-line." (But it's unclear to me if this is alluding to the convert command, but not mogrify.)

Then there's this this, from http://www.imagemagick.org/script/mogrify.php, down at the -profile listing:

-profile filename add, delete, or apply an image profile

It does SEEM like it's doing an apply/assign action, but I'm not 100% sure.

Color me confused. I'm looking for a way to apply an sRGB profile to untagged images, via the command line, in Linux.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Mogrify: Apply vs. Convert to Profile

Post by fmw42 »

Both mogrify and convert will add the profile to the image or convert from an existing profile to the new one. The image will be read, a new profile added and then the image with the profile will be written to the output, which could be the same as the input. But note, then image must be read. You cannot just include a profile with an image without reading the image first in IM. Perhaps some other tool would do this. If the image is JPG (lossy compression), then it will lose some quality being read and written again. Other formats that are not lossy compressed will show no affect in quality. But you must allow some time for reading and writing the image.

For only one image, use convert since it is more flexible than mogrify. For many images in a folder that all need the profile, you can use mogrify to process all the images in a folder using a wild card or you can write a script loop over all the images in the folder and use convert once for each image.

The syntax for each is different.

For mogrify, see http://www.imagemagick.org/Usage/basics/#mogrify
rcgordon
Posts: 2
Joined: 2017-01-19T21:03:32-07:00
Authentication code: 1151

Re: Mogrify: Apply vs. Convert to Profile

Post by rcgordon »

Thank you. It seems that apply the profile with exiftool in a way that does not rewrite the image data (or change the mod date), using the command:

Code: Select all

exiftool "-icc_profile<=/PATH/TO/sRGB.icm" -overwrite_original TARGET_FILE
so I think that that will be my choice for this application.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Mogrify: Apply vs. Convert to Profile

Post by snibgo »

rcgordon wrote:…will that apply/assign the profile or convert the image to that profile?
If the image doesn't already have a profile, the new profile is assigned. If it did have a profile, the image is converted from the old profile to the new profile.

If it already has a profile, you can assign a new one either by stripping first, or using "-set profile ABC.icm".

Thanks for the exiftool magic.
snibgo's IM pages: im.snibgo.com
Post Reply