Unexpected output: Affected paths: relative - resubmit patch.
⚙ D368 INP-1668 - Allow specifying image quality, orientation and output format during resizing
Page MenuHomeIn-Portal Phabricator

INP-1668 - Allow specifying image quality, orientation and output format during resizing
ClosedPublic

Authored by erik on Jun 14 2019, 9:29 AM.

Details

Summary

added new image format options

Test Plan

Preparations

In the themes\advanced\in-bulletin\elements\side_boxes\polls.elm.tpl template add below code at the beginning of poll_element element:

<img src="<inp2:Field name='Image' format='resize:480x640;crop:100|200;quality:10;orientation:auto'/>" border="0" alt="<inp2:Field field='Question'/>">
<img src="<inp2:Field name='Image' format='resize:x480;orientation:landscape'/>" border="0" alt="<inp2:Field field='Question'/>">
<img src="<inp2:Field name='Image' format='resize:x480;orientation:portrait'/>" border="0" alt="<inp2:Field field='Question'/>">
<img src="<inp2:Field name='Image' format='resize:640x480;output_format:png'/>" border="0" alt="<inp2:Field field='Question'/>">

<img src="<inp2:Field name='Image' format='resize:5000x5000;output_format:png'/>" border="0" alt="<inp2:Field field='Question'/>">
<img src="<inp2:Field name='Image' format='resize:5000x5000;output_format:jpg'/>" border="0" alt="<inp2:Field field='Question'/>">
<img src="<inp2:Field name='Image' format='resize:5000x5000'/>" border="0" alt="<inp2:Field field='Question'/>">

Testing

  1. Make sure In-Bulletin module is active and advanced theme is selected as default theme
  2. Go to Catalog & WebsitePolls section
  3. Create poll without answers, but with big enough (more than 640x480) landscape jpg image
  4. Go to front-end forums.html page
  5. Confirm, that 1st image shown is landscape, bad quality, cropped by horizontal axis 2x more, than by vertical
  6. Confirm, that 2nd image shown have height 480px
  7. Confirm, that 3rd image shown have width 480px
  8. Confirm, that 4th image shown is in png format
  9. Confirm, that 5th image (for this to work uploaded image must be less than 5000x5000) has png extension
  10. Confirm, that 6th image (for this to work uploaded image must be less than 5000x5000) has jpg extension
  11. Confirm, that 7th image (for this to work uploaded image must be less than 5000x5000) has jpg extension

Crash testing

In the themes\advanced\in-bulletin\elements\side_boxes\polls.elm.tpl template, in the code, added at the beginning of poll_element element, change requested format part value, refresh page and see result:

  1. Change quality to -5
  2. Confirm that exception "Quality value "-5" is out of 0..100 integer range." is thrown
  3. Change quality to 105
  4. Confirm that exception "Quality value "105" is out of 0..100 integer range." is thrown
  5. Change quality to 1.5
  6. Confirm that exception "Quality value "1.5" is out of 0..100 integer range." is thrown
  7. Change quality to 100
  8. Change output_format to tiff
  9. Confirm that exception "Output format value "tiff" is out of [jpg,png,gif,bmp,auto] range." is thrown
  10. Change output_format to png
  11. Change orientation to normal
  12. Confirm that exception "Orientation value "normal" is out of [auto,manual,portrait,landscape] range." is thrown
  13. Change orientation to portrait
  14. Where orientation is auto change resize to 480x
  15. Confirm that exception "Both width & height parameters must be specified." is thrown
  16. Where orientation is auto change resize to x640
  17. Confirm that exception "Both width & height parameters must be specified." is thrown
  18. Where orientation is auto set resize to 480x640

Diff Detail

Repository
rINP In-Portal
Branch
/in-portal/branches/5.2.x
Lint
Lint ErrorsExcuse: Full file re-formatting is not part of this task.
SeverityLocationCodeMessage
Errorcore/units/helpers/image_helper.php:37PHPCS.E.CodingStandard.Commenting.DocComment.TagValueIndentCodingStandard.Commenting.DocComment.TagValueIndent
Errorcore/units/helpers/image_helper.php:37PHPCS.E.CodingStandard.Commenting.FunctionComment.ParamCommentFullStopCodingStandard.Commenting.FunctionComment.ParamCommentFullStop
Errorcore/units/helpers/image_helper.php:37PHPCS.E.CodingStandard.Commenting.FunctionComment.ParamCommentNotCapitalCodingStandard.Commenting.FunctionComment.ParamCommentNotCapital
Errorcore/units/helpers/image_helper.php:38PHPCS.E.CodingStandard.Commenting.DocComment.NonParamGroupCodingStandard.Commenting.DocComment.NonParamGroup
Errorcore/units/helpers/image_helper.php:38PHPCS.E.CodingStandard.Commenting.FunctionComment.InvalidReturnCodingStandard.Commenting.FunctionComment.InvalidReturn
Errorcore/units/helpers/image_helper.php:38PHPCS.E.Generic.Files.LineLength.MaxExceededGeneric.Files.LineLength.MaxExceeded
Errorcore/units/helpers/image_helper.php:83PHPCS.E.CodingStandard.WhiteSpace.ControlStructureSpacing.SpaceBeforeCloseBraceCodingStandard.WhiteSpace.ControlStructureSpacing.SpaceBeforeCloseBrace
Errorcore/units/helpers/image_helper.php:83PHPCS.E.CodingStandard.WhiteSpace.ControlStructureSpacing.SpacingAfterOpenBraceCodingStandard.WhiteSpace.ControlStructureSpacing.SpacingAfterOpenBrace
Errorcore/units/helpers/image_helper.php:159PHPCS.E.Generic.Files.LineLength.MaxExceededGeneric.Files.LineLength.MaxExceeded
Errorcore/units/helpers/image_helper.php:279PHPCS.E.CodingStandard.Commenting.InlineComment.InvalidEndCharCodingStandard.Commenting.InlineComment.InvalidEndChar
Errorcore/units/helpers/image_helper.php:279PHPCS.E.CodingStandard.Commenting.InlineComment.NotCapitalCodingStandard.Commenting.InlineComment.NotCapital
Warningcore/units/helpers/image_helper.php:319PHPCS.W.CodingStandard.PHP.NoSilencedErrors.DiscouragedCodingStandard.PHP.NoSilencedErrors.Discouraged
Unit
No Unit Test Coverage
Build Status
Buildable 942
Build 942: arc lint + arc unit

Event Timeline

erik created this revision.Jun 14 2019, 9:29 AM
erik requested review of this revision.Jun 14 2019, 9:29 AM
erik edited the test plan for this revision. (Show Details)Jun 14 2019, 9:31 AM
alex requested changes to this revision.Jun 18 2019, 3:03 AM

In the themes\advanced\in-bulletin\elements\side_boxes\polls.elm.tpl change poll image output code to:

Please change this to:

In the `themes\advanced\in-bulletin\elements\side_boxes\polls.elm.tpl` template add below code at the beginning of `poll_element` element:

Right now it's not obvious what template fragment needs to be changed.

core/units/helpers/image_helper.php
38–42

Example for output_format and orientation options is missing.

57–59

Not covered in test plan.

64–68

Not covered in test plan.

73–77

Not covered in test plan.

154–156

Not covered in test plan.

654–660

Please combine error messages and conditions (if either of dimensions isn't specified, then exception).

This revision now requires changes to proceed.Jun 18 2019, 3:03 AM
alex added a project: Restricted Project.Jun 18 2019, 3:07 AM
erik edited the test plan for this revision. (Show Details)Jun 18 2019, 9:01 AM
erik edited the test plan for this revision. (Show Details)Jun 18 2019, 9:47 AM
erik marked 5 inline comments as done.Jun 18 2019, 10:10 AM
erik added inline comments.
core/units/helpers/image_helper.php
654–660

There is nothing to combine. This method is called only when at least one resize dimension is specified.

erik updated this revision to Diff 911.Jun 18 2019, 10:21 AM

Fixed thrown exceprion messages.

erik edited the test plan for this revision. (Show Details)Jun 18 2019, 10:22 AM
erik edited the test plan for this revision. (Show Details)
alex requested changes to this revision.Jun 19 2019, 3:00 AM
alex added inline comments.
core/units/helpers/image_helper.php
654–660

I've meant this change:

if ( $dst_width === '' || $dst_height === '' ) {
    throw new InvalidArgumentException('Both width & height parameters must be specified.');
}
This revision now requires changes to proceed.Jun 19 2019, 3:00 AM
erik updated this revision to Diff 912.Jun 19 2019, 7:52 AM
erik edited the test plan for this revision. (Show Details)

Combined error messages.

erik edited the test plan for this revision. (Show Details)Jun 19 2019, 7:53 AM
alex accepted this revision.Jun 20 2019, 10:03 AM
This revision is now accepted and ready to land.Jun 20 2019, 10:03 AM
alex updated this revision to Diff 919.Jul 11 2019, 12:14 PM

Fixed case, when "output_format" option was ignored, when image wasn't resized.

alex edited the test plan for this revision. (Show Details)Jul 11 2019, 12:22 PM
alex retitled this revision from INP-1668 Allow specifying image quality, orientation and output format during resizing to INP-1668 - Allow specifying image quality, orientation and output format during resizing.Aug 3 2022, 4:42 AM
This revision was landed with ongoing or failed builds.Nov 22 2023, 3:01 AM
This revision was automatically updated to reflect the committed changes.