Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to soften edges of an image programmatically with PHP? [closed]

I'm looking for any solution to get QR Code with soft edge programmatically.

Any solution could be right. Post processing after QR Code generation or built in feature of any library.

like image 281
gsempe Avatar asked Aug 07 '11 21:08

gsempe


1 Answers

In PHP you can use GD library to perform some filtering on qrcode image, like smoothing and median (easy to implement) http://php.net/manual/en/function.imagefilter.php

This is what you need.. assuming $img is image of qrcode.

$i=10;
while($i--) 
imagefilter($img,IMG_FILTER_GAUSSIAN_BLUR);
imagefilter($img,IMG_FILTER_CONTRAST,-100);

After that use

header("Content-type: image/jpeg");
imagejpeg($img,null,100);

to send image to output.

Smooth qr code

There is one more thing - number of iteration of gaussian blur should depend on qr code point size. Maybe you can check in loop the darkest value, if it's not 0 then stop blurring.

like image 139
szamil Avatar answered Nov 14 '22 22:11

szamil