PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, September 19, 2022

[FIXED] How to overlay transparent text with background on picture?

 September 19, 2022     imagemagick, imagemagick-convert, imagick     No comments   

Issue

I have a background picture. Now I want to draw a rounded rectangle with a text shaped hole on it. Do I have to draw a mask pic first?


Update: I want the picture show through the text, but not the rounded rectangle. My convert command version is 6.9.7, on Linux.


Solution

Sorry, I am still not sure I understand what you want for the round rectangle. But here is one method that computes a white round rectangle, puts transparent text in it, then overlays that on the lena background image.

convert \( -size 150x150 xc:white \) \
\( +clone  -alpha extract \
-draw 'fill black polygon 0,0 0,15 15,0 fill white circle 15,15 15,0' \
\( +clone -flip \) -compose Multiply -composite \
\( +clone -flop \) -compose Multiply -composite \
\) -alpha off -compose CopyOpacity -composite \
\( -size 100x100 -background none -fill white -gravity center \
-pointsize 36 -font arial label:"TEST"  \) \
-gravity center -compose dstout -composite -alpha on \
lena.png +swap -compose over -composite tmp.png

enter image description here



Answered By - fmw42
Answer Checked By - Terry (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing