Hi all
I was searching throw the Imagic and GD libary but couldnot find a function near info on google about this question.
I want to adjust the total count of colors in an image but how to do that?
I couldnot find a function 'setColorCount' or what so ever
Thanks a lot
Adjusting images in php
Moderator: General Moderators
Re: Adjusting images in php
Out of curiosity, why would you want to do this?
There's the option to save an image as gif (paletted, i.e. 256 colors) or truecolor (png/jpg/etc), but what's the point of explicitly adjusting the color count in an image?
(I can imagine some purposes for this, but not in a web/php related context)
(I can imagine some purposes for this, but not in a web/php related context)
Re: Adjusting images in php
My mom wants to embroidery pictures but she only has x amount of colors (else it gets to dificult for her)
So i want to make her a tool that she can upload pictures, adjust the count of colors and then print the image with color mapping so she can embroidery w/e she wants
So i want to make her a tool that she can upload pictures, adjust the count of colors and then print the image with color mapping so she can embroidery w/e she wants
Re: Adjusting images in php
Haha, that's cool man 
Well what you're looking for is essentially a color quantization algorithm. I dunno if there are any PHP libraries available that do this for you, but if your hosting server has imageMagick installed (most servers do), you can do it by executing a shell command like this:
This will reduce mommy.jpg to only 5 unique colors and save the result as mommy.png.
Well what you're looking for is essentially a color quantization algorithm. I dunno if there are any PHP libraries available that do this for you, but if your hosting server has imageMagick installed (most servers do), you can do it by executing a shell command like this:
Code: Select all
convert mommy.jpg -colors 5 mommy.pngRe: Adjusting images in php
I will try it out and let you know here if it worked
Thanks a lot
Thanks a lot
Re: Adjusting images in php
I did some testing and it works good so thanks a lot Apollo