If I apply $image->colorizeImage('#0000aa', 1) to a full color image, I have a blue tinted image that retains some of the original colors - cool, as expected.
If I first convert to grayscale via $image->modulateImage(100,0,100) and then apply the colorizeImage(), I get a nearly-perfect blue tinted image without any other colors, except for a minor yellow hue anywhere there was a #ffffff pixel. This is much more apparent when an image has a white background.
See the attached example. Is there any way to recolor an image and "force" a particular palette or color range?
colorizeImage sets white pixels to a secondary color
-
- Posts: 16
- Joined: 2011-07-27T21:24:03-07:00
- Authentication code: 8675308
colorizeImage sets white pixels to a secondary color
- Attachments
-
- link-recolored.png (65.13 KiB) Viewed 15327 times
-
- Posts: 16
- Joined: 2011-07-27T21:24:03-07:00
- Authentication code: 8675308
Re: colorizeImage sets white pixels to a secondary color
This is what I'm trying to ultimately achieve:
- Attachments
-
- link-blue.png (26.9 KiB) Viewed 15321 times
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: colorizeImage sets white pixels to a secondary color
try convert to grayscale, then +level-colors blue,white. Change blue to whatever shade works best. You will have to overlay your black border again.
-
- Posts: 16
- Joined: 2011-07-27T21:24:03-07:00
- Authentication code: 8675308
Re: colorizeImage sets white pixels to a secondary color
The black border is just to show a background, i.e. that this has a white bg.
Can you describe the +level-colors blue, white? Is this syntax from the command line? I'm looking to achieve this within Imagick if possible, or if it must be on the command line do you know of a method to get the output directly without saving and printing a file?
Can you describe the +level-colors blue, white? Is this syntax from the command line? I'm looking to achieve this within Imagick if possible, or if it must be on the command line do you know of a method to get the output directly without saving and printing a file?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: colorizeImage sets white pixels to a secondary color
It is a commandline option. My only reference to Imagick is http://php.net/manual/en/book.imagick.php and I do not see it there. But that does not surprise me as Imagick is not well maintained and not kept up to data with Imagemagick options.
You can however, still use PHP exec() to do this step. It allows you to put IM command lines into the exec function to process them.
see
http://www.rubblewebs.co.uk/index.php
You can however, still use PHP exec() to do this step. It allows you to put IM command lines into the exec function to process them.
see
http://www.rubblewebs.co.uk/index.php
-
- Posts: 16
- Joined: 2011-07-27T21:24:03-07:00
- Authentication code: 8675308
Re: colorizeImage sets white pixels to a secondary color
Thanks for your help! This achieves exactly what I am looking for (pretty much the image from my 2nd post above, which was done in Photoshop using a blue opaque layer with 'color' blending mode on top of a grayscale layer):
Code: Select all
$output = shell_exec('convert image.jpg -colorspace gray +level-colors "#0000aa",white -');
header("Content-Type: image/png");
print $output;