Hello,
I am new with Imagemagick and I don't succeed in apply a gradient on another image.
I have found a lost of topics about this but I haven't succeed in make it work, and honnestly I don't want to study all the doc because it's juste for a one time development.
1 - I create a simple image :
convert -size 500x500 -background blue label:text blue.png
2 - I create a gradient
convert -size 1000x800 gradient:grey-none -function Polynomial -4,4,0 -distort SRT 90 gradient.png
3 - I try to apply the gradient on the image with a transparency effect (in my dreams )
convert blue.png -composite gradient.png output.png
I have also try : convert blue.png ( gradient.png -colorspace Gray -gamma 1.0 ) +matte -compose Copy_Opacity -composite output.png
In fact I have try a lot of things (without really understand them) found in several topics but nothing works.
Any help would be appreciate. Thanks
Just apply a transparent gradient
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Just apply a transparent gradient
Your third command should be something like ...
... which will copy the transparency from gradient.png.
However, your images are not the same size, so you might want to adjust.
Code: Select all
convert blue.png gradient.png -compose CopyOpacity -composite output.png
However, your images are not the same size, so you might want to adjust.
snibgo's IM pages: im.snibgo.com
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Just apply a transparent gradient
You may want to include a -alpha off before the -composite when using -compose CopyOpacity.
The original meaning of -compose CopyOpacity is to copy the transparency from source to the destination image. This is the same result you would get using -compose DstIn when the destination image is fully-opaque.
However if no transparency is present, IM treats the second image as a greyscale 'alpha mask' image to assign to the transparency channel of the destination image. Using -alpha off (or +matte ) ensures that the second image at least has no transparency channel to be copied.
Without that addition you may find the composition doing nothing (coping fully-opaque transparency channel) for no visible reason in some cases.
See the warning in
http://www.imagemagick.org/Usage/compose/#copyopacity
Recent Development: a new addition to IM is a setting ( -intensity ) that can change how the compose CopyOpacity (and CopyBlack) methods reads a 'grayscale intensity' from the given source/overlay image, especially from more 'colorful' images that have no alpha channel. When the composition method is to be updated to use this setting is unknown.
The original meaning of -compose CopyOpacity is to copy the transparency from source to the destination image. This is the same result you would get using -compose DstIn when the destination image is fully-opaque.
However if no transparency is present, IM treats the second image as a greyscale 'alpha mask' image to assign to the transparency channel of the destination image. Using -alpha off (or +matte ) ensures that the second image at least has no transparency channel to be copied.
Without that addition you may find the composition doing nothing (coping fully-opaque transparency channel) for no visible reason in some cases.
See the warning in
http://www.imagemagick.org/Usage/compose/#copyopacity
Recent Development: a new addition to IM is a setting ( -intensity ) that can change how the compose CopyOpacity (and CopyBlack) methods reads a 'grayscale intensity' from the given source/overlay image, especially from more 'colorful' images that have no alpha channel. When the composition method is to be updated to use this setting is unknown.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: Just apply a transparent gradient
Thanks for your answer, it make me progress a lot
The solution of snigbo was quite good for me (the -alpha off from Anthony doesn't work for me, no matter).
But I know realize it's not exactly what I need for my effect.
Because what I want is to make a part of my image "darker" on one side (it's for a shadow on a object).
What I want with my gradient (which is from white to grey) is : nothing change on my object where the gradient is white and a bit darker where the gradient is grey.
But in fact, currently the result is different : I see the original image where the gradient is grey and I see a white zone where the gradient is white.
Do you see what I mean ? Any idea for that ?
Thanks
The solution of snigbo was quite good for me (the -alpha off from Anthony doesn't work for me, no matter).
But I know realize it's not exactly what I need for my effect.
Because what I want is to make a part of my image "darker" on one side (it's for a shadow on a object).
What I want with my gradient (which is from white to grey) is : nothing change on my object where the gradient is white and a bit darker where the gradient is grey.
But in fact, currently the result is different : I see the original image where the gradient is grey and I see a white zone where the gradient is white.
Do you see what I mean ? Any idea for that ?
Thanks
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Just apply a transparent gradient
It isn't. You are probably using a viewer that shows transparent pixels as white. In your gradient command, "none" means "transparent black".What I want with my gradient (which is from white to grey)...
I'm confused about what you want. Do you want any transparency in the output?
snibgo's IM pages: im.snibgo.com
Re: Just apply a transparent gradient
Yes, I think you're right, it should be transparent. But my viewer don't show transparency, so I can't know it's transparent ou white.
What I want to make is somthing like this : http://tavmjong.free.fr/INKSCAPE/MANUAL ... Can_14.png
(don't look at the page, it doesn't matter, I just take the image in google image to show the result I want).
I have already made the sticker, which is plane currently.
Then I want to make the shadow on it.
Because I am going to apply it on a background which is a bottle, with a shadow on it too.
Si I want the sticker to have the same kind of shadow.
Is it more clear ?
So my sticker is white with some black/red letters, and now I want (with the gradient) make a part of it darker to simulate the shadow.
What I want to make is somthing like this : http://tavmjong.free.fr/INKSCAPE/MANUAL ... Can_14.png
(don't look at the page, it doesn't matter, I just take the image in google image to show the result I want).
I have already made the sticker, which is plane currently.
Then I want to make the shadow on it.
Because I am going to apply it on a background which is a bottle, with a shadow on it too.
Si I want the sticker to have the same kind of shadow.
Is it more clear ?
So my sticker is white with some black/red letters, and now I want (with the gradient) make a part of it darker to simulate the shadow.