filestack / filestack-js

Official Javascript SDK for the Filestack API and content ingestion system.
https://www.filestack.com
MIT License
206 stars 77 forks source link

Client side image compression and resize #23

Closed dmalexeev closed 7 years ago

dmalexeev commented 7 years ago

Is there any v3 analogue for v2 client side image compression and resize (imageMax: [width, height])?

filepicker.pickAndStore(
  {
    mimetype:"image/*",
    multiple: true,
    imageMax: [250, 250],    // Images bigger than the specified dimensions will be resized to the maximum size while maintaining the original aspect ratio.
  },
  {
    location:"S3"
  },
  function(Blobs){
    console.log(JSON.stringify(Blobs));
  },
  function(error){
  console.log(JSON.stringify(error)); - print errors to console
  }
);
velveteer commented 7 years ago

@dmalexeev At the moment there are no client-side transformations. All transformations are done through the Filestack processing engine. Currently in v3 you can use the maxDimensions option inside of transformations to specify analogous behavior to v2 imageMax-- except right now it will only apply to images passed through the transformation flow (crop, filters, etc.).

In any case this functionality is definitely on our roadmap for v2 parity. The use case you are describing, multiple images that each need to be resized before upload, should be covered eventually in v3. However it is likely compression and resizing will be done via the processing engine.

dmalexeev commented 7 years ago

@velveteer Thank you for quick answer. So I should use client.transform(url, options) function (https://www.filestack.com/docs/javascript-api/transform-v3) after upload to resize image?

velveteer commented 7 years ago

That's an option. But keep in mind that client.transform won't transform the image in place, it just returns a URL to the processed image.

velveteer commented 7 years ago

Just an update, we are now discussing the inclusion of client-side resizing and compression, and whether this will conflict with the current implementation.

velveteer commented 7 years ago

Please check out 0.8.0 as it includes new options for client-side image cropping and resizing.

ankkit101 commented 5 years ago

Hello dmalexeev can you help me for this solution. there i have also image resize before uplode. because in salesforce there 6 mb max size file support. and i have need to before uplode resize that image. can it possible to workflow. have other solution please give me.

dmalexeev commented 5 years ago

can you help me for this solution. there i have also image resize before uplode. because in salesforce there 6 mb max size file support. and i have need to before uplode resize that image. can it possible to workflow. have other solution please give me.

@ankkit101 you could use imageMax picker option for client side image resizing: https://filestack.github.io/filestack-js/interfaces/pickeroptions.html#imagemax