Skip to content

Images take too much space #8469

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
paveq opened this issue Feb 8, 2017 · 10 comments
Closed

Images take too much space #8469

paveq opened this issue Feb 8, 2017 · 10 comments
Labels
bug report Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed

Comments

@paveq
Copy link
Contributor

paveq commented Feb 8, 2017

When adding images through Magento API, Magento pregenerates all defined downscaled versions for that image. While pregenerating downscaled versions is a good thing, it looks like Magento's default theme defines a LOT of differing image sizes.

Image sizes are defined here: https://github.com/magento/magento2/blob/develop/app/design/frontend/Magento/blank/etc/view.xml

Example of almost same size definitions:

<image id="recently_viewed_products_images_only_widget" type="small_image">
    <width>76</width>
    <height>76</height>
</image>
<image id="gift_messages_checkout_small_image" type="small_image">
    <width>75</width>
    <height>75</height>
</image>
<image id="mini_cart_product_thumbnail" type="thumbnail">
    <width>78</width>
    <height>78</height>
</image>

Surely there is no proper reason to generate almost equal downscaled versions of the same image? I would expect Magento to maintain maximum of 3-5 downscaled versions.

Preconditions

  1. Latest Magento CE installed

Steps to reproduce

  1. Add lot of images through API
  2. Observe sizes of media folders catalog/product and catalog/product/cache

Expected result

  1. Cache folder size is reasonable compared to size of originals

Actual result

  1. Depending on amount of images. Example in my case:
  • catalog/product 64G
  • catalog/product/cache 51G

Which means originals take 13G, and cached versions take 51G of disk space. There appears to be total of 34 generated versions of one image:

./0/image/400x400/beff4985b56e3afdbeabfc89641a4582/1/4/1426281_3.jpg
./0/image/700x560/beff4985b56e3afdbeabfc89641a4582/1/4/1426281_3.jpg
./0/image/beff4985b56e3afdbeabfc89641a4582/1/4/1426281_3.jpg
./0/image/700x700/beff4985b56e3afdbeabfc89641a4582/1/4/1426281_3.jpg
./0/image/285x285/beff4985b56e3afdbeabfc89641a4582/1/4/1426281_3.jpg
./0/image/265x265/beff4985b56e3afdbeabfc89641a4582/1/4/1426281_3.jpg
./0/swatch_image/30x20/beff4985b56e3afdbeabfc89641a4582/1/4/1426281_3.jpg
./0/swatch_thumb/110x90/beff4985b56e3afdbeabfc89641a4582/1/4/1426281_3.jpg
./0/small_image/165x165/beff4985b56e3afdbeabfc89641a4582/1/4/1426281_3.jpg
./0/small_image/76x76/beff4985b56e3afdbeabfc89641a4582/1/4/1426281_3.jpg
./0/small_image/270x340/beff4985b56e3afdbeabfc89641a4582/1/4/1426281_3.jpg
./0/small_image/75x90/beff4985b56e3afdbeabfc89641a4582/1/4/1426281_3.jpg
./0/small_image/152x190/beff4985b56e3afdbeabfc89641a4582/1/4/1426281_3.jpg
./0/small_image/113x113/beff4985b56e3afdbeabfc89641a4582/1/4/1426281_3.jpg
./0/small_image/240x300/beff4985b56e3afdbeabfc89641a4582/1/4/1426281_3.jpg
./0/small_image/75x75/beff4985b56e3afdbeabfc89641a4582/1/4/1426281_3.jpg
./0/small_image/270x270/beff4985b56e3afdbeabfc89641a4582/1/4/1426281_3.jpg
./0/small_image/100x100/beff4985b56e3afdbeabfc89641a4582/1/4/1426281_3.jpg
./0/small_image/140x140/beff4985b56e3afdbeabfc89641a4582/1/4/1426281_3.jpg
./0/small_image/270x207/beff4985b56e3afdbeabfc89641a4582/1/4/1426281_3.jpg
./0/small_image/135x135/beff4985b56e3afdbeabfc89641a4582/1/4/1426281_3.jpg
./0/small_image/78x78/beff4985b56e3afdbeabfc89641a4582/1/4/1426281_3.jpg
./0/small_image/285x285/beff4985b56e3afdbeabfc89641a4582/1/4/1426281_3.jpg
./0/small_image/110x160/beff4985b56e3afdbeabfc89641a4582/1/4/1426281_3.jpg
./0/thumbnail/152x188/beff4985b56e3afdbeabfc89641a4582/1/4/1426281_3.jpg
./0/thumbnail/76x76/beff4985b56e3afdbeabfc89641a4582/1/4/1426281_3.jpg
./0/thumbnail/200x248/beff4985b56e3afdbeabfc89641a4582/1/4/1426281_3.jpg
./0/thumbnail/75x90/beff4985b56e3afdbeabfc89641a4582/1/4/1426281_3.jpg
./0/thumbnail/75x75/beff4985b56e3afdbeabfc89641a4582/1/4/1426281_3.jpg
./0/thumbnail/100x100/beff4985b56e3afdbeabfc89641a4582/1/4/1426281_3.jpg
./0/thumbnail/88x110/beff4985b56e3afdbeabfc89641a4582/1/4/1426281_3.jpg
./0/thumbnail/140x140/beff4985b56e3afdbeabfc89641a4582/1/4/1426281_3.jpg
./0/thumbnail/78x78/beff4985b56e3afdbeabfc89641a4582/1/4/1426281_3.jpg
./0/thumbnail/90x90/beff4985b56e3afdbeabfc89641a4582/1/4/1426281_3.jpg

Note that eg. 75x75 pixels sized version is generated multiple times, for thumbnail and for small_image. Actual file content is 1:1 identical.

@hostep
Copy link
Contributor

hostep commented Feb 8, 2017

See #8145 for two suggested fixes for this problem (it's not exactly the same like what you are suggesting though).

@paveq
Copy link
Contributor Author

paveq commented Feb 8, 2017

This seems to be somewhat duplicate of #8145 although my report suggests reducing actual size combinations of blank/luma themes themselves. Since blank can be used as parent theme for custom themes, it's important that definitions there 1) make somewhat sense, 2) can be overwritten by custom theme.

@choukalos
Copy link

Tracking internally as - MAGETWO-60316

@paveq - is it safe to assume the problem is with blank/luma themes? Ie that a 3rd party theme developer wouldn't create more then 5 different image resizes in general?

@paveq
Copy link
Contributor Author

paveq commented Feb 9, 2017

@choukalos Yes, problem is with blank/luma and with themes based on them. Even if theme is not based on blank/luma, Magento will still generate images for them.

@maksek
Copy link
Contributor

maksek commented Feb 13, 2017

linking with existing PR, which doesn't resolve issue, but ignore themes are not assigned to stores - #8142

@magento-engcom-team magento-engcom-team added 2.0.x bug report Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed and removed G1 Passed labels Sep 5, 2017
@magento-engcom-team
Copy link
Contributor

@paveq, thank you for your report.
The issue is already fixed in 2.2.0

@paveq
Copy link
Contributor Author

paveq commented Oct 2, 2017

@magento-engcom-team How was this fixed? I still see blank theme defining a lot of image sizes that only slightly differ: https://github.com/magento/magento2/blob/2.2.0/app/design/frontend/Magento/blank/etc/view.xml

@paveq
Copy link
Contributor Author

paveq commented Oct 2, 2017

Tested on clean 2.2.0 by adding an image from admin. 35 versions were generated from the original.

Paavos-MacBook-Pro:media paveq$ find . -name test_image.png
./catalog/product/cache/0f831c1845fc143d00d6d1ebc49f446a/t/e/test_image.png
./catalog/product/cache/15dc7e9ba1a6bafcd505d927c7fcfa03/t/e/test_image.png
./catalog/product/cache/17adc37afef25a60cfde5800e2fea1bd/t/e/test_image.png
./catalog/product/cache/2b4546e5ba001f3aea4287545d649df0/t/e/test_image.png
./catalog/product/cache/2f067dfaa2eefc9cc6820ffd207e9866/t/e/test_image.png
./catalog/product/cache/2f58bf1051a2f0ceba166b720ec0a490/t/e/test_image.png
./catalog/product/cache/2f5bcdd08b6b861f73e29326ee14ef04/t/e/test_image.png
./catalog/product/cache/3bb5001b99d4c204f1708e92b30dda97/t/e/test_image.png
./catalog/product/cache/3cf5799449660ed39031217945ace72a/t/e/test_image.png
./catalog/product/cache/3f695f7dd477cbb47cd99d2622d93108/t/e/test_image.png
./catalog/product/cache/52b32f30e33927a7cf307075f5b7c020/t/e/test_image.png
./catalog/product/cache/633177f689f3c479eab7d48212fd720b/t/e/test_image.png
./catalog/product/cache/6633e7fcc9a7e88021adbe9a2450a512/t/e/test_image.png
./catalog/product/cache/75eed2686e01eb22cb4050b2f40ddf97/t/e/test_image.png
./catalog/product/cache/806d6fa663c29d159ca59727157b4a59/t/e/test_image.png
./catalog/product/cache/81ea8665b1d657e2313096e2818a187e/t/e/test_image.png
./catalog/product/cache/8a4e709a70e03bf31b178a318a79cf0e/t/e/test_image.png
./catalog/product/cache/900f44f0120b35eff596cbeba48e1c0a/t/e/test_image.png
./catalog/product/cache/914b1ba9268f8c1d0e58a8e7ce614488/t/e/test_image.png
./catalog/product/cache/926507dc7f93631a094422215b778fe0/t/e/test_image.png
./catalog/product/cache/9b0529d63c590f29ded60308ccd979ee/t/e/test_image.png
./catalog/product/cache/a2d2345650965cd6042e53fd7d716674/t/e/test_image.png
./catalog/product/cache/afad95d7734d2fa6d0a8ba78597182b7/t/e/test_image.png
./catalog/product/cache/c687aa7517cf01e65c009f6943c2b1e9/t/e/test_image.png
./catalog/product/cache/ccf7793e39f95beba8c329ba40e7df07/t/e/test_image.png
./catalog/product/cache/cdec6e528c16187a547aea54d9e1d6ee/t/e/test_image.png
./catalog/product/cache/ce2c090f9c3d4f35979d90b7dd274348/t/e/test_image.png
./catalog/product/cache/dca4079c45c8bedb9968e3d3d4e45631/t/e/test_image.png
./catalog/product/cache/ee4ee1fe1bbe32e9b93a354df94c32e2/t/e/test_image.png
./catalog/product/cache/f073062f50e48eb0f0998593e568d857/t/e/test_image.png
./catalog/product/cache/f485795eb4b45ff97c82d72651274f10/t/e/test_image.png
./catalog/product/cache/f4a2bc458ca2feecb5750446998dc347/t/e/test_image.png
./catalog/product/cache/f9c7fbe9b524c081a3ccf800cbd963eb/t/e/test_image.png
./catalog/product/cache/fd09478435d4f3d9e62d28584118149d/t/e/test_image.png
./catalog/product/cache/fd4c882ce4b945a790b629f572e4ef93/t/e/test_image.png
./catalog/product/t/e/test_image.png
Paavos-MacBook-Pro:media paveq$ find . -name test_image.png | wc -l
      36

@paveq
Copy link
Contributor Author

paveq commented Oct 2, 2017

In addition there being too many different sizes being generated, there's still separate issue of exactly same contents being generated multiple times:

Paavos-MacBook-Pro:media paveq$ find . -name test_image.png -print0 | xargs -0 md5sum | sort -n
a47e0f3b37f821396f090176b143a8e1  ./catalog/product/cache/cdec6e528c16187a547aea54d9e1d6ee/t/e/test_image.png
a47e0f3b37f821396f090176b143a8e1  ./catalog/product/cache/dca4079c45c8bedb9968e3d3d4e45631/t/e/test_image.png
b46f42409fb2775baa9e30b1c6812d34  ./catalog/product/cache/2f5bcdd08b6b861f73e29326ee14ef04/t/e/test_image.png
b46f42409fb2775baa9e30b1c6812d34  ./catalog/product/cache/f485795eb4b45ff97c82d72651274f10/t/e/test_image.png
b4c9a9d49b76517b36af22e8695d8f7b  ./catalog/product/cache/926507dc7f93631a094422215b778fe0/t/e/test_image.png
b4c9a9d49b76517b36af22e8695d8f7b  ./catalog/product/cache/afad95d7734d2fa6d0a8ba78597182b7/t/e/test_image.png
b4c9a9d49b76517b36af22e8695d8f7b  ./catalog/product/cache/c687aa7517cf01e65c009f6943c2b1e9/t/e/test_image.png
c1cef856e581384899ab91bdc5417169  ./catalog/product/cache/9b0529d63c590f29ded60308ccd979ee/t/e/test_image.png
c1e026be15aca2637b9be0a4e8999f8a  ./catalog/product/cache/633177f689f3c479eab7d48212fd720b/t/e/test_image.png
c28c5efd92c8002e1cda7b2ba8148e79  ./catalog/product/cache/914b1ba9268f8c1d0e58a8e7ce614488/t/e/test_image.png
c3ba3475c680ed742140b9481acfd42a  ./catalog/product/cache/8a4e709a70e03bf31b178a318a79cf0e/t/e/test_image.png
c3ba3475c680ed742140b9481acfd42a  ./catalog/product/cache/ee4ee1fe1bbe32e9b93a354df94c32e2/t/e/test_image.png
cbf05ca5715955c864cd544dd8667ac0  ./catalog/product/t/e/test_image.png
d5e96329a51bd0bab4b2140583c5f938  ./catalog/product/cache/2f067dfaa2eefc9cc6820ffd207e9866/t/e/test_image.png
d5e96329a51bd0bab4b2140583c5f938  ./catalog/product/cache/3cf5799449660ed39031217945ace72a/t/e/test_image.png
dbdff9bf94139e9ad67e75eb45f9f963  ./catalog/product/cache/15dc7e9ba1a6bafcd505d927c7fcfa03/t/e/test_image.png
dbdff9bf94139e9ad67e75eb45f9f963  ./catalog/product/cache/2b4546e5ba001f3aea4287545d649df0/t/e/test_image.png
dcc80c95e4a7351b86ab89661e206b1d  ./catalog/product/cache/2f58bf1051a2f0ceba166b720ec0a490/t/e/test_image.png
f511259edb0d2075db917ecbc86223d8  ./catalog/product/cache/6633e7fcc9a7e88021adbe9a2450a512/t/e/test_image.png
fb948a14ee2a19300248e4008ee49b67  ./catalog/product/cache/f073062f50e48eb0f0998593e568d857/t/e/test_image.png
01a4b5963bdd91d2a1cbb4c0fa61f926  ./catalog/product/cache/806d6fa663c29d159ca59727157b4a59/t/e/test_image.png
2af8bacf4eacd97851b1cf953bc58b8c  ./catalog/product/cache/75eed2686e01eb22cb4050b2f40ddf97/t/e/test_image.png
4bc63c3363740fabd71f598318acc60a  ./catalog/product/cache/ccf7793e39f95beba8c329ba40e7df07/t/e/test_image.png
4bc63c3363740fabd71f598318acc60a  ./catalog/product/cache/f4a2bc458ca2feecb5750446998dc347/t/e/test_image.png
7cf815989a7cc10c746dfb07d8662599  ./catalog/product/cache/3bb5001b99d4c204f1708e92b30dda97/t/e/test_image.png
8ade684d6bdb654acf1d60d48501998a  ./catalog/product/cache/ce2c090f9c3d4f35979d90b7dd274348/t/e/test_image.png
9f1d5f93ce6830214a7ed84c6f3bd6eb  ./catalog/product/cache/52b32f30e33927a7cf307075f5b7c020/t/e/test_image.png
67fde7e2d6ffa2d7efc0e001e34d83b3  ./catalog/product/cache/81ea8665b1d657e2313096e2818a187e/t/e/test_image.png
68bec310399390fa375a1a34d535badb  ./catalog/product/cache/f9c7fbe9b524c081a3ccf800cbd963eb/t/e/test_image.png
710a439c4fd4bd0a73486df22201bd4f  ./catalog/product/cache/fd09478435d4f3d9e62d28584118149d/t/e/test_image.png
710a439c4fd4bd0a73486df22201bd4f  ./catalog/product/cache/fd4c882ce4b945a790b629f572e4ef93/t/e/test_image.png
3325c7f2a07a52aeed87a8f003dffc1b  ./catalog/product/cache/17adc37afef25a60cfde5800e2fea1bd/t/e/test_image.png
4371ed0359cdd7948122e2c2c24164a1  ./catalog/product/cache/3f695f7dd477cbb47cd99d2622d93108/t/e/test_image.png
29835afdbff26bfd98ee31f4206e4856  ./catalog/product/cache/900f44f0120b35eff596cbeba48e1c0a/t/e/test_image.png
542554a4b2a420bb57553ac9143a9aac  ./catalog/product/cache/0f831c1845fc143d00d6d1ebc49f446a/t/e/test_image.png
7302632a2dd4db09138319f6b30e4bb8  ./catalog/product/cache/a2d2345650965cd6042e53fd7d716674/t/e/test_image.png

@ishakhsuvarov
Copy link
Contributor

Hi @paveq
I am closing this issue in favor of #8145
While reports may be somewhat different it is still the same problem which must be fixed for all cases at the same time.

Thank you for report and detailed investigation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed
Projects
None yet
Development

No branches or pull requests

8 participants