Help with image tint/modulation combination

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
nicky77

Help with image tint/modulation combination

Post by nicky77 »

Hi, I'm trying to create a tint effect but I'm having a nightmare trying to get the desired effect. The HSB values used in Photoshop to filter the image do not have the same effect when used in ImageMagick (probably due to my own misuse of them). Anyway, i'm trying to get as close as i can to the effect below, if anyone can help that would be great. The RGB values specified are an orange which I want the image to be coloured with, but the HSB balance isn't right, as you can see below. The closest I've come is using the following code (I've tried a number of variations of this code):

Code: Select all

exec("convert $filename -colorspace Gray $new_image; convert $new_image -fill 'rgb(238, 180, 34)' -tint 100 -modulate 110,100,100 $new_image");
Original image example
Image

desired version
Image

Current result:
Image
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Help with image tint/modulation combination

Post by anthony »

You probably need a slightly different color for the 'tint'

I am not certain what photoshop is doing (or what you are doing with photoshop) and with out that information it is hard to translate photoshop operation into ImageMagick operations.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
nicky77

Re: Help with image tint/modulation combination

Post by nicky77 »

Hi Anthony - what I've done in Photoshop is convert the image to greyscale, then apply HSL values of 36, 62, -6. I want to replicate this with ImageMagick, so I imagine it should be something like this -

Code: Select all

exec("convert $filename -colorspace Gray $new_image; convert $new_image -fill 'hsl(36, 62, -6)' -tint 100 $new_image");
However, the HSL values aren't being processed and i'm left with the image in greyscale. Is there an obvious mistake i'm making here?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Help with image tint/modulation combination

Post by fmw42 »

Code: Select all

exec("convert $filename -colorspace Gray $new_image; convert $new_image -fill 'hsl(36, 62, -6)' -tint 100 $new_image");
you should make this one command line

exec("convert $filename -colorspace Gray -fill 'hsl(36, 62, -6)' -tint 100 $new_image");

BUT NOTE, you cannot have negative lightness (-6 is invalid)


Here is using my tintilize script. I found your basic tint color using a colorpicker to get it in hex, but you can use any IM valid color (see http://www.imagemagick.org/script/color.php and the color converter at the top should help NOTE: HSL and HSB colors have changed definition since I wrote the script. See the previous link about the current definitions as percent or raw values and their ranges.).

This is a bash unix script and you can find it at the link below:
tintilize -m "#DF9B4A" -c -25 cowboy.jpg cowboy_DF9B4A_cm25.jpg

You can use it in PHP exec. I am not expert on this but you can try
exec("/fullpathto/tintilize -m \"#DF9B4A\" -c -35 /fullpathto/cowboy.jpg /fullpathto/cowboy_DF9B4A_cm35.jpg");

Image

This works directly from IM (the +level, lowers the contrast by 10%)

cconvert cowboy.jpg -colorspace gray -fill "#DF9B4A" -tint 100 +level 10,90% cowboy_DF9B4A_t100_pl_10_90.jpg

Image
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Help with image tint/modulation combination

Post by anthony »

nicky77 wrote:Hi Anthony - what I've done in Photoshop is convert the image to greyscale, then apply HSL values of 36, 62, -6.
As pointed out by Fred, -6 lightness is invalid. What this means in terms of what photoshop does is known. Their is a -modulate command, but it works with percentables, and does not effect tinting of grayscale image, only previously tinted images (rotation of existing colors in HSL or HSB colorspace).
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply