Page 1 of 1
How to reduce color using ImageMagick
Posted: 2014-04-16T19:06:29-07:00
by bubu333
I have a image and I want to reduce color using ImageMagick
I use this code
strConversion = img.Convert("-fill", "blue", "-colorize", "-5%", strSrcdir, strDestdir)
But I receive image with wrong color
So My code is wrong or wrong way?Please help me.I use Classic ASP
Re: How to reduce color using ImageMagick
Posted: 2014-04-16T19:12:17-07:00
by fmw42
Please define what you mean by reduce color. Post an example input and output image if you can. You can post to dropbox.com (public folder) and put links here.
-colorize replaces the image with some percent of constant color added to the image. Do you mean to use -colors X? 0r -posterize X.
see
http://www.imagemagick.org/script/comma ... php#colors
http://www.imagemagick.org/script/comma ... #posterize
http://www.imagemagick.org/Usage/quantize/
http://www.imagemagick.org/Usage/color_mods/#colorize
Also please identify your version of Imagemagick and your platform.
Re: How to reduce color using ImageMagick
Posted: 2014-04-16T20:36:42-07:00
by bubu333
Hi.Thanks for reply.
I write a web application for convert image realtime and i use imagemagick and reduce color is an option.
My customer ask me to reduce image's color with blue,red,yellow colors.
My sample.jpg:
https://www.dropbox.com/s/98idrkn64eiy1zs/sample.jpg
My result convert :
https://www.dropbox.com/s/tjx9bkqzcp5s5 ... sample.jpg
I'm using ImageMagick-6.8.8-10-Q16 and classic asp,window 7 pro x86
And i'm trying to do with your reply.Waiting for you!
Re: How to reduce color using ImageMagick
Posted: 2014-04-16T22:14:56-07:00
by fmw42
try either
Code: Select all
convert sample.jpg +dither -colors 16 result_c16.gif
or
Code: Select all
convert sample.jpg +dither -posterize 16 result_p16.gif
Reduce or increase the number of colors from 16 as desired.
If this is not what you want, please give more details about what you are trying to do and if possible provide and example of the correct type of result.
The other option would be to create a colortable image and use -remap to reduce the colors in the the image only to the specific colors you put in the colortable image. The colortable image could be as simple as a list of colors as desired something like the following. You can use rgb or hex colors in addition to the colornames. Pick whatever colors you want to use. see
http://www.imagemagick.org/script/color.php
Code: Select all
convert -size 1x1 xc:black xc:red xc:green xc:blue xc:yellow xc:magenta xc:cyan xc:white +append colortable.png
convert sample.jpg +dither -remap colortable.png result_ctable.gif
See
http://www.imagemagick.org/Usage/quantize/#remap
Re: How to reduce color using ImageMagick
Posted: 2014-04-17T01:18:21-07:00
by bubu333
Thanks for reply
I don't have example of the correct type of result.
I use -colorize 0,0,-50 for reduce color.Ex:
convert sample.jpg -colorize 0,0,-100 tmp_sample.jpg for reduce blue color.Something like that.
I don't know about RGB color,so can you help me?I don't now how to reduce yellow color and red color
PS:you can give me an example of -gamma option
Re: How to reduce color using ImageMagick
Posted: 2014-04-17T10:13:05-07:00
by fmw42
Perhaps this is what you want (Windows syntax):
Code: Select all
convert sample.jpg ^
-channel red -evaluate multiply 0.85 +channel ^
-channel blue -evaluate multiply 0.85 +channel ^
-channel yellow -evaluate multiply 0.85 +channel ^
sample_result.jpg
see
http://www.imagemagick.org/script/comma ... hp#channel
http://www.imagemagick.org/script/comma ... p#evaluate