Created
January 23, 2014 12:58
-
-
Save kinglozzer/8578092 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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