Skip to content

Instantly share code, notes, and snippets.

@kinglozzer
Created January 23, 2014 12:58
Show Gist options
  • Save kinglozzer/8578092 to your computer and use it in GitHub Desktop.
Save kinglozzer/8578092 to your computer and use it in GitHub Desktop.
<?php
class CustomGDBackend extends GDBackend {
public function watermark() {
$newGD = imagecreatetruecolor($width, $height);
// Do image watermark stuff here. The current image resource is $this->gd
imagecopyresampled($newGD, $this->gd, 0, 0, $left, $top, $width, $height, $width, $height);
$output = clone $this;
$output->setImageResource($newGD);
return $output;
}
}
<?php
class WatermarkedImage extends Image {
private static $backend = "CustomGDBackend";
public function generateWatermarkedImage(Image_Backend $backend, $angle, $width, $height) {
return $backend->rotate($angle)->croppedResize($width, $height)->watermark();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment