Skip to content

Instantly share code, notes, and snippets.

@teppokoivula
Created December 7, 2021 07:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save teppokoivula/6e1a2742a9a5a5701ea4b3b49d51f686 to your computer and use it in GitHub Desktop.
Save teppokoivula/6e1a2742a9a5a5701ea4b3b49d51f686 to your computer and use it in GitHub Desktop.
<?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