mirror of
https://github.com/humhub/humhub.git
synced 2025-01-17 06:08:21 +01:00
Fix #4036: Uploaded photos are not rotated correctly
This commit is contained in:
parent
28e30ff566
commit
2ee4ad850b
@ -7,7 +7,7 @@ HumHub Change Log
|
|||||||
- Fix #4031: Notifications with non existing base model breaks notification list
|
- Fix #4031: Notifications with non existing base model breaks notification list
|
||||||
- Fix #4038: Cannot use yii\helpers\Html as Html because the name is already in use in ProfileBannerImage
|
- Fix #4038: Cannot use yii\helpers\Html as Html because the name is already in use in ProfileBannerImage
|
||||||
- Fix #4050: Broken Cron-job documentation link used in cron info sidebar snippet
|
- Fix #4050: Broken Cron-job documentation link used in cron info sidebar snippet
|
||||||
|
- Fix #4036: Uploaded photos are not rotated correctly
|
||||||
|
|
||||||
1.5.1 (April 19, 2020)
|
1.5.1 (April 19, 2020)
|
||||||
----------------------
|
----------------------
|
||||||
|
@ -79,17 +79,7 @@ class StorageManager extends Component implements StorageManagerInterface
|
|||||||
if (is_uploaded_file($file->tempName)) {
|
if (is_uploaded_file($file->tempName)) {
|
||||||
move_uploaded_file($file->tempName, $this->get($variant));
|
move_uploaded_file($file->tempName, $this->get($variant));
|
||||||
@chmod($this->get($variant), $this->fileMode);
|
@chmod($this->get($variant), $this->fileMode);
|
||||||
|
|
||||||
/**
|
|
||||||
* For uploaded jpeg files convert them again - to handle special
|
|
||||||
* exif attributes (e.g. orientation)
|
|
||||||
*/
|
|
||||||
if ($file->type === 'image/jpeg') {
|
|
||||||
Image::getImagine()->open($this->get($variant))->save($this->get($variant), ['format' => 'jpg']);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -81,6 +81,25 @@ class PreviewImage extends BaseConverter
|
|||||||
if (!is_file($this->file->store->get($fileName))) {
|
if (!is_file($this->file->store->get($fileName))) {
|
||||||
$image = Image::getImagine()->open($this->file->store->get());
|
$image = Image::getImagine()->open($this->file->store->get());
|
||||||
|
|
||||||
|
// Also handle orientation of resized images
|
||||||
|
// https://github.com/yiisoft/yii2-imagine/issues/44
|
||||||
|
if ($this->file->mime_type === 'image/jpeg' && function_exists('exif_read_data')) {
|
||||||
|
$exif = exif_read_data($this->file->store->get());
|
||||||
|
if (!empty($exif['Orientation'])) {
|
||||||
|
switch ($exif['Orientation']) {
|
||||||
|
case 3:
|
||||||
|
$image->rotate(180);
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
$image->rotate(90);
|
||||||
|
break;
|
||||||
|
case 8:
|
||||||
|
$image->rotate(-90);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($image->getSize()->getHeight() > $this->options['height']) {
|
if ($image->getSize()->getHeight() > $this->options['height']) {
|
||||||
$image->resize($image->getSize()->heighten($this->options['height']));
|
$image->resize($image->getSize()->heighten($this->options['height']));
|
||||||
}
|
}
|
||||||
@ -116,8 +135,8 @@ class PreviewImage extends BaseConverter
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated since 1.5
|
|
||||||
* @return int the image width or 0 if not valid
|
* @return int the image width or 0 if not valid
|
||||||
|
* @deprecated since 1.5
|
||||||
*/
|
*/
|
||||||
public function getWidth()
|
public function getWidth()
|
||||||
{
|
{
|
||||||
@ -128,8 +147,8 @@ class PreviewImage extends BaseConverter
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated since 1.5
|
|
||||||
* @return int the image height or 0 if not valid
|
* @return int the image height or 0 if not valid
|
||||||
|
* @deprecated since 1.5
|
||||||
*/
|
*/
|
||||||
public function getHeight()
|
public function getHeight()
|
||||||
{
|
{
|
||||||
@ -140,8 +159,8 @@ class PreviewImage extends BaseConverter
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated since 1.5
|
|
||||||
* @return ImageInterface
|
* @return ImageInterface
|
||||||
|
* @deprecated since 1.5
|
||||||
*/
|
*/
|
||||||
public function getImage()
|
public function getImage()
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user