コード例 #1
0
ファイル: flip.php プロジェクト: elboletaire/watimage
function flipImage($image, $mode, $output_image)
{
    $wm = new Watimage();
    $wm->setImage(array('file' => "files/{$image}", 'quality' => 90));
    // file to use and export quality
    $wm->flip($mode);
    if (!$wm->generate("results/{$output_image}")) {
        // handle errors...
        print_r($wm->errors);
    }
}
コード例 #2
0
ファイル: watermark.php プロジェクト: elboletaire/watimage
function applyWatermark($image, $watermark, $output_image)
{
    $wm = new Watimage();
    $wm->setImage(array('file' => "files/{$image}", 'quality' => 90));
    // file to use and export quality
    $wm->setWatermark(array('file' => "files/{$watermark}", 'position' => 'center'));
    // watermark to use and its position
    $wm->applyWatermark();
    // apply watermark to the canvas
    if (!$wm->generate("results/{$output_image}")) {
        // handle errors...
        print_r($wm->errors);
    }
}
コード例 #3
0
ファイル: Watimage.php プロジェクト: elboletaire/watimage
    print_r($wm->errors);
}
/***********************
 *** CROPPING IMAGES ***
 ***********************/
// 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();