Search code examples
imagemagickimage-manipulation

Extend image with blurred frame using ImageMagick?


I'd like to make certain images larger by adding a blurred frame (consisting of the image itself). Would like to do that using ImageMagick.

Sort of like what https://pinetools.com/blurred-frame-images-generator does.

Source image

Larger image

How to do that?

Searched Google for hints, but didn't really find something…

Found Blur image with ImageMagick and extent it and this command:

convert original.png -background none -gravity center -extent 200x200% -blur ... -trim result.png

But I guess I'm doing something wrong. When I run that command, the result.png looks identical to "original.png".

result.png


Solution

  • Something along these lines maybe?

    • open the image
    • in some "aside-processing" clone the original, enlarge and blur it
    • back in the mainline processing, put the enlarged, blurred image to the back of the depth stacking order, and composite the original over the blurred one with aligned centres

    magick tour.jpg \( +clone -resize 150% -blur x10 \) +swap -gravity center -composite  result.jpg
    

    enter image description here


    For my money, I'd darken the background a little too in order to make it less distracting:

    magick tour.jpg \( +clone -resize 150% -blur x20 -fill black -colorize 25% \) +swap -gravity center -composite  result.jpg
    

    enter image description here