Unable to preserve image resolution

stromb0li

Well-known member
Affected version
2.3.7
In 2.3.x, it appears images are always resized client side prior to upload, even if under attachments, we set image optimization to "Do not optimize".

If I take a 300 dpi image that is about 20MB and upload, it is compressed down to about 2MB (which is great for those that don't want the original images), and then depending on your image processor, the DPI is stripped to the default value: it looks like the PHP built-in GD image library defaults to 96 dpi and Imagick defaults to 72 dpi upon upload; altering the photo.

Our use-case is we allow submission of photos for publication, but when uploaded via XenForo, the original file is altered.

Given we have "Do not optimize" enabled, our expectation is the client would not compress the image prior to upload and the original resolution / dpi of the image would be retained.
 
Last edited:
If you have size restrictions set, and it resizes the image, it also optimizes, I believe at 85%. So the file size will be a lot smaller based on size and optimization.
 
Per the HYS threads back when 2.3 was released, I also read this.
As a developer, if you wish to opt-out of this behaviour for any reason, you can do so with the following one-liner:

$upload->setImageOptimize(false);

I've tried the following and still see the image compressed to the 2.1MB filesize.

PHP:
...
    
                $upload = $this->request->getFile('upload', false, false);
                if ($upload)
                {
                    $upload->setImageOptimize(false);
                    $attachment = $manipulator->insertAttachmentFromUpload($upload, $error);
                    if (!$attachment) return $this->error($error);

...
 
Back
Top Bottom