Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use loadFromFile instead of loadFromFileHandle #34297

Merged
merged 1 commit into from
Feb 1, 2019

Conversation

sharidas
Copy link
Contributor

Use loadFromFile instead of loadFromFileHandle
while generating the thumbnail.

Signed-off-by: Sujith H [email protected]

Description

When loadFromFileHandle is used for generating thumbnail of images, the problem found is that it doesn't fix the orientation of images with exif. While loadFromFile handles this. It uses exif_imagetype before checking the mimetype of the image file. There is a word of caution noted in the https://github.com/owncloud/core/blob/master/lib/private/legacy/image.php#L496 ( reference: http://php.net/manual/en/function.exif-imagetype.php#79283 ). With the changeset the orientation issue while generating preview is resolved.

Related Issue

Motivation and Context

This changeset fixes the orientation issue of images while generating preview.

How Has This Been Tested?

  • Upload the image mentioned in the issue.
  • The image should be able to view properly ( just like any image viewers like gwenview etc ).

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Technical debt
  • Tests

Checklist:

  • Code changes
  • Unit tests added
  • Acceptance tests added
  • Documentation ticket raised:

Open tasks:

  • Backport (if applicable set "backport-request" label and remove when the backport was done)

Use loadFromFile instead of loadFromFileHandle
while generating the thumbnail.

Signed-off-by: Sujith H <[email protected]>
@sharidas sharidas self-assigned this Jan 29, 2019
@sharidas sharidas changed the title Use loadFromFile instead of loadFromFileHandle [WIP] Use loadFromFile instead of loadFromFileHandle Jan 29, 2019
@sharidas sharidas added this to the development milestone Jan 29, 2019
@codecov
Copy link

codecov bot commented Jan 29, 2019

Codecov Report

Merging #34297 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #34297      +/-   ##
============================================
+ Coverage     64.76%   64.77%   +<.01%     
  Complexity    18368    18368              
============================================
  Files          1199     1199              
  Lines         69550    69550              
  Branches       1281     1281              
============================================
+ Hits          45044    45050       +6     
+ Misses        24133    24127       -6     
  Partials        373      373
Flag Coverage Δ Complexity Δ
#javascript 53.09% <ø> (ø) 0 <ø> (ø) ⬇️
#phpunit 66.12% <100%> (ø) 18368 <0> (ø) ⬇️
Impacted Files Coverage Δ Complexity Δ
lib/private/Preview/Image.php 87.5% <100%> (ø) 5 <0> (ø) ⬇️
lib/private/legacy/image.php 48.06% <0%> (+1.15%) 170% <0%> (ø) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7201f89...dc922c1. Read the comment docs.

1 similar comment
@codecov
Copy link

codecov bot commented Jan 29, 2019

Codecov Report

Merging #34297 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #34297      +/-   ##
============================================
+ Coverage     64.76%   64.77%   +<.01%     
  Complexity    18368    18368              
============================================
  Files          1199     1199              
  Lines         69550    69550              
  Branches       1281     1281              
============================================
+ Hits          45044    45050       +6     
+ Misses        24133    24127       -6     
  Partials        373      373
Flag Coverage Δ Complexity Δ
#javascript 53.09% <ø> (ø) 0 <ø> (ø) ⬇️
#phpunit 66.12% <100%> (ø) 18368 <0> (ø) ⬇️
Impacted Files Coverage Δ Complexity Δ
lib/private/Preview/Image.php 87.5% <100%> (ø) 5 <0> (ø) ⬇️
lib/private/legacy/image.php 48.06% <0%> (+1.15%) 170% <0%> (ø) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7201f89...dc922c1. Read the comment docs.

@PVince81
Copy link
Contributor

seems to make sense, I was expecting something more complicated when I looked into this. It was probably because I took a different route based on git log / diff / bisect and tried to understand the commits that caused the regression.

if this fulfils all use cases as tested in the ticket, and doesn't cause additional performance impact (see local storage vs ext storage), then it should be fine

@sharidas sharidas changed the title [WIP] Use loadFromFile instead of loadFromFileHandle Use loadFromFile instead of loadFromFileHandle Jan 31, 2019
@jvillafanez
Copy link
Member

I guess to generate a preview we still need the whole file, even thought I'd still prefer to use streams...
Any idea how many changes are needed to use streams? If there are a lot of changes required, I'm fine with this solution.

@PVince81
Copy link
Contributor

PVince81 commented Feb 1, 2019

@jvillafanez I think we never used streams before because many of the PHP functions for image processing operate directly on files, like changing orientation. We definitely need to look into improving this, it might require searching for new libraries.

Copy link
Contributor

@PVince81 PVince81 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 looks good and thanks for the extensive tests in the original ticket

@PVince81 PVince81 merged commit ba74089 into master Feb 1, 2019
@delete-merged-branch delete-merged-branch bot deleted the fix-preview-image-orientation branch February 1, 2019 06:45
@PVince81
Copy link
Contributor

PVince81 commented Feb 1, 2019

@sharidas please backport

@sharidas
Copy link
Contributor Author

sharidas commented Feb 1, 2019

Backport to stable10 #34356

@lock lock bot locked as resolved and limited conversation to collaborators Feb 4, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

OC_Image doesn't always set imageType correctly
4 participants