-
-
Notifications
You must be signed in to change notification settings - Fork 81
/
ImageCompressorOptions.java
61 lines (52 loc) · 1.94 KB
/
ImageCompressorOptions.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package com.reactnativecompressor.Image.utils;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.bridge.ReadableMapKeySetIterator;
public class ImageCompressorOptions {
public static ImageCompressorOptions fromMap(ReadableMap map) {
final ImageCompressorOptions options = new ImageCompressorOptions();
final ReadableMapKeySetIterator iterator = map.keySetIterator();
while (iterator.hasNextKey()) {
final String key = iterator.nextKey();
switch (key) {
case "autoCompress":
options.autoCompress = map.getBoolean(key);
break;
case "maxWidth":
options.maxWidth = map.getInt(key);
break;
case "maxHeight":
options.maxHeight = map.getInt(key);
break;
case "quality":
options.quality = (float) map.getDouble(key);
break;
case "input":
options.input = InputType.valueOf(map.getString(key));
break;
case "output":
options.output = OutputType.valueOf(map.getString(key));
break;
case "returnableOutputType":
options.returnableOutputType = ReturnableOutputType.valueOf(map.getString(key));
break;
}
}
return options;
}
public enum InputType {
base64, uri
}
public enum OutputType {
png, jpg
}
public enum ReturnableOutputType {
base64, uri
}
public boolean autoCompress = false;
public int maxWidth = 640;
public int maxHeight = 480;
public float quality = 1.0f;
public InputType input = InputType.uri;
public OutputType output = OutputType.jpg;
public ReturnableOutputType returnableOutputType = ReturnableOutputType.uri;
}