5

I am trying to convert an png Gray scale image to RGB png image using the following command.

convert HopeLoveJoy.png -size 1x1 -fill "rgba(0%,1%,2%,0)" -draw "color 511,511 point" out_test.png 

By using the above the above command I am able to convert but the color of the image is getting changed. Is any thing wrong in the command?? Any help is appreciated. Thanks in advance.

Benjamin Loison
  • 3,782
  • 4
  • 16
  • 33
Sahanaa D
  • 95
  • 1
  • 6
  • Mmmm... what exactly are you trying to achieve? At the moment, you open a file, set the size of any new images you later create to 1x1 although you don't then create any, then you set the fill colour using `rgba()` and draw a point at 511,511. – Mark Setchell Dec 16 '15 at 09:14
  • I just want to convert the Gray scale png image to rgb png image. – Sahanaa D Dec 16 '15 at 09:33
  • @mounikam You can try this command `convert gray.png -type truecolormatte PNG32:color.png`, which convert a gray png named `gray.png` to be a true color png named `color.png`. – Yantao Xie Jul 05 '17 at 04:27

1 Answers1

7

If, as your question title implies, you really just want to go from greyscale to sRGB colorspace, use this:

convert image.png -define png:color-type=2 result.png

I check it like this:

convert image.png -define png:color-type=2 result.png && identify -format "%[colorspace]" result.png
sRGB
Mark Setchell
  • 191,897
  • 31
  • 273
  • 432
  • 1
    Still the result image is being in gray scale format.. I checked it using the command " identify -format %[colorspace] result.png " – Sahanaa D Dec 16 '15 at 09:32
  • 2
    If the image contains only gray pixels "identify" will tell you it's grayscale. If you need to know the actual PNG storage format, use "identify -verbose" and look for "IHDR" in the output. – Glenn Randers-Pehrson Dec 16 '15 at 18:23