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

Getting error while image compression. #19

Closed
krupalikevadiya opened this issue Jun 23, 2021 · 23 comments
Closed

Getting error while image compression. #19

krupalikevadiya opened this issue Jun 23, 2021 · 23 comments

Comments

@krupalikevadiya
Copy link

krupalikevadiya commented Jun 23, 2021

Please check below attached screenshot for more details and also i added my code.

Image.compress(path, {
maxWidth:width,
maxHeight:.height,
input: 'uri',
output: 'jpg',
quality: 0.5,
returnableOutputType: 'uri',
})
.then(async (compressedFileUri) => {
console.log('===========image compressed=============' + JSON.stringify(detail, null, 2))

        const detail = await getFileInfo(compressedFileUri);
      })
      .catch((e) => {
        console.log( '==============error in compression===================');
      });

Simulator Screen Shot - iPhone 12 Pro Max - 2021-06-23 at 18 08 02

@numandev1
Copy link
Owner

@krupalikevadiya did you install react-native-fs ?

@krupalikevadiya
Copy link
Author

No there is no any description to add react-native-fs in Readme. Anyway let me check by adding it.

@numandev1
Copy link
Owner

@krupalikevadiya this package is in progress. I will add a description or remove fs in the future.

@numandev1
Copy link
Owner

numandev1 commented Jun 28, 2021

@krupalikevadiya fixed in 0.5.2

@krupalikevadiya
Copy link
Author

krupalikevadiya commented Jul 6, 2021

Okk it is worked for image compression but does not for video compression.It gives same size of video after compression.
Even returned same path which i input to compress.

@numandev1
Copy link
Owner

@krupalikevadiya with compressionMethod: 'auto' you can achieve compression-like Whatsapp and Whatsapp cannot compress video have less than equal to 16MB. i will add this description in the readme so users know why we are not compressing below 16MB video in auto mode

if you wanna compress video which is below 16MB then you can use compressionMethod:'manual' prop

@krupalikevadiya
Copy link
Author

Yes i used this props but did not get compressed video. Here is my code.
const result = await Video.compress(
path,
{
compressionMethod:'manual',
bitrate:10,
},
(progress) => {

  }
);

Also here result is origional video url not compressed one.

@numandev1
Copy link
Owner

numandev1 commented Jul 6, 2021

@krupalikevadiya can you upload the video and share the link here so I can test it on my side

@krupalikevadiya
Copy link
Author

@krupalikevadiya
Copy link
Author

@nomi9995 any update on it?

@numandev1
Copy link
Owner

@krupalikevadiya I will check it when I am at the home. I will let you know after 5 hour

@krupalikevadiya
Copy link
Author

okay thanks for quick reply.

@numandev1
Copy link
Owner

@krupalikevadiya we are using NextLevelSessionExporter pod for compression videos on ios. but on this video, it is giving an exception, therefore, I am returning the same URI. I have created issue on
NextLevel/NextLevelSessionExporter#37
we have to wait for resolve issue from NextLevelSessionExporter size

@krupalikevadiya
Copy link
Author

okk thanks and let me know once it is resolved...same thing happen in android to.

@numandev1
Copy link
Owner

@krupalikevadiya sure. can you send me a reproducible example for android?

@krupalikevadiya
Copy link
Author

ImagePicker.openPicker({
multiple: false,
mediaType: "video",
cropping: false
}).then(images => {
console.log('===========image browsed=============' + JSON.stringify(images, null, 2))

  this.compress_video(images.path,images.width)
  })
  
  async compress_video(path, width) {
const result = await Video.compress(
  path,
  {
    compressionMethod: 'manual',
    bitrate:10
  },
  (progress) => {

  }
);
console.log('=============video compressed=============' + JSON.stringify(result, null, 2))

}

And error is : https://prnt.sc/197jr8u

@numandev1
Copy link
Owner

@krupalikevadiya can you try compressionMethod: 'auto' or remove bitrate:10?

@krupalikevadiya
Copy link
Author

Hey @nomi9995 it is worked with compressionMethod: 'auto' in android but does not work with compressionMethod: 'manual'

@numandev1
Copy link
Owner

@krupalikevadiya I think we cannot set bitrate:16. can you try with bitrate 450000

@krupalikevadiya
Copy link
Author

krupalikevadiya commented Jul 7, 2021

Getting same error of asynctask with following options i tried both bitrate:16 and bitrate:450000.
{
compressionMethod: 'manual',
bitrate:16
},

Error. : https://prnt.sc/198rpuk

@numandev1
Copy link
Owner

@krupalikevadiya can you add video link here?

@krupalikevadiya
Copy link
Author

With same video which i use in ios.

@krupalikevadiya
Copy link
Author

krupalikevadiya commented Jul 8, 2021

@nomi9995 any update on it? ..i need this package to compress video.
Also why i'm getting this error while installing pod. : https://prnt.sc/19hjrbi

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

2 participants