Created
December 7, 2021 07:51
-
-
Save teppokoivula/6e1a2742a9a5a5701ea4b3b49d51f686 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 namespace ProcessWire; | |
class ImageSizerEngineGDAlt extends ImageSizerEngineGD { | |
public static function getModuleInfo() { | |
return [ | |
'title' => 'GD Image Sizer (alternative version)', | |
'version' => 1, | |
'summary' => "Uses PHP’s built-in GD library to resize images (alternative version, see https://github.com/processwire/processwire-issues/issues/1154).", | |
]; | |
} | |
/** | |
* Check orientation (@horst) | |
* | |
* @param array | |
* | |
* @return bool | |
* | |
*/ | |
protected function checkOrientation(&$correctionArray) { | |
// first value is rotation-degree and second value is flip-mode: 0=NONE | 1=HORIZONTAL | 2=VERTICAL | |
$corrections = array( | |
'1' => array(0, 0), | |
'2' => array(0, 1), | |
'3' => array(180, 0), | |
'4' => array(0, 2), | |
'5' => array(90, 1), | |
'6' => array(90, 0), | |
'7' => array(270, 1), | |
'8' => array(270, 0) | |
); | |
if(!isset($this->info['orientation']) || !isset($corrections[strval($this->info['orientation'])])) { | |
return false; | |
} | |
$correctionArray = $corrections[strval($this->info['orientation'])]; | |
return true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment