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?
convert not changing colorspace
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: convert not changing colorspace
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
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
I tried the command in that same order, and the grayscale conversion doesn't work, either.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: convert not changing colorspace
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
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
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: convert not changing colorspace
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.
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.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: convert not changing colorspace
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.
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.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: convert not changing colorspace
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
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
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/