Page 1 of 1
Convert 8bit grayscale jpeg image to 24bit jpeg image
Posted: 2014-01-14T00:22:54-07:00
by abhilash.ar
Using CommandLine approach of ImageMagick I wanted to convert 8bit grayscale jpeg image to 24bit jpeg image maintaining the same image density(dpi).
I used the below command, but there is no change in the output image properties and bitdepth is unaltered
“ImageMagick-6.8.8-Q16\convert.exe” “Input_Image_Path” -density 300 -type TrueColor “Output_Image_Path”
Re: Convert 8bit grayscale jpeg image to 24bit jpeg image
Posted: 2014-01-14T04:22:52-07:00
by snibgo
What is the difference between "8bit grayscale jpeg" and "24bit jpeg"? As far as I know, jpegs can always store three channels, almost always 8 bits per channel.
Re: Convert 8bit grayscale jpeg image to 24bit jpeg image
Posted: 2014-01-14T10:02:17-07:00
by fmw42
snibgo wrote:What is the difference between "8bit grayscale jpeg" and "24bit jpeg"? As far as I know, jpegs can always store three channels, almost always 8 bits per channel.
I suspect the OP wants to convert the colorspace to sRGB, but have it grayscale. I don't think IM will allow that, unless at least one pixel is changed from gray. IM knows when the channels are all the same and forces the colorspace or type to gray.
Re: Convert 8bit grayscale jpeg image to 24bit jpeg image
Posted: 2014-01-14T10:33:34-07:00
by magick
Add -type TrueColor to your command line.
Re: Convert 8bit grayscale jpeg image to 24bit jpeg image
Posted: 2014-01-14T11:57:43-07:00
by fmw42
magick wrote:Add -type TrueColor to your command line.
That does not seem to work for me. Afterwards, IM still reports colorspace gray and type grayscale
convert zelda3.png -colorspace gray zelda3g.png
Code: Select all
Image: zelda3g.png
Format: PNG (Portable Network Graphics)
Mime type: image/png
Class: DirectClass
Geometry: 128x128+0+0
Resolution: 72x72
Print size: 1.77778x1.77778
Units: Undefined
Type: Grayscale
Base type: Grayscale
Endianess: Undefined
Colorspace: Gray
Depth: 16-bit
Channel depth:
gray: 16-bit
convert zelda3g.png -type truecolor zelda3g_rgb.png
Code: Select all
Image: zelda3g_rgb.png
Format: PNG (Portable Network Graphics)
Mime type: image/png
Class: DirectClass
Geometry: 128x128+0+0
Resolution: 72x72
Print size: 1.77778x1.77778
Units: Undefined
Type: Grayscale
Base type: Grayscale
Endianess: Undefined
Colorspace: Gray
Depth: 16-bit
Channel depth:
gray: 16-bit
Re: Convert 8bit grayscale jpeg image to 24bit jpeg image
Posted: 2014-01-14T13:09:07-07:00
by magick
Does it work for JPEG? If not, we'll investigate. If not for PNG, alert our PNG maintainer that its a bug!
Re: Convert 8bit grayscale jpeg image to 24bit jpeg image
Posted: 2014-01-14T13:25:32-07:00
by snibgo
My first reply was wrong. Jpegs can have just one channel. As magick suggests, "-type truecolor" ensures it has 3 channels.
Code: Select all
F:\web\im>%IM%convert logo: l.jpg
F:\web\im>dumpjpeg /il.jpg
Input: /i l.jpg
l.jpg: JPEG image is 640w * 480h, 3 color components, 8 bits per sample
JPEG process: Baseline
width 640, height 480
F:\web\im>%IM%convert logo: -monochrome l.jpg
F:\web\im>dumpjpeg /il.jpg
Input: /i l.jpg
l.jpg: JPEG image is 640w * 480h, 1 color components, 8 bits per sample
JPEG process: Baseline
width 640, height 480
F:\web\im>%IM%convert logo: -monochrome -type truecolor l.jpg
F:\web\im>dumpjpeg /il.jpg
Input: /i l.jpg
l.jpg: JPEG image is 640w * 480h, 3 color components, 8 bits per sample
JPEG process: Baseline
width 640, height 480
@abhilash.ar: please clarify what you are trying to do. Ideally, please post your input to dropbox.com or similar and paste the URL here.
Re: Convert 8bit grayscale jpeg image to 24bit jpeg image
Posted: 2014-01-14T14:19:21-07:00
by glennrp
magick wrote:Does it work for JPEG? If not, we'll investigate. If not for PNG, alert our PNG maintainer that its a bug!
The PNG that is written is color-type 2, depth 16. When "identify" evaluates the image (not the input file!), it discovers that the pixels
are all gray and reports "grayscale". If you have to know about the stored PNG colortype, etc., don't use "identify" to find out. Use a third-party
application such as "pngcheck" instead. Probably the same goes for JPG files, too, but you'd need a different third-party application.
Re: Convert 8bit grayscale jpeg image to 24bit jpeg image
Posted: 2014-01-14T14:49:28-07:00
by snibgo
As I did above with dumpjpeg.
Re: Convert 8bit grayscale jpeg image to 24bit jpeg image
Posted: 2014-01-14T22:57:07-07:00
by abhilash.ar
Thanks all for your replies
I had included '-type truecolor' in my command line. But it is not affecting jpeg images
Re: Convert 8bit grayscale jpeg image to 24bit jpeg image
Posted: 2014-01-14T23:12:17-07:00
by fmw42
abhilash.ar wrote:Thanks all for your replies
I had included '-type truecolor' in my command line. But it is not affecting jpeg images
How do you know? Are you using IM identify? If so, that was the point of the comments above. You may need to verify using some other tool besides IM identify, such as Exiftool or one of the other tools mentioned. Apparently IM sees three identical channels as reports it as grayscale. But other tools will recognize it as 3 channels (RGB).
Re: Convert 8bit grayscale jpeg image to 24bit jpeg image
Posted: 2014-01-15T04:54:29-07:00
by abhilash.ar
I used the below command to get the desired output
“ImageMagick-6.8.8-Q16\convert.exe” -density 300 -type bilevel -type TrueColor “Input_Image.jpeg” “Output_Image.jpeg”
Thanks for all your suggestions
Re: Convert 8bit grayscale jpeg image to 24bit jpeg image
Posted: 2014-01-15T10:14:32-07:00
by fmw42
abhilash.ar wrote:I used the below command to get the desired output
“ImageMagick-6.8.8-Q16\convert.exe” -density 300 -type bilevel -type TrueColor “Input_Image.jpeg” “Output_Image.jpeg”
Thanks for all your suggestions
Proper IM syntax in this case would be to read the input before any other command.
see
http://www.imagemagick.org/Usage/basics/#why