Add Text to Image with White Transparent background

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
ckunchala
Posts: 7
Joined: 2020-01-29T11:08:28-07:00
Authentication code: 1152

Add Text to Image with White Transparent background

Post by ckunchala »

Hi Experts,

i'm new to Image Magick, i'm trying to find a command to achieve below use case,

Let's say, i have an image ocean.jpg, my requirement is,

1) i need to add one transparent white color on ocean.jpg
2) i need to add one text say, READ ME on the white transparent area
3) Text and white transparent area should be center of the image.

idea is, we need to see the text (READ ME) Properly irrespective of the color of Ocean.jpg.

any help ?

User avatar
fmw42
Posts: 26261
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Add Text to Image with White Transparent background

Post by fmw42 »

Please always provide your ImageMagick version and platform as syntax may differ.

Try this (the text will be blue and the white will be half transparent)

Unix Syntax:

Code: Select all

convert ocean.jpg \
-size 150x150 xc:"rgba(255,255,255,0.5)" \
-gravity center -compose over -composite \
-background none -fill blue -pointsize 24 label:"TESTING" \
-gravity center -compose over -composite \
ocean_test.jpg
If on ImageMagick 7, change convert to magick.

If on Windows replace the line ending \ with ^

See
https://imagemagick.org/script/color.php
https://imagemagick.org/Usage/text/#label
https://imagemagick.org/Usage/compose/#compose
https://imagemagick.org/Usage/layers/#convert


For novices, see
http://www.imagemagick.org/discourse-se ... f=1&t=9620
http://www.imagemagick.org/script/comma ... essing.php
http://www.imagemagick.org/Usage/reference.html
http://www.imagemagick.org/Usage/
https://github.com/ImageMagick/usage-markdown
https://imagemagick.org/script/porting.php#cli

ckunchala
Posts: 7
Joined: 2020-01-29T11:08:28-07:00
Authentication code: 1152

Re: Add Text to Image with White Transparent background

Post by ckunchala »

Thank you So much for your reply.

Actually this is my first post, so, i forgot to mention about version/os details.

i'm working on IM7 & SuseLinux.

The command worked for me, only change i have made is added "-font courier", as i have got an errror

magick: unable to read font `helvetica' @ error/annotate.c/RenderFreetype/1437


final command i have used is,

magick DI19_000000272-S.JPG -size 600x200 xc:"rgba(255,255,255,0.5)" -gravity center -compose over -composite -background none -fill black -font courier -pointsize 100 label:"PUMA\nDUPLICATE" -gravity center -compose over -composite result.jpg

Thanks a Million

Post Reply