IMagick Smooth Rounded Corners on QR Code??

IMagick is a native PHP extension to create and modify images using the ImageMagick API. ImageMagick Studio LLC did not write nor does it maintain the IMagick extension, however, IMagick users are welcome to discuss the extension here.
Post Reply
lordchapman
Posts: 3
Joined: 2012-03-09T03:14:06-07:00
Authentication code: 8675308

IMagick Smooth Rounded Corners on QR Code??

Post by lordchapman »

Hi There. I am currently using a median filter to create a rounded corners effect on a QR Code which results in this result:
QR With Median
QR With Median
qrCode-hwrfrgs-1331288078-X.png (12.58 KiB) Viewed 14185 times
But I need it to look like this:
QR Smooth
QR Smooth
unitag_qrcode.png (21.48 KiB) Viewed 14185 times
Nice and smooth corners. Whats the best way to achieve this?

Any help greatly appreciated!
lordchapman
Posts: 3
Joined: 2012-03-09T03:14:06-07:00
Authentication code: 8675308

Re: IMagick Smooth Rounded Corners on QR Code??

Post by lordchapman »

Can anyone help?
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: IMagick Smooth Rounded Corners on QR Code??

Post by Bonzo »

There was a similar question about this late last year. You could try searching the users and developers section. The code would need to be adapted to Imagick.
lordchapman
Posts: 3
Joined: 2012-03-09T03:14:06-07:00
Authentication code: 8675308

Re: IMagick Smooth Rounded Corners on QR Code??

Post by lordchapman »

Thanks for your reply!

Ive checked that out but it isnt very clear at all. Just wondered if someone could shed some more light on it..
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: IMagick Smooth Rounded Corners on QR Code??

Post by anthony »

You could try using a Morphology Close with a 'Disk' of the desired radius (not too big).

http://www.imagemagick.org/Usage/morphology/#close

however as you are using a white background you will need to use the 'complementary' method, Open
http://www.imagemagick.org/Usage/morphology/#Open

The examples shown in the above does not do the operation justice, but the Wikipedia page shows its effect on square corners.
http://en.wikipedia.org/wiki/Closing_%28morphology%29

Actually you may need to do both Close and Open to get the total overall effect, one to round off corners, the other to round of the bridges between diagonal points. Doing both is known as a 'Smooth' Morphological operation
http://www.imagemagick.org/Usage/morphology/#smooth
But you may need to re-order the operations for the white background.

Hey you wanted 'smooth'!... Well their you go. "Smooth" is the name of the operation!


Of course please report on how sucess or failure.


PS: a more general problem like this can be made to the Users forum. With perhaps a copy of the original image!

Others will then try out things and show you results, typically using the command line API. Translating the Shell API back to IMagick API on the other hand is a different matter.

I do not know if IMagick API is up-to-date enough to have access to the morphology methods, but thw MagickWand API is.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply