Textured text on fixed width & height canvas

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
robocop
Posts: 32
Joined: 2013-03-22T23:15:09-07:00
Authentication code: 6789

Textured text on fixed width & height canvas

Post by robocop »

Hello folks :o

I'm trying to create caption text with a textured background used for the text.

I followed the directions here for the Psychedelic! sample:
http://www.imagemagick.org/Usage/text/#annotate_size

However, what i was hoping to accomplish was to create textured text on a fixed canvas width X height so the text would auto resize & center without having to add -pointsize for the caption.

Here is a 600x600 pixel canvas example of what i hope to accomplish.

Texture image
Image

Caption text: WOW this is awesome

The output would be something like this.
Image

Could this be done ? I hope it's possible to accomplish this with imagemagick :D

Version: ImageMagick 6.7.7-10 2016-11-29 Q16 on Ubuntu

Thanks so much for any help and pointing me in the right direction.
Version: ImageMagick 6.9.7-4 Q16 x86_64 20170114 | Ubuntu 18.04.1 LTS
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Textured text on fixed width & height canvas

Post by snibgo »

v6.7.7 is very old. I suggest you upgrade.

Windows BAT syntax:

Code: Select all

%IM%convert ^
  texture2.jpg ^
  ( -clone 0 -fill White -colorize 100 ) ^
  ( -size 600x600 -gravity center -fill Black ^
    caption:"WOW\nthis is\nawesome" ) ^
  -composite ^
  w.png
For bash, escape the parentheses to \( and \), and change lines-ends from ^ to \.
snibgo's IM pages: im.snibgo.com
robocop
Posts: 32
Joined: 2013-03-22T23:15:09-07:00
Authentication code: 6789

Re: Textured text on fixed width & height canvas

Post by robocop »

snibgo wrote: 2017-02-21T09:02:09-07:00 v6.7.7 is very old. I suggest you upgrade.

Windows BAT syntax:

Code: Select all

%IM%convert ^
  texture2.jpg ^
  ( -clone 0 -fill White -colorize 100 ) ^
  ( -size 600x600 -gravity center -fill Black ^
    caption:"WOW\nthis is\nawesome" ) ^
  -composite ^
  w.png
For bash, escape the parentheses to \( and \), and change lines-ends from ^ to \.

Thank you so much snibo. It works very well.

I'm just having 1 small final issue. I am using a lot of calligraphy style fonts and the caption in many cases extends beyond the bounding box.

I've looked everywhere and haven't had much luck in solving this.

I've attached an example using the Marguaritas font:
http://www.dafont.com/marguaritas.font
Image

If there was a way to add some padding to the edges, it would be great though.

I will upgrade my version as you advised. Thanks very much.
Version: ImageMagick 6.9.7-4 Q16 x86_64 20170114 | Ubuntu 18.04.1 LTS
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Textured text on fixed width & height canvas

Post by snibgo »

IM's automatic calculation of the pointzize doesn't work on that font. An upgrade may cure the problem. If it doesn't, you can do an automatic pointsize and find what IM has used, then use (say) 90% of that pointsize, or a larger image size.
snibgo's IM pages: im.snibgo.com
robocop
Posts: 32
Joined: 2013-03-22T23:15:09-07:00
Authentication code: 6789

Re: Textured text on fixed width & height canvas

Post by robocop »

Hi snibgo

Thank you so much for your advise and help! We basically changed the font and all is great. Many Thanks again :)
Version: ImageMagick 6.9.7-4 Q16 x86_64 20170114 | Ubuntu 18.04.1 LTS
Post Reply