Question T12799
Visible to All Users

Image compression and optimization

created 2 years ago

Hi,
What would be the best way to downsize images before storing it in the survey Json. Is there a hook to integrate any of the popular node image compression libraries?

Answers approved by surveyjs Support

created 2 years ago

Hello,
To decrease the image size before saving it to a survey JSON, you can handle the creator.onUploadFile event handler, obtain uploaded files from options.files, compress them (using a required third-party library, for example), and send the options.callback('success', 'base64-compressed-image) callback function.

The following demo shows an example of the creator.onUploadFile function usage: Manage Image Uploads.

I hope this information helps. Please let us know if you have any questions or require further assistance.