Advertisement:

Author Topic: Image rotation issue when using ImageMagick  (Read 441 times)

jazepsmalta

  • Newbie
  • *
  • Posts: 19
Image rotation issue when using ImageMagick
« on: April 03, 2019, 08:56:45 pm »
Image rotation issue when using ImageMagick

I am using ImageMagick library on my website,
Unfortunately after image upload from mobile phones it rotates some images.


Is there a solution to this problem?


dev101

  • Osclass Hero
  • Hero Member
  • *
  • Posts: 2155
  • osclass.work
Re: Image rotation issue when using ImageMagick
« Reply #1 on: April 04, 2019, 01:17:31 am »
Please, upload some ORIGINAL sample images here or on some server (archive them into .zip if you wish, just don't process them in any photo editor or through other app).

jazepsmalta

  • Newbie
  • *
  • Posts: 19
Re: Image rotation issue when using ImageMagick
« Reply #2 on: April 04, 2019, 06:48:30 pm »
Please, upload some ORIGINAL sample images here or on some server (archive them into .zip if you wish, just don't process them in any photo editor or through other app).

I uploaded original image in zip format on google drive,

Thumbnail images - displayed normally, without turning
Normal size images - turns on 90 degrees.

https://drive.google.com/open?id=1J1JVMB1K7eRwW0C2XTqIrp7-f14KjD9g

« Last Edit: April 04, 2019, 07:03:06 pm by jazepsmalta »

jazepsmalta

  • Newbie
  • *
  • Posts: 19
Re: Image rotation issue when using ImageMagick
« Reply #3 on: April 07, 2019, 09:52:03 pm »
really, nobody faced such problem?

dev101

  • Osclass Hero
  • Hero Member
  • *
  • Posts: 2155
  • osclass.work
Re: Image rotation issue when using ImageMagick
« Reply #4 on: April 08, 2019, 12:47:09 am »
This image is in Apple HEIC format, I am not sure what is happening during upload/conversion on your server. I assume phone recognizes that there is no support for it, and then serves JPEG equivalent. Because, as it is now, Osclass does not support anything beyond GIF, PNG and common JPEG. Will investigate this in my spare time.

edit: as expected, this is invalid extension, and it cannot be examined and work upon directly now, because it is not supported.

Code: [Select]
IMG_0396.HEIC has an invalid extension. Valid extension(s): png, gif, jpg, jpeg.
What happens during image conversion and serving in the phone (at least, this is my best guess), is beyond my research ability right now.
« Last Edit: April 08, 2019, 12:52:21 am by dev101 »

jazepsmalta

  • Newbie
  • *
  • Posts: 19
Re: Image rotation issue when using ImageMagick
« Reply #5 on: April 08, 2019, 01:13:19 am »
This image is in Apple HEIC format, I am not sure what is happening during upload/conversion on your server. I assume phone recognizes that there is no support for it, and then serves JPEG equivalent. Because, as it is now, Osclass does not support anything beyond GIF, PNG and common JPEG. Will investigate this in my spare time.

edit: as expected, this is invalid extension, and it cannot be examined and work upon directly now, because it is not supported.

Code: [Select]
IMG_0396.HEIC has an invalid extension. Valid extension(s): png, gif, jpg, jpeg.
What happens during image conversion and serving in the phone (at least, this is my best guess), is beyond my research ability right now.

dev101  this happens only when i turn on ImageMagick. If i use GD library, there is no such problem. but the quality of uploaded photos is very bad when using this library "GD library". In ImageMagick uploaded photos are little better.

Is it possible to change the quality of uploaded photos?








dev101

  • Osclass Hero
  • Hero Member
  • *
  • Posts: 2155
  • osclass.work
Re: Image rotation issue when using ImageMagick
« Reply #6 on: April 08, 2019, 01:41:09 am »
Again, this needs to be examined in detail, the whole chain of events. Yes, we can increase quality, but default one should be fine, unless something very wrong is going on. It's a new format, it is not supported out of the box, and I have few ideas/theories of what is happening, none proven for a fact yet.

jazepsmalta

  • Newbie
  • *
  • Posts: 19
Re: Image rotation issue when using ImageMagick
« Reply #7 on: April 08, 2019, 11:30:54 am »
Again, this needs to be examined in detail, the whole chain of events. Yes, we can increase quality, but default one should be fine, unless something very wrong is going on. It's a new format, it is not supported out of the box, and I have few ideas/theories of what is happening, none proven for a fact yet.

I meant to improve the quality of uploaded photos for all formats, not only for Apple HEIC.  If we upload photos in JPG, then after processing they are pretty bad quality, I would like to keep the best possible. Thanks

dev101

  • Osclass Hero
  • Hero Member
  • *
  • Posts: 2155
  • osclass.work
Re: Image rotation issue when using ImageMagick
« Reply #8 on: April 10, 2019, 12:15:00 am »
I have investigated this issue, and on my server (PHP 7.2.16 or PHP 7.3.3 / imagick 3.4.3 / ImageMagick 6.9.4-10 Q16 x86_64) running more or less stock 3.80 with Bender theme (irrelevant), I had only issues with portrait images posted using ImageMagick. As in your heic example, it was captured with iPhone 7, so here is my test:

iPhone 7 / 7 Plus / plus few Android Phones
(Safari browser with iOS devices)

Quote

GD Library   |   with PreResize plugin  |   without PreResize plugin
landscape    |   no issue                       |   no issue
portrait         |   no issue                       |   no issue


Quote

IM Library   |   with PreResize plugin  |   without PreResize plugin
landscape    |   no issue                       |   no issue
portrait         |   no issue                       |   YES - ISSUE!


In ALL 4 test cases I have NOT experienced any quality issues you've encountered and described. Problem with autorotation is that it seems both ajax and later processing stages are rotating the image twice, which creates the problem. I am not sure, but that seems to be the most logical scenario according to my tests. Also, not sure how this slipped through before, maybe things changed... I need more samples and tests for this to draw a conclusion. In any case, core code is correct, nothing wrong with it, except this rotation issue.

I already have a fix for rotation problem, will post it later. Initial tests show that it is working.

Test examples from above compiled table are available (for a limited time) on my demo website (url under my profile), just so you can see that I'm telling the truth. You can see that beside rotation issue, quality does not suffer and I don't see any reason to change anything in that regard.

In case if you use preResize plugin by teseo, issue is not present in all cases (GD/IM).

My theory is that your theme uses very small thumbnails instead of larger images, and maybe that creates a problem for you.

Regards
dev101
« Last Edit: April 10, 2019, 01:23:28 am by dev101 »

jazepsmalta

  • Newbie
  • *
  • Posts: 19
Re: Image rotation issue when using ImageMagick
« Reply #9 on: July 06, 2019, 12:22:46 am »
I have investigated this issue, and on my server (PHP 7.2.16 or PHP 7.3.3 / imagick 3.4.3 / ImageMagick 6.9.4-10 Q16 x86_64) running more or less stock 3.80 with Bender theme (irrelevant), I had only issues with portrait images posted using ImageMagick. As in your heic example, it was captured with iPhone 7, so here is my test:

iPhone 7 / 7 Plus / plus few Android Phones
(Safari browser with iOS devices)

Quote

GD Library   |   with PreResize plugin  |   without PreResize plugin
landscape    |   no issue                       |   no issue
portrait         |   no issue                       |   no issue


Quote

IM Library   |   with PreResize plugin  |   without PreResize plugin
landscape    |   no issue                       |   no issue
portrait         |   no issue                       |   YES - ISSUE!


In ALL 4 test cases I have NOT experienced any quality issues you've encountered and described. Problem with autorotation is that it seems both ajax and later processing stages are rotating the image twice, which creates the problem. I am not sure, but that seems to be the most logical scenario according to my tests. Also, not sure how this slipped through before, maybe things changed... I need more samples and tests for this to draw a conclusion. In any case, core code is correct, nothing wrong with it, except this rotation issue.

I already have a fix for rotation problem, will post it later. Initial tests show that it is working.

Test examples from above compiled table are available (for a limited time) on my demo website (url under my profile), just so you can see that I'm telling the truth. You can see that beside rotation issue, quality does not suffer and I don't see any reason to change anything in that regard.

In case if you use preResize plugin by teseo, issue is not present in all cases (GD/IM).

My theory is that your theme uses very small thumbnails instead of larger images, and maybe that creates a problem for you.

Regards
dev101

Hello, dev101

Did you find any solution for issue ?

dev101

  • Osclass Hero
  • Hero Member
  • *
  • Posts: 2155
  • osclass.work

jazepsmalta

  • Newbie
  • *
  • Posts: 19
Re: Image rotation issue when using ImageMagick
« Reply #11 on: July 06, 2019, 03:34:24 pm »
« Last Edit: July 06, 2019, 03:40:29 pm by jazepsmalta »

jazepsmalta

  • Newbie
  • *
  • Posts: 19
Re: Image rotation issue when using ImageMagick
« Reply #12 on: July 06, 2019, 03:39:52 pm »
dev101,

I have another problem with photos, this question has already been asked many years ago, but is there any solution of this issue in osclass v. 3.8.0?
 
Here is a link to old topic.

https://forums.osclass.org/development/much-better-image-resize-smart-offset-no-white-space/

« Last Edit: July 06, 2019, 03:44:07 pm by jazepsmalta »