-
Type: Feature Request
-
Status: Resolved
-
Priority: Minor
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: 5.2.2-B3
-
Component/s: Image Processing
-
Labels:None
-
Change Log Group:Added
-
Change Log Message:Allow specifying image quality, orientation and output format during resizing.
-
Story Points:2
-
Copy Issue Key:
-
Patch Instructions:
Plan (part 1 - support for "quality" option)
- in "ImageHelper::parseFormat" method parse "quality:X" format: - 0.5h
- the "X" is a number between 0 and 100
- when "X" happens to be something else throw an exception
- the "$res" array would initially contain array('quality' => 100)
- add protected "ImageHelper::convertQualityToCompression($quality)" method after "ImageHelper::ScaleImage" method that will: - 0.5h
- subtract value from 100 (when 60 is given it will become 40)
- divide by 10 and round it (the (100-65)/10 becomes 4)
- return the result
- in "ImageHelper::ScaleImage" method where "$write_function" is used to save file on disk: - 0.5h
- where "0" is used now (the PNG files) use result of "ImageHelper::convertQualityToCompression" method on "quality" parameter parsed before
- where "100" is used (everything else) use "quality" parameter parsed before
Plan (part 2 - support for "output_format" option):
- in "ImageHelper::parseFormat" method parse "output_format:X" format: - 0.5h
- the "X" is a string from this list: jpg, png, gif, bmp, auto
- when "X" happens to be something else throw an exception
- the "$res" array would initially contain array('output_format' => 'auto')
- in "ImageHelper::ScaleImage" method: - 0.5h
- after "$write_function" variable was defined create "$output_format_map" array, where:
- key is value for "output_format" option, except "auto"
- value is 2 last matching elements (also separated by colon) from $resize_map" array (e.g. "imagejpeg:jpg" value for "jpg" key and so on)
- if "output_format" option isn't "auto", then change "$write_function" and "$file_extension" variables to values extracted from "$output_format_map" array based on used "output_format" option value
- after "$write_function" variable was defined create "$output_format_map" array, where:
Plan (part 3 - support for "orientation" option):
- in "ImageHelper::parseFormat" method parse "orientation:X" format: - 0.5h
- the "X" is a string from this list: auto, manual, portrait, landscape
- when "X" happens to be something else throw an exception
- the "$res" array would initially contain array('orientation' => 'manual')
- add protected "ImageHelper::shouldRotateDimensions($src_image, $dst_width, $dst_height, array $params)" method, that will: - 0.5h
- store $params['orientation'] into $orientation variable
- if $orientation is "manual", then return "false"
- if $orientation is "auto", but only one of $dst_width/$dst_height is a number, then throw an exception
- if $orientation is "auto", then set $resized_orientation variable to orientation ("portrait" or "landscape") based on $dst_width and $dst_height variable values
- otherwise set $resized_orientation variable to value of $orientation variable (at this point it could be only "portrait" or "landscape")
- get image dimensions of "$src_image" image using "\ImageHelper::getImageInfo" method
- set $src_image_orientation variable to orientation ("portrait" or "landscape") of $src_image based on above retrieved image dimensions and store it into
- return true, when $src_image_orientation doesn't match $resized_orientation
- return false otherwise
- in "ImageHelper::ResizeImage" method, when "orientation" is not "manual" AND we're inside if ( !$this->isSVG($src_image) && ($params['max_width'] > 0 || $params['max_height'] > 0) ) { logic branch (as 1st thing): - 0.5h
- if "ImageHelper::shouldRotateDimensions" returns thrusy value, then:
- swap "$params['max_width']" and "$params['max_height']" values
- swap "$params['crop_x']" and "$params['crop_y']" values, but only when such keys exist
- if "ImageHelper::shouldRotateDimensions" returns thrusy value, then:
- blocks
-
INP-1847 Specify image resizing defaults for category item images
- Resolved
- is blocked by
-
INP-1775 Rename uploaded images to match their image type (when "storage_format" is used)
- Resolved
- relates to
-
INP-1708 Ignore crop/fill parameters during image resize, when they have no effect
- Resolved
- implemented in
-
[Diffusion] rINP16778 Fixes INP-1668 - Allow specifying image quality, orientation and output format…
-
D368 INP-1668 - Allow specifying image quality, orientation and output format during resizing
-
D368 INP-1668 - Allow specifying image quality, orientation and output format during resizing