Image with 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?".
Anandkv
Posts: 14
Joined: 2009-11-18T06:54:09-07:00
Authentication code: 8675309

Image with profile

Post by Anandkv »

Hi All,

I am using profile given by the client to apply greyscale effect to an image. But i am not getting any changes to the rendered image, only the size of the image gets increased. Not sure whether the icm profile is correct or not.

command which i am using
convert org.jpg -profile bw.icm org_bw.jpg

icm can be downloaded from http://www.newtoybox.com/bw.icm

Please help me in this regard.

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

Re: Image with profile

Post by snibgo »

If org.jpg has an embedded profile, your command should create a monochrome version.

If it doesn't, you should add the appropriate profile first, eg:

convert org.jpg -profile sRGB_v4_ICC_preference.icc -profile bw.icm org_bw.jpg
snibgo's IM pages: im.snibgo.com
Anandkv
Posts: 14
Joined: 2009-11-18T06:54:09-07:00
Authentication code: 8675309

Re: Image with profile

Post by Anandkv »

Thanks,
It seems there is a problem with the icm file. Got a new file from client and its working fine. Now, i have another problem. I am merging the org_bw.jpg to another image (png), But it seems the profile is removed from the org_bw.jpg after merging. Please suggest me how can i retain the profile info of org_bw.jpg on merging.

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

Re: Image with profile

Post by snibgo »

What command are you using for the merge? Any operation that involves two input files will copy the profile and other data from only one of the input files. (And it shouldn't change either input file, unless you use mogrify.)
snibgo's IM pages: im.snibgo.com
Anandkv
Posts: 14
Joined: 2009-11-18T06:54:09-07:00
Authentication code: 8675309

Re: Image with profile

Post by Anandkv »

Thanks for your feedback,
i am using composite command for merging the images.
composite -geometry +0+0 org_bw.png destination1.png destination2.png.

Please correct me if i am wrong. Also, If needed i will put the images which i am using for your reference.

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

Re: Image with profile

Post by snibgo »

destination2.png will take its size, comments, profile and the rest from destination1.png, not org_bw.png. If you want the opposite effect, reverse the order of the files.

See http://www.imagemagick.org/Usage/compose/
snibgo's IM pages: im.snibgo.com
Anandkv
Posts: 14
Joined: 2009-11-18T06:54:09-07:00
Authentication code: 8675309

Re: Image with profile

Post by Anandkv »

Hi,

I am in a situation where i need to merge more than one image to destination2.png. In this case some image will be having profile and some of the images may not have profiles. Here destination2.png is a template image with transparency.

I do not have much knowledge in profile. And, when i try to open the org_bw.png in photoshop it gives me an alert 'The document org_bw.png has an embedded color profile that does not match the current RGB working space. The embedded profile will be used instead of the working space'. Other image viewers eg. irfan viewer shows image without profile.
Is there any option to add profile to an image without embed?

Please suggest me the changes i need to apply.

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

Re: Image with profile

Post by snibgo »

It's difficult to be specific without knowing exactly what you are trying to do.
Is there any option to add profile to an image without embed?
"-profile ABC.icc" will adjust the image according to the profile, and embed it. You can then remove the embedded profile, if you want, with "-strip" or "+profile".
snibgo's IM pages: im.snibgo.com
Anandkv
Posts: 14
Joined: 2009-11-18T06:54:09-07:00
Authentication code: 8675309

Re: Image with profile

Post by Anandkv »

Fine. The requirement is i need to place two images into a template (destination2.png) at different positions, where one of the image contains profile for greyscale and another one does not. After placing both the images into template (destination2.png) the whole image gets greyscaled. But the expected output is, only the portion of the image with greyscale profile should be shown with greyscale effect in resultant image (destination2.png).

Please confirm whether this information make any sense.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Image with profile

Post by snibgo »

Sorry, I don't understand. If the whole image gets greyscaled, it will all be greyscale, not just part of it.

Can you post input files and expected output?
snibgo's IM pages: im.snibgo.com
Anandkv
Posts: 14
Joined: 2009-11-18T06:54:09-07:00
Authentication code: 8675309

Re: Image with profile

Post by Anandkv »

Good. Below given the image details for your reference, Please check and suggest the changes need to be done.

Template image: http://www.newtoybox.com/template.png

First image with profile : http://www.newtoybox.com/left_image_with_profile.png

Second image without any profile : http://www.newtoybox.com/right_image.png

And, below is the expected result

Expected image: http://www.newtoybox.com/expected_output.jpg

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

Re: Image with profile

Post by snibgo »

This Windows 7 script:

Code: Select all

set TEMPLATE=template.png
set LEFT=left_image_with_profile.png
set RIGHT=right_image.png

FOR /F "usebackq" %%L IN (`identify -format "WW=%%w\nHH=%%h" %TEMPLATE%`) DO set %%L

convert -size %WW%x%HH% xc:None ^
  %LEFT% -colorspace Gray ^
  -gravity West -composite ^
  ( ^
    -size %WW%x%HH% xc:None ^
    %RIGHT% ^
    -gravity East -composite ^
    ( template.png -channel RGBA -fill Red -floodfill +500+500 rgba(100%%,100%%,100%%,0) ) ^
    -composite ^
    -channel RGBA -fill None -floodfill +500+500 Red ^
  ) ^
  -composite ^
  girl_output.jpg
creates this output, which looks like your desired output: http://www.snibgo.org/images/girl_output.jpg

There may be a problem with left_image_with_profile.png:
- Quicktime Picture Viewer 7.6.5 shows a colour image.
- Windows Photo Viewer can't open the file.
- Gimp 2.6.8 shows the image as monochrome, whether or not I choose to convert it to inbuilt sRGB colorspace.
- ImageMagick 6.6.0-8 creates a colour image, unless I use "-colorspace Gray".
snibgo's IM pages: im.snibgo.com
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Image with profile

Post by snibgo »

I was having finger-trouble. The correct convert that takes the embedded profile into account so IM creats a monochrome image is:

Code: Select all

convert -size %WW%x%HH% xc:None ^
  %LEFT% -profile sRGB.icm ^
  -gravity West -composite ^
  ( ^
    -size %WW%x%HH% xc:None ^
    %RIGHT% ^
    -gravity East -composite ^
    ( template.png -channel RGBA -fill Red -floodfill +500+500 rgba(100%%,100%%,100%%,0) ) ^
    -composite ^
    -channel RGBA -fill None -floodfill +500+500 Red ^
  ) ^
  -composite ^
  girl_output.jpg
snibgo's IM pages: im.snibgo.com
Anandkv
Posts: 14
Joined: 2009-11-18T06:54:09-07:00
Authentication code: 8675309

Re: Image with profile

Post by Anandkv »

Great, thanks. I had a feeling that left_image_with_profile.png image might be having an issue after adding profile.
And, http://www.newtoybox.com/left_image.png is the original image which i want to add profile http://www.newtoybox.com/bw.icc to that.

So the convert command which i used is

convert left_image.png -profile bw.icc left_image_with_profile.png

Please do the needful and correct me if i am wrong.

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

Re: Image with profile

Post by snibgo »

Yes, that command applies the profile. Perhaps Quicktime and Windows viewers don't like large profiles. Then "-profile sRGB.icm" would convert it back to sRGB space.

I would do all the work in a single convert command:

Code: Select all

set TEMPLATE=template.png
set LEFT=left_image.png
set RIGHT=right_image.png

FOR /F "usebackq" %%L IN (`identify -format "WW=%%w\nHH=%%h" %TEMPLATE%`) DO set %%L

convert -size %WW%x%HH% xc:None ^
  %LEFT% -profile bw.icc -profile sRGB.icm ^
  -gravity West -composite ^
  ( ^
    -size %WW%x%HH% xc:None ^
    %RIGHT% ^
    -gravity East -composite ^
    ( %TEMPLATE% -channel RGBA -fill Red -floodfill +500+500 rgba(100%%,100%%,100%%,0) ) ^
    -composite ^
    -channel RGBA -fill None -floodfill +500+500 Red ^
  ) ^
  -composite ^
  girl_output.jpg
I have effectively created two templates out of template.png. I can't see a way of doing the job without. If I were doing this many times, I would create the two templates just once.
snibgo's IM pages: im.snibgo.com
Post Reply