OrchardCMS / Orchard

Orchard is a free, open source, community-focused Content Management System built on the ASP.NET MVC platform.
https://orchardproject.net
BSD 3-Clause "New" or "Revised" License
2.38k stars 1.12k forks source link

ImageResizer exception on large TIFF image files #3844

Open orchardbot opened 11 years ago

orchardbot commented 11 years ago

bsdr created: https://orchard.codeplex.com/workitem/20016

Version 1.7 MediaProcessing

To reproduce:

Upload a TIFF image file larger than 3200 pixels in at least one dimension.

Create a Media Profile 'Thumbnail' with two filters:

JPG output with quality 90

Resize to 200 x 200 pixels

Display the file using @Display.MediaUrl(Profile: "Thumbnail", Path: Model.ContentItem.Contact.Picture.Url)

Open the log file to see the exception:

2013-08-12 16:30:55,982 [22] Orchard.MediaProcessing.Shapes.MediaShapes - An error occured while rendering shape Lightbox for image /OrchardLocal/Media/Default/Stamps%20of%20Australia/ClaytonTremlett244.tif ImageResizer.Plugins.Basic.SizeLimits+SizeLimitException (0x80004005): The dimensions of the output image (2668x3364) exceed the maximum permitted dimensions of 3200x3200.

Why is this exception throwing? The request is for an image that is 200x200 pixels, which is way less than 3200x3200.

BTW. If I drop filter 1 (JPG quality 90). It works fine.

orchardbot commented 11 years ago

@bleroy commented:

Maybe resize first, then change to JPG? The pipeline has to go through your steps in order... So the output of the first step is larger than the max size. Sounds perfectly normal to me.

orchardbot commented 11 years ago

bsdr commented:

Yes that worked. Thanks Bertrand -- didn't see the up and down labels and didn't realize it was a pipeline.

orchardbot commented 11 years ago

bsdr commented:

First, this should not be a pipeline: both 'filters' should be incorporated into a single call to ImageResizer. Secord, if this can't be done for some reason, format/quality filters should always execute after resize requests and the user should have no control over sequence. Third, format/quality filters are not very useful with TIFF source files as ImageResizer converts TIFF to JPG anyway.

orchardbot commented 11 years ago

bsdr commented:

A pipeline will also reduce image quality, as explained here by Nathanael Jones (author of ImageResizer): http://stackoverflow.com/questions/18184309/how-to-turn-off-imageresizer-file-size-limit-in-orchard/18197337?noredirect=1#comment26702178_18197337

orchardbot commented 11 years ago

bsdr commented:

OK, I have done a few tests. ImageResizer does NOT automatically convert to jpg as I suggested above, it simply creates a smaller TIFF. So that means minimal artifacts, and any subsequent conversion to JPG will look OK, as indeed it does. So the only issue with TIFF originals is that a pipeline is inefficient. HOWEVER, if I start from a JPEG original then I do get artifacts because of the multiple lossy compressions.

The bottom line for me is that there is no requirement for an image pipeline as implemented in the MediaProcessing Module, and this will cause inefficiency and possibly artifacts with JPG originals. ImageResizer presumably has it's own internal 'pipeline'. Why not leverage that instead of reimplementing pipeline processing in Orchard?

I suggest that you add 'Output Format' and 'Output Quality' to the Resize Filter, dispense with the Format filter, and limit to one filter.

orchardbot commented 11 years ago

bsdr commented:

OK I was wrong to assume I was wrong. See also issue 20019