2

When uploading new images to a product in Magento 2, it is not only decreasing the dimensions of the image, but it's increasing the image file size:

Image Details Before Upload

  • Dimensions: 1185 × 1580 px
  • File Size: 446 KB

After Upload

enter image description here

Can anybody explain why this is happening? I accept that some data may be added to the image by Magento, but I don't understand why it has been resized? Is there anywhere this can be changed?

EDIT

I've now discovered that the image dimensions have been set in vendor/magento/framework/File/Uploader.php

enter image description here

Next is to find the best way to change these values, I found this related post: Magento 2 change max image height and width of image uploader in Admin?

I still don't know why these dimensions have been imposed on users on M2. nor why the file size more than doubles in size!

1

2 Answers 2

0

In the end I created a new theme to override the following two files where the restriction was added:

  • vendor/magento/module-cms/view/adminhtml/templates/browser/content/uploader.phtml
  • vendor/magento/module-backend/view/adminhtml/templates/media/uploader.phtml

Within those files I hard coded the new max image sizes:

"maxWidth":3000,
"maxHeight":3000

This is the post I followed to achieve the override: https://magento.stackexchange.com/a/153968/191

Regarding the image file size I have not found a definitive answer as to why the size has more than doubled. This post had some insight however: https://stackoverflow.com/questions/14008524/why-smaller-png-image-takes-up-more-space-than-the-original-after-getting-resize

0

Now the max image size can be set at Stores > Settings > Configuration > Advanced > System > Images Upload Configuration

see https://docs.magento.com/user-guide/catalog/product-image-resizing.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.