예제 #1
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';
// create destination image
$dst = new ImageEditor();
// assing canvas size
$dst->createCanvas(250, 200);
// filenames
$src1FileName = 'all4.jpg';
$src2FileName = 'bart.jpg';
$src3FileName = 'splash.jpg';
$src4FileName = 'water.jpg';
/**
 * drop the sourcefiles resized into destination image
 */
// src1
$src1 = new ImageEditor();
$src1->loadImageFile($src1FileName);
$dst->fillinArea($src1, 0, 0, 150, 100);
// src2
$src2 = new ImageEditor();
$src2->loadImageFile($src2FileName);
$dst->fillinArea($src2, 0, 100, 150, 100);
// src3
$src3 = new ImageEditor();
$src3->loadImageFile($src3FileName);
// apply drift of cropping mask to the left(x-direction)
$dst->fillinArea($src3, 150, 0, 100, 100, 50, 0);
// src4
$src4 = new ImageEditor();
$src4->loadImageFile($src4FileName);
<?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);
<?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');