mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-04 01:01:41 +09:00
Separate image rotation check into its own method in FileHandler
This commit is contained in:
parent
42baab1c2c
commit
270f84abe9
2 changed files with 39 additions and 17 deletions
|
|
@ -485,6 +485,38 @@ class FileHandler
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if image needs rotation
|
||||
*
|
||||
* @param string $filename
|
||||
* @return int|bool 0, 90, 180, 360, or false
|
||||
*/
|
||||
public static function checkImageRotation(string $filename)
|
||||
{
|
||||
if (function_exists('exif_read_data'))
|
||||
{
|
||||
$exif = @exif_read_data($filename);
|
||||
if($exif && isset($exif['Orientation']))
|
||||
{
|
||||
switch ($exif['Orientation'])
|
||||
{
|
||||
case 3: return 180;
|
||||
case 6: return 270;
|
||||
case 8: return 90;
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves an image file (resizing is possible)
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue