Page 1 of 1
convert not changing colorspace
Posted: 2008-03-05T11:15:23-07:00
by cajun67
I need to make JPG thumbnails of all the images that are uploaded to me. Because of the nature of my site, the JPG's that I get are sometimes in grayscale or CMYK format.
Here is the command I'm using:
convert -colorspace rgb -thumbnail 250x250 origfile.jpg filethumb.jpg
Imagemagick creates the new file, but the colorspace remains unchanged. What might I have I missed?
Re: convert not changing colorspace
Posted: 2008-03-05T12:28:52-07:00
by fmw42
For grayscale, this should work:
convert origfile.jpg -colorspace rgb -thumbnail 250x250 filethumb.jpg
but I think you may need to use something else if it is CMYK. See
http://www.imagemagick.org/Usage/channels/#separate
http://www.imagemagick.org/Usage/channe ... bine_other
as converting from CMYK to RGB is not as straight forward
Re: convert not changing colorspace
Posted: 2008-03-05T22:09:39-07:00
by cajun67
I tried the command in that same order, and the grayscale conversion doesn't work, either.
Re: convert not changing colorspace
Posted: 2008-03-06T04:33:02-07:00
by fmw42
Why would you want to make a grayscale image into an rgb thumbnail? It will still be gray tone even if it has 3 channels. It would be just a waste of disk space.
For CMYK, you would need to convert to RGB.
Try this:
convert image_cmyk.jpg -colorspace CMYK -separate tmp.png
convert tmp-0.png -colorspace CMYK mp-0.png \
-compose CopyCyan -composite tmp-1.png \
-compose CopyMagenta -composite tmp-2.png \
-compose CopyYellow -composite tmp-3.png \
-compose CopyBlack -composite -colorspace RGB image_rgb.jpg
Re: convert not changing colorspace
Posted: 2008-03-11T17:42:44-07:00
by anthony
For CMYK, just read the gray scale image then convert it with -colorspace CMYK
There is no need to separate and rebuild the image (as shown above), unless you actually have separate Cyan, Magenta, Yellow and blacK grayscale channel images.
Re: convert not changing colorspace
Posted: 2008-03-17T14:58:02-07:00
by cajun67
The essential problem, however, is that the colorspace conversion is not taking place.
A new file is created, and even resized (on thumbnail conversions), so I know the rest of the command is working; just not the colorspace conversion.
Re: convert not changing colorspace
Posted: 2008-03-17T17:40:29-07:00
by anthony
I think you may be confusing colorspace with image type, and color profiles.
Colorspace is used for IM internal data handling. It will convert this as needed for input and output.
The image TYPE is the way the image data is stored within an image file format!!
See IM examples, Basics, Colorspace and Type
http://imagemagick.org/Usage/basics/#colorspace
this is further complicated in JPEG and TIFF images through the use of color profiles which define different ways of representing colors. This includes CMYK, sRGB, etc etc
For methods of changes an images color profile, see
http://imagemagick.org/Usage/formats/#profiles
Re: convert not changing colorspace
Posted: 2008-03-20T08:22:44-07:00
by cajun67
Thanks for clearing that up; that was the problem.