Skip to content

Commit 204f20b

Browse files
nadjibivpusic
authored andcommitted
Create another file for compressed picture with different name (ivpusic#418)
* Create another file for compressed picture For fix bug replace original image * Update Compression.java
1 parent 54934f5 commit 204f20b

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

android/src/main/java/com/reactnative/ivpusic/imagepicker/Compression.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,16 @@ public File compressImage(final Activity activity, final ReadableMap options, fi
5353
compressor.setMaxHeight(maxHeight);
5454
}
5555

56+
File image = new File(originalImagePath);
57+
58+
String[] paths = image.getName().split("\\.(?=[^\\.]+$)");
59+
String compressedFileName = paths[0] + "-compressed";
60+
61+
if(paths.length > 1)
62+
compressedFileName += "." + paths[1];
63+
5664
return compressor
57-
.compressToFile(new File(originalImagePath));
65+
.compressToFile(image, compressedFileName);
5866
}
5967

6068
public synchronized void compressVideo(final Activity activity, final ReadableMap options, final String originalVideo, final String compressedVideo, final Promise promise) {

0 commit comments

Comments
 (0)