Skip to content
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

Compression not working sometimes on Android devices. #308

Open
1 task done
Su-priya opened this issue Sep 5, 2024 · 1 comment
Open
1 task done

Compression not working sometimes on Android devices. #308

Su-priya opened this issue Sep 5, 2024 · 1 comment

Comments

@Su-priya
Copy link

Su-priya commented Sep 5, 2024

I am using the library to compress both videos and images. The compression behaviour is very inconsistent. Same image of size 2.10MB is compressed to 0.2MB sometimes, 1MB sometimes, and no compression at all and same size 2.10MB.

###Code snippet.
const imageResolution = JSON.parse(Config.get("IMAGE_RESOLUTION"));
const videoResolution = JSON.parse(Config.get("VIDEO_RESOLUTION"));
const imageQuality = Config.get("IMAGE_QUALITY");
const imageMax = Math.max(
Number(imageResolution.height),
Number(imageResolution.width),
);
const videoMax = Math.max(
Number(videoResolution.height),
Number(videoResolution.width),
);

let compressedPath = "";
if (type === "Videos") {
compressedPath = await Video.compress(
attachment.path,
{
compressionMethod: "auto",
minimumFileSizeForCompress: 2,
maxSize: videoMax, //The maximum size can be height in case of portrait video or can be width in case of landscape video
},
progress => {
if (progressCallback) {
progressCallback(progress);
}
},
);
} else if (type === "Images") {
compressedPath = await Image.compress(attachment.path, {
compressionMethod: "auto",
maxWidth: imageMax, //The maximum width boundary used as the main boundary in resizing a landscape image
maxHeight: imageMax, //The maximum height boundary used as the main boundary in resizing a portrait image
quality: imageQuality / 100, //This package takes quality value from 0 to 1
});

Platform

  • Android

React Native Version: 0.72.6

React Native Compressor Version: 1.8.22

Copy link

github-actions bot commented Sep 5, 2024

👋 @Su-priya
Thanks for opening your issue here! If you find this package useful hit the star🌟!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant