<?php include_once '../lib/ImageEditor.php'; // create destination image $dst = new ImageEditor(); // assing canvas size $dst->createCanvas(100, 200); /** * cut all4 centered to canvas size */ $src = new ImageEditor(); $src->loadImageFile('all4.jpg'); // fill destination image with source image // keeping destination canvas-size(100,200) $dst->fillin($src); // write the image $dst->writeImageFile('out1.jpg', ImageEditor::JPG, 75); /** * apply drift to kai(right 120) */ $src = new ImageEditor(); $src->loadImageFile('all4.jpg'); $dst->fillin($src, 120, 0); // write the image $dst->writeImageFile('out2.jpg', ImageEditor::JPG, 75); /** * apply drift to Anne (left -100) */ $src = new ImageEditor(); $src->loadImageFile('all4.jpg'); $dst->fillin($src, -100, 0);
/** * fill an area of image with another image, scaled and drifted * * @param ImageEditor $fillImg * @param int $x * @param int $y * @param int $width * @param int $height * @param int $driftX * @param int $driftY */ public function fillinArea(ImageEditor $fillImg, $x, $y, $width, $height, $driftX = 0, $driftY = 0) { // create a mask for area $maskImg = new ImageEditor(); $maskImg->createCanvas($width, $height); // fill mask $maskImg->fillin($fillImg, $driftX, $driftY); // drop masked image into image $this->dropin($maskImg, $x, $y); }
<?php include_once '../lib/ImageEditor.php'; $src = new ImageEditor(); $dst = new ImageEditor(); $dst->createCanvas(200, 400); $src->loadImageFile('kai_schwanger.jpg'); $dst->fillin($src, 0, 1000); $drop = new ImageEditor(); $drop->loadImageFile('ruth.jpg'); #$dst->dropin($drop, 20 ,50); $dst->fillinArea($drop, 10, 20, 100, 100); $dst->fillinArea($drop, 10, 350, 100, 100); #$src->rotate(90); #$dst->fitin($src); #$dst->applyGrayscale(); #$dst->pseudosepia(20); #$dst->sepia(60); #$dst->grayscale(); $dst->writeImageFile('out.jpg', ImageEditor::JPG, 75); #$src->writeImageFile('out.jpg', ImageEditor::JPG, 75); #$dst->displayImage('JPG');