Skip to content

Instantly share code, notes, and snippets.

@guoguolong
Created March 24, 2021 06:37
Show Gist options
  • Save guoguolong/afe1adac5f55e3cf791e8f659dcb9f88 to your computer and use it in GitHub Desktop.
Save guoguolong/afe1adac5f55e3cf791e8f659dcb9f88 to your computer and use it in GitHub Desktop.
compound images with Imagick libarary
<?php
$image_basedir = './';
$dude = new Imagick($image_basedir . 'images/photo.jpg');
$mask = new Imagick($image_basedir . 'images/frame.png');
$dude->setImageMatte(1);
$dude->compositeImage($mask, Imagick::COMPOSITE_DSTIN, 0, 0);
$dude->writeImage($image_basedir . 'mask.png');
<?php
$image_basedir = './';
$im = new Imagick($image_basedir . 'images/widget.jpg');
$album = new Imagick($image_basedir . 'images/bg.jpg');
// $im->rotated(....)
$album->compositeimage($im, Imagick::COMPOSITE_OVER, 10 ,20);
$album->writeImage($image_basedir . 'album.jpg');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment