Convert 8bit grayscale jpeg image to 24bit jpeg image
-
- Posts: 3
- Joined: 2014-01-13T23:19:29-07:00
- Authentication code: 6789
Convert 8bit grayscale jpeg image to 24bit jpeg image
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”
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”
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Convert 8bit grayscale jpeg image to 24bit jpeg image
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.
snibgo's IM pages: im.snibgo.com
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Convert 8bit grayscale jpeg image to 24bit jpeg image
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.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.
Re: Convert 8bit grayscale jpeg image to 24bit jpeg image
Add -type TrueColor to your command line.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Convert 8bit grayscale jpeg image to 24bit jpeg image
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
Does it work for JPEG? If not, we'll investigate. If not for PNG, alert our PNG maintainer that its a bug!
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Convert 8bit grayscale jpeg image to 24bit jpeg image
My first reply was wrong. Jpegs can have just one channel. As magick suggests, "-type truecolor" ensures it has 3 channels.
@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.
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
snibgo's IM pages: im.snibgo.com
Re: Convert 8bit grayscale jpeg image to 24bit jpeg image
The PNG that is written is color-type 2, depth 16. When "identify" evaluates the image (not the input file!), it discovers that the pixelsmagick wrote:Does it work for JPEG? If not, we'll investigate. If not for PNG, alert our PNG maintainer that its a bug!
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.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Convert 8bit grayscale jpeg image to 24bit jpeg image
As I did above with dumpjpeg.
snibgo's IM pages: im.snibgo.com
-
- Posts: 3
- Joined: 2014-01-13T23:19:29-07:00
- Authentication code: 6789
Re: Convert 8bit grayscale jpeg image to 24bit jpeg image
Thanks all for your replies
I had included '-type truecolor' in my command line. But it is not affecting jpeg images
I had included '-type truecolor' in my command line. But it is not affecting jpeg images
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Convert 8bit grayscale jpeg image to 24bit jpeg image
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).
-
- Posts: 3
- Joined: 2014-01-13T23:19:29-07:00
- Authentication code: 6789
Re: Convert 8bit grayscale jpeg image to 24bit jpeg image
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
“ImageMagick-6.8.8-Q16\convert.exe” -density 300 -type bilevel -type TrueColor “Input_Image.jpeg” “Output_Image.jpeg”
Thanks for all your suggestions
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Convert 8bit grayscale jpeg image to 24bit jpeg image
Proper IM syntax in this case would be to read the input before any other command.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
see
http://www.imagemagick.org/Usage/basics/#why