Page 1 of 2

Image with profile

Posted: 2010-04-15T08:12:42-07:00
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,

Re: Image with profile

Posted: 2010-04-15T08:48:35-07:00
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

Re: Image with profile

Posted: 2010-04-16T03:20:48-07:00
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,

Re: Image with profile

Posted: 2010-04-16T07:04:18-07:00
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.)

Re: Image with profile

Posted: 2010-04-16T07:55:31-07:00
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,

Re: Image with profile

Posted: 2010-04-16T08:22:19-07:00
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/

Re: Image with profile

Posted: 2010-04-17T05:49:23-07:00
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,

Re: Image with profile

Posted: 2010-04-17T06:38:15-07:00
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".

Re: Image with profile

Posted: 2010-04-17T09:08:08-07:00
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.

Re: Image with profile

Posted: 2010-04-17T12:28:13-07:00
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?

Re: Image with profile

Posted: 2010-04-18T05:32:04-07:00
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,

Re: Image with profile

Posted: 2010-04-18T10:25:57-07:00
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".

Re: Image with profile

Posted: 2010-04-18T20:52:28-07:00
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

Re: Image with profile

Posted: 2010-04-19T02:12:11-07:00
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,

Re: Image with profile

Posted: 2010-04-19T06:55:32-07:00
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.