zetbaitsu / Compressor

An android image compression library.
7.08k stars 963 forks source link

Compressed image is of 0 bytes #172

Closed pratyush019 closed 3 years ago

pratyush019 commented 3 years ago

I'm using this code to compress image, works fine till android 9 but on android 10 file size is of 0 bytes

try { new Compressor(this) //.setMaxWidth(640) // .setMaxHeight(480) // .setQuality(75) .setCompressFormat(Bitmap.CompressFormat.JPEG) .setDestinationDirectoryPath(new File(this.getExternalCacheDir(),"images").getAbsolutePath()) .compressToFile(new File(getPath(uri))); } catch (IOException e) { e.printStackTrace(); }

pratyush019 commented 3 years ago

From android 10 you can't access files directly from apps folder. Implementation was right but i had permission related issue. Problem solved now.