from wand.image import Image
from wand.api import library
with Image(filename='wizard:') as img:
# Grab image size
cols, rows = img.size
# Define our target location ... say 1/3rd, by 1/5th
tx, ty = int(cols * 0.33), int(rows * 0.2)
# Find middle of the image.
mx, my = cols // 2, rows // 2
# Roll target coord into middle
ok = library.MagickRollImage(img.wand, mx-tx, my-ty)
if not ok:
img.raise_exception()
# Implode
img.implode(0.5)
# Roll middle back into place.
ok = library.MagickRollImage(img.wand, mx+tx, my+ty)
if not ok:
img.raise_exception()
# done
img.save(filename='output.png')
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter