BoldMinded acquires Ansel, support ending for all add-ons. BoldMinded acquires Ansel, support ending for all add-ons. Read More →
Support has been discontinued. Issues remain available as an archive. Support has been discontinued. Issues remain available as an archive.
The "quality" parameter seems to be ignored (in templates)
#224 opened by ometiclan
Description
According to the docs (https://www.buzzingpixel.com/software/ansel-ee/documentation/templating#onTheFlyCroppingAndResizing), I should be able to change the quality on the fly.
<img src="{img:url:resize quality='99'}">
<img src="{img:url:resize quality='10'}">
results in 2 different files with the exact same size. It doesn't matter if I also crop
or scale_up
. Width, Height, Crop all seem to work as intended.
The same seems to be true for the quality settings of the field itself. Changing quality from 1 to 100 results in the same filesize when uploading the same image again.
Edit: Tested with a new channel and a new field: Changing the field setting from 1 to 100 does work when an image is uploaded.
But trying to change the quality in the template:
img:url:resize quality="11"
img:url:resize quality="22"
img:url:resize quality="88"
img:url:resize quality="99"
will generate 4 images in _ansel_image_cache, but the quality / filesize does not change, they are all the same.
What am I doing wrong?
Also: It seems changing the quality and resizing is applied to the image that was uploaded and then saved again with the (initial) settings of the field itself. Yet the original image is also kept. Shouldn't resizing and changing quality be applied to the original image rather than the already modified image? Setting quality=100 in a template on an image that was reduced to quality = 50 by the field settings when uploaded seems pointless. If not, why do we keep the original image?
"[x] Keep original image" seems like a good option to prevent keeping files we don't actually need?
Replies
- ometiclan
Replied 3/6/2023 7:39 AM
In addition, the "Force JPEG" option in the field options yields very different results when checked compared to not-checked.
An image with roughly 1MB in size uploaded with field options quality set to "5" WITHOUT "Force JPEG" results in 1 original image (1MB) and 1 image with roughly 800KB size.
If "Force JPEG" is checked, the same upload will result in 1 original image (1MB) and a second image with about 50KB in size.The image already is a JPG.
50KB seems more likely at quality 5 than 800KB ... what am I missing here? - TJ Draper
Replied 4/22/2023 12:39 PM
It seems you found a bug that has almost certainly been present since the release of Ansel 2 in 2017.
There was a logic flaw in the code when using
Imagick
rather thanGD
(which Ansel prefers if it's installed) that did not set the quality parameter on theImagick
save process unlessforceJpg
was also used.This has been fixed in 2.3.3.
https://www.buzzingpixel.com/software/ansel-ee/changelog/2-3-3
https://www.buzzingpixel.com/software/ansel-ee/download
On the original image: The original image is always saved and never touched, which is necessary to preserve the edibility of the image. It is true that on-the-fly manipulations are applied to the saved image and that the saved image will have the quality that you've set in the field type. Therefore generational quality loss can occur. So you have to take that into account when setting things up.
- ometiclan
Replied 4/24/2023 3:22 AM
Thank you for the update and the explanation! :-)