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

Monday, September 19, 2022

[FIXED] How might I achieve this blurred text-outline effect with ImageMagick?

 September 19, 2022     imagemagick, imagick, php     No comments   

Issue

https://thumb7.shutterstock.com/display_pic_with_logo/1517996/1106095757/stock-photo-photographer-silhouette-people-make-a-photo-of-nature-landscape-for-photostocks-and-social-networks-1106095757.jpg

I'm interested in creating a similar effect for watermarking images on my site.

I need to generate it on the fly as the text in the middle would be different on each photo, so I can't use a precomposed png file.

I'm not bothered about the exact font (I have one I'm happy with), but how can I go about adding a nicely blurred outline around it like they have?

I tried using gaussianBlurImage but it doesn't work on an ImagickDraw object. Do I need to compose my ImagickDraw onto an Imagick object first, then blur it, then compose it onto the main image?

Or are there some clever ImagickDraw functions I can use that I've not discovered yet?

Thanks


Solution

You can do that in ImageMagick, by creating a transparent background and adding text via label: using black text with a white stroke and then reducing the opacity. Then composite that latter onto your original.

Original:

enter image description here

convert image.jpg \( -background none -pointsize 64 -fill black -strokewidth 2 -stroke white -font arial -gravity center label:"stockphoto" -channel a -evaluate multiply 0.33 +channel \) -gravity center -geometry +0+50 -compose over -composite result.jpg

enter image description here



Answered By - fmw42
Answer Checked By - Mildred Charles (PHPFixing Admin)
  • 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