0

I already know how to get a gradient image but how can I merge the gradient image and the base image so that it looks something like this: link

convert -size 1327x1327 xc:transparent gradient: grad_image.png

or another approach has been suggested here Base image is base image The output should the gradient at the bottom like this: https://1drv.ms/i/s!Aoi-6MWkMNN4kGLYNmqN9dm1nrOD

Community
  • 1
  • 1
Abhi
  • 442
  • 1
  • 10
  • 24
  • Where is the base image? Your `xc:transparent` is pointless, by the way - you can remove it. – Mark Setchell Jul 19 '16 at 21:41
  • @MarkSetchell I've edited the question. The output image should have a gradient at the bottom of the image as shown [here](https://1drv.ms/i/s!Aoi-6MWkMNN4kGLYNmqN9dm1nrOD) – Abhi Jul 20 '16 at 04:02
  • Sorry, I still don't get it. You have a blue jellyfish image and some words, which I don't know how you generate on a black-white gradient. There is also no indication of what you want to achieve. – Mark Setchell Jul 20 '16 at 06:32
  • @MarkSetchell if you see the output image that has white background and title at the bottom, you will notice that there is a black to white gradient at the bottom beneath the title on that image. So if I have any image and I want to add this type of gradient how can I achieve this. – Abhi Jul 20 '16 at 06:38
  • What's it got to do with the jellyfish? Do you want to paint white on the jellyfish? How's the answer supposed to look? Just describe it in words if you can't create the actual image. – Mark Setchell Jul 20 '16 at 06:47
  • @MarkSetchell Ignore the jelly fish image for now. I only want to know about the black-white gradient at the bottom of any image just like the same output in the question. ( I'll edit my question and remove this jelly image) – Abhi Jul 20 '16 at 06:50
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/117775/discussion-between-abhi-and-mark-setchell). – Abhi Jul 20 '16 at 07:07

1 Answers1

1

I can only guess what you are trying to do, so my first attempt would be this:

convert jelly.jpg \( -size 1140x100! gradient:none-black \) -gravity south -composite -pointsize 36 -fill white -annotate +0+20 "Title Treatment" result.png

enter image description here

The important parts are that the gradient goes from black to transparent rather than black to white, else you will get white on your background which I am guessing you don't want.

The -gravity south places the gradient at the bottom and also sets the initial position of the title, but that is then shifted 20 pixels up from the bottom with -annotate +0+20.

Hope that helps.

Update 1

If you want to control the gradient, you can alter the start and end of it using rgb() constants, like this:

convert jelly.jpg \( -size 1140x100! gradient:"rgba(0,0,0,0.25)"-"rgb(50,50,50)" \) -gravity south -composite -pointsize 36 -fill white -annotate +0+20 "Title Treatment" result.png

enter image description here

Or you can make it go from one colour to another:

convert jelly.jpg \( -size 1140x100! gradient:"rgba(0,0,0,0.25)"-"rgba(255,255,0,0.75)" \) -gravity south -composite -pointsize 36 -fill white -annotate +0+20 "Title Treatment" result.png

enter image description here

Or you can change the blending mode, so here I use colorBurn:

convert jelly.jpg \( -size 1140x100! gradient:"rgba(0,0,0,0.25)"-"rgba(255,255,0,0.75)" \) -gravity south -compose colorburn -composite -pointsize 36 -fill white -annotate +0+20 "Title Treatment" result.png

enter image description here

If you want to try some other blending modes, you can get a list with:

identify -list compose:

Atop
Blend
Blur
Bumpmap
ChangeMask
Clear
ColorBurn
ColorDodge
Colorize
CopyAlpha
CopyBlack
CopyBlue
CopyCyan
CopyGreen
Copy
CopyMagenta
CopyRed
CopyYellow
Darken
DarkenIntensity
DivideDst
DivideSrc
Dst
Difference
Displace
Dissolve
Distort
DstAtop
DstIn
DstOut
DstOver
Exclusion
HardLight
HardMix
Hue
In
Intensity
Lighten
LightenIntensity
LinearBurn
LinearDodge
LinearLight
Luminize
Mathematics
MinusDst
MinusSrc
Modulate
ModulusAdd
ModulusSubtract
Multiply
None
Out
Overlay
Over
PegtopLight
PinLight
Plus
Replace
Saturate
Screen
SoftLight
Src
SrcAtop
SrcIn
SrcOut
SrcOver
VividLight
Xor

Update 2

If you want to blur the text, it is easier to create that first, blur it, and then underlay the background like this:

convert -size 1140x100! gradient:none-black     \
   -pointsize 36 -fill white -gravity south     \
   -annotate +5+25 "Title Treatment" -blur 0x4  \
   -annotate +0+20 "Title Treatment" jelly.jpg +swap -composite result.png

enter image description here

Update 3

If you want to shadow your text, and control your gradient and do a load of other things, you may be better off doing one thing at a time. So, let's try and make your text with a drop-shadow first, then put a gradient on your image then put the shadowed text on top of that - and hope we are getting close!

string="Funky Main Title\nSub-title"
convert -size 1200x400 xc:none -pointsize 72 -gravity center   \
       -fill white  -stroke black  -annotate +25+65 "$string"  \
       \( +clone -background black  -shadow 70x4+5+5 \) +swap  \
       -background none -flatten  -trim +repage shadowed.png

enter image description here

Now put gradient on main image and title top of that:

convert jelly.jpg                                                   \
  \( -size 1140x100! gradient:"rgba(0,0,0,0.25)"-"rgb(50,50,50)" \) \
  -gravity south -composite                                         \
  shadowed.png -composite result.png

enter image description here

Mark Setchell
  • 191,897
  • 31
  • 273
  • 432
  • 1
    Thank you ! This is what I wanted. – Abhi Jul 20 '16 at 08:48
  • Excellent! Pleased to be of service - good luck with your project. – Mark Setchell Jul 20 '16 at 08:54
  • Mark is there a way I can control the transparency of this gradient – Abhi Jul 20 '16 at 09:06
  • I was trying to add text shadow for the title using `convert jelly.jpg \( -size 1140x100! gradient:none-black \) -gravity south -composite -pointsize 36 -fill white -annotate +5+25 "Title Treatment" -blur 0x4 -annotate +0+20 "Title Treatment" result.png` not working the bottom half is getting blured – Abhi Jul 20 '16 at 09:21
  • Mark if I have 2 lines in the title like: ** Hello This is Me** and we are doing blur on both the titles as `-annotate +5+25 Hello -blur 0x2 -annotate +5+25 This is Me -blur 0x2` The second time i do blur for `This is Me` the title 'Hello' as get blurred What's wrong – Abhi Jul 20 '16 at 11:57
  • Use `-annotate +5+25 "Line 1\nLine 2"` – Mark Setchell Jul 20 '16 at 12:02
  • Cool ! awesome, How did you master this. I tried to read stuff online and everything gets messed up – Abhi Jul 20 '16 at 12:29
  • Years of frustration, practice, experiment... :-) – Mark Setchell Jul 20 '16 at 12:30
  • `gradient:"rgba(0,0,0,0.25)"-"rgba(255,255,0,0.75)" ` the command is taking hours to run if I use a high resolution image – Abhi Jul 20 '16 at 12:39
  • sorry my bad there was a space between`"rgba(0,0,0,0.25)"-"rgba(255,255,0,0.75)"` – Abhi Jul 20 '16 at 12:40
  • also if we add these `"rgba(0,0,0,0.25)"-"rgba(255,255,0,0.75)"` the gradient strip becomes visible is there a way to merge or blend it with the base image ? – Abhi Jul 20 '16 at 12:45
  • Experiment with changing the `0.25` and `0.75` to numbers between 0 and 1 to get the effect you want. – Mark Setchell Jul 20 '16 at 12:51
  • And If I want to overlay the `string` on the image with text-shadow. Lets say that I have image abc.png and I want to write hello along with its shadow. – Abhi Jul 20 '16 at 13:21
  • Have another look at **Update 3**. – Mark Setchell Jul 20 '16 at 13:57
  • Mark if I use the -blur option the whole image is betting blurred instead of the text only `-annotate +30+25 'Hello\nMark' -blur 0x4 -fill red -annotate +25+20 'Hello\nMark' ` – Abhi Jul 20 '16 at 17:19
  • Mark in the Update 2 if we fill the color as white then its working fine. But if I fill black shadow it wont work. – Abhi Jul 21 '16 at 04:27
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/117869/discussion-between-abhi-and-mark-setchell). – Abhi Jul 21 '16 at 05:57