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); } }
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); } }
/*********************** *** 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(); // Export the file if (!$wm->generate(OUTPUT . 'test7.png')) {