コード例 #1
0
ファイル: Watimage.php プロジェクト: elboletaire/watimage
// Usefull for cropping plugins like https://github.com/tapmodo/Jcrop
$wm = new Watimage($image);
$wm->crop(array('width' => 500, 'height' => 500, 'x' => 50, 'y' => 80));
if (!$wm->generate(OUTPUT . 'test6.png')) {
    // handle errors...
    print_r($wm->errors);
}
/***************************
 *** EVERYTHING TOGETHER ***
 ***************************/
$wm = new Watimage();
// Set the image
$wm->setImage($image);
// you can also set the quality with setImage, you only need to change it with an array: array('file' => $image, 'quality' => 70)
// Set the export quality
$wm->setQuality(80);
// Set a watermark
$wm->setWatermark(array('file' => $watermark, 'position' => 'center center', 'margin' => array('x' => -20, 'y' => 10), 'size' => 'full'));
// Resize the image
$wm->resize(array('type' => 'resize', 'size' => 400));
// Flip it
$wm->flip('horizontal');
// Now rotate it 30deg
$wm->rotate(30);
// It's time to apply the watermark
$wm->applyWatermark();
// Export the file
if (!$wm->generate(OUTPUT . 'test7.png')) {
    // handle errors...
    print_r($wm->errors);
}