Page 1 of 1

Text stroke + shadow + PNG transparency + label interword-spacing fit

Posted: 2016-05-03T02:40:23-07:00
by queensoft
Final image is like this (used as watermark for video):
- transparent PNG, 1920x1080, text at bottom
- text is automatically fit to image width, using 'label' and 'interword-spacing'
- text is offset from border, using 'bordercolor transparent' and 'border'
- text has stroke
- text also needs to have shadow (blur, drop shadow, doesn't really matter which one)
But, every time I try to add this shadow, I end up with completely white image or loss of transparency
Also, I want to create image using one single command line.
I use ImageMagick-7.0.1-Q16.
Command line is like this:

Code: Select all

convert.exe -size 1890x1050 xc:none -font Arial -size 1890x -fill rgb(255,255,255) -stroke #0d0707 -background transparent -gravity South -interword-spacing 500  label:"www.google.com (555)123-4567" -bordercolor transparent -border 15x15  -composite +repage -depth 8 output.png
I have tried numerous examples of 'clone', but got nowhere.
What am I doing wrong ?

Re: Text stroke + shadow + PNG transparency + label interword-spacing fit

Posted: 2016-05-03T03:35:56-07:00
by snibgo
Have you looked at http://www.imagemagick.org/Usage/blur/#shadow ? That shows you how to create shadows when you have opaque letters on a transparent background.

You already have an image, output.png, so you can put a shadow behind it (Windows BAT syntax):

Code: Select all

convert output.png ^
  ( +clone   -background navy   -shadow 80x3+3+3 ) +swap ^
  -background none   -layers merge +repage  s.png
If you want the whole thing in one command, that's easy. The output of the first convert is an image, and that's directly used by the second command, so just merge them:

Code: Select all

convert.exe -size 1890x1050 xc:none -font Arial -size 1890x -fill rgb(255,255,255) -stroke #0d0707 -background transparent -gravity South -interword-spacing 500  label:"www.google.com (555)123-4567" -bordercolor transparent -border 15x15  -composite +repage -depth 8 ^
  ( +clone   -background navy   -shadow 80x3+3+3 ) +swap ^
    -background none   -layers merge +repage  s.png

Re: Text stroke + shadow + PNG transparency + label interword-spacing fit

Posted: 2016-05-03T03:42:52-07:00
by queensoft
Holy cow !!! Thanks a lot !!
Yes, I looked at 'shadow', but I was always adding the shadow before '-composite +repage'
The same thing with 'clone', I was adding it before the final step ('-composite +repage')
Thank you very much, problem solved.
Later edit: hmm, one small problem: final image resolution is not 1920x1080 anymore, but 1932x1092.
I'm pretty sure it's an easy fix.
Later later edit: fixed size, just decreased first one: '-size 1878x1038'
Not sure why this problem occured, but I'm not that curious :)

Re: Text stroke + shadow + PNG transparency + label interword-spacing fit

Posted: 2016-05-03T09:13:44-07:00
by fmw42
shadow extends the image to allow room for the shadow. you can just crop the image back to its original size if you want at the end of your command.