Reduce the weight of an uploaded photo (client side)

Hello,
I would like that when we upload an image, that it automatically reduces to 1200px wide max (and its height in proportion to its original size) and 72 dpi if it is larger than that. This in order to limit the weight thereafter (because it would be an online game and there would be many images). Is there a function for this?
I have attached a starting file as an attachmentweight-picture.hype.zip (70.6 KB)

  1. You could also use some batch resize tool on your export folder once you exported.

  2. Or you could resize them before importing them like the rest of us :wink:

  3. You could use a service like Cloud Image but it costs some money and introduces a CDN. That service allows manipulating images on the fly and I wrote an extension that does that in Hype. A little code to set the width is needed.

Yes indeed I could resize them before;) But it is for the use of exported doc online and it crashes on mobile device (and to avoid customers having to resize their pictures). I saw this: https://stackoverflow.com/questions/2434458/image-resizing-client-side-with-javascript-before-upload-to-the-server#:~:text=You%20can%20use%20a % 20javascript, the% 20image% 20to% 20the% 20server. & Text = Basically% 20I% 20use% 20the% 20method, blob% 20 (using% 20the% 20method% 20image.
and I tried to apply it in this new document (witch is in attachment. It works on computer but it crashes again on smartphone…weight-picture-2.hype.zip (70.9 KB)

It crashes because lots of pictures and not enough power on a smartphone
(not on this doc precisely because it remains simple => not many pictures to upload). Do you have a solution ? :slight_smile:

Yes, see Reduce the weight of an uploaded photo (client side) bullet points 1. and 3.

ok I’ll watch it all, thank you :). I was hoping that a function placed on the hype doc before exporting would do the job :wink:

You can write an export script …


… and use a shell script or Python to-do some post preview/export optimization.

Thank you for this additional information :slight_smile: