Source of file ImageExtension.php
Size: 2,802 Bytes - Last Modified: 2021-12-23T10:11:22+00:00
/var/www/docs.ssmods.com/process/src/code/ImageExtension.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 | <?php /** * ImageExtension.php. * * @author Quinn Interactive, Inc. */ /** * StartGeneratedWithDataObjectAnnotator * * @property Image|ImageExtension $owner * * EndGeneratedWithDataObjectAnnotator */ class ImageExtension extends DataExtension { # added to make sure thumbnail shows up in UploadField private static $summary_fields = array( 'StripThumbnail' => 'Thumbnail', 'Name' => 'Name', 'Title' => 'Title', ); /** * Resizes and crops an image to the top of the image. * * @param $width * @param $height * * @return Image */ public function TopCroppedImage($width, $height) { return $this->owner->getFormattedImage('TopCroppedImage', $width, $height); } /** * @param object $gd * @param unknown $width * @param unknown $height * * @return unknown */ public function generateTopCroppedImage(Image_Backend $backend, $width, $height) { # resize $backend = $backend->resizeByWidth($width); # crop to top $backend = $backend->crop(0, 0, $width, $height); return $backend; } public function Ratio() { return $this->owner->getWidth() / $this->owner->getHeight(); } public function RatioPercent() { return $this->owner->getWidth() / $this->owner->getHeight() * 100; } public function InvertedRatio() { return $this->owner->getHeight() / $this->owner->getWidth(); } public function InvertedRatioPercent() { return $this->owner->getHeight() / $this->owner->getWidth() * 100; } public function RatioLessThan($ratio) { return $this->Ratio() < $ratio; } public function RatioGreaterThan($ratio) { return $this->Ratio() > $ratio; } public function WiderThan($width) { return $this->owner->getWidth() > $width; } public function WiderThanOrEqual($width) { return $this->owner->getWidth() >= $width; } public function TallerThan($height) { return $this->owner->getHeight() > $height; } public function TallerThanOrEqual($height) { return $this->owner->getHeight() >= $height; } public function Rotate($degrees) { return $this->owner->getFormattedImage('RotateClockwise'); } public function generateRotate(GD $gd, $degrees = 90) { return $gd->rotate($degrees); } public function SetQuality($quality) { return $this->owner->getFormattedImage('QualityVariantImage', $quality); } public function generateQualityVariantImage(Image_Backend $backend, $quality) { $new = clone $backend; $new->setQuality($quality); return $new; } } |