React-native-image-crop-picker: Compress only when image is larger than a certain size?

Created on 25 Feb 2017  路  3Comments  路  Source: ivpusic/react-native-image-crop-picker

Version

Tell us which versions you are using:

  • react-native-image-crop-picker v0.11.2
  • react-native v0.37.0

Platform

Tell us to which platform this issue is related

  • iOS
  • Android

Is it possible to compress the image only when it is above a certain size?

Most helpful comment

+1

There is always maxSize limit in server side. If there is no such feature, we may use compressImageQuality to compress the original image, but how can we ensure that the compressed image size is always less than maxSize in server side?

Or could we expose a method for user to compress image like below?

ImagePicker.openPicker({
  compressImageQuality: 0.8,
  multiple: true
}).then(images => {
  images.forEach(image => {
    if (image.size > MAX_SIZE) {
      image = ImagePicker.newApiToCompressImageByUser(image);
    }
  });
  // ...
});

Or could we expose something like compressImageQuality but for size like compressImageMaxSize: 2 (2M)?

All 3 comments

currently not, but I would accept PR with such feature if you have some time

+1

There is always maxSize limit in server side. If there is no such feature, we may use compressImageQuality to compress the original image, but how can we ensure that the compressed image size is always less than maxSize in server side?

Or could we expose a method for user to compress image like below?

ImagePicker.openPicker({
  compressImageQuality: 0.8,
  multiple: true
}).then(images => {
  images.forEach(image => {
    if (image.size > MAX_SIZE) {
      image = ImagePicker.newApiToCompressImageByUser(image);
    }
  });
  // ...
});

Or could we expose something like compressImageQuality but for size like compressImageMaxSize: 2 (2M)?

@ivpusic this feature is very useful, now it has such feature???

Was this page helpful?
0 / 5 - 0 ratings