Last active
December 15, 2015 03:38
-
-
Save azinkey/5195345 to your computer and use it in GitHub Desktop.
A simple way to set a frame with help of "Imagick"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Easiest way to set a frame (Image Magick Required) | |
* | |
* @name Image Composition(Set Frame) | |
* @author AZinkey | |
*/ | |
/********* Set Your World *************/ | |
// define directory seprator | |
define(DS, DIRECTORY_SEPARATOR); | |
// Get Root folder | |
$folder = realpath(dirname(__FILE__)) . DS; | |
/********* Configure File *************/ | |
//// Set image name | |
$size = '10x12'; // just think its diffrent frame | |
$space = 70; | |
$frame = $folder . $size.'.png'; | |
$main = $folder . 'art.jpg'; | |
///* Create new object */ | |
$imFrame = new Imagick($frame); | |
$imMain = new Imagick($main); | |
// Get Frame Dimension | |
$fD = $imFrame->getimagegeometry(); | |
$imMain->resizeimage($fD['width'] - ($space * 2), $fD['height'] - ($space * 2), NULL, 1, 0); | |
$imFrame->compositeimage($imMain, Imagick::COMPOSITE_DEFAULT, $space, $space); | |
// | |
//// save image | |
$imFrame->writeimage($folder.$size.'.jpg'); | |
//// display image | |
header("Content-type: image/jpg"); | |
echo $imFrame; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment