Skip to content

Commit e3ef229

Browse files
committed
add background_removal,return_delete_token in upload/update params. add support for responsive and hidpi. add support for custom coordinates
1 parent d81e0f1 commit e3ef229

File tree

16 files changed

+930
-268
lines changed

16 files changed

+930
-268
lines changed

cloudinary-core/src/main/java/com/cloudinary/Api.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,8 @@ public ApiResponse resource(String public_id, Map options) throws Exception {
241241
String resourceType = Cloudinary.asString(options.get("resource_type"), "image");
242242
String type = Cloudinary.asString(options.get("type"), "upload");
243243
return callApi(HttpMethod.GET, Arrays.asList("resources", resourceType, type, public_id),
244-
Cloudinary.only(options, "exif", "colors", "faces", "image_metadata", "pages", "phash", "max_results"), options);
244+
Cloudinary.only(options, "exif", "colors", "faces", "coordinates",
245+
"image_metadata", "pages", "phash", "max_results"), options);
245246
}
246247

247248
public ApiResponse update(String public_id, Map options) throws Exception {

cloudinary-core/src/main/java/com/cloudinary/Coordinates.java

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
import java.util.Collection;
44
import java.util.ArrayList;
5+
56
import org.apache.commons.lang.StringUtils;
7+
68
import java.awt.Rectangle;
79
public class Coordinates {
810

@@ -14,6 +16,51 @@ public Coordinates() {
1416
public Coordinates(Collection<Rectangle> coordinates) {
1517
this.coordinates = coordinates;
1618
}
19+
20+
public Coordinates(int[] rect) {
21+
Collection<Rectangle> coordinates = new ArrayList<Rectangle>();
22+
if (rect.length != 4) {
23+
throw new IllegalArgumentException("Must supply exactly 4 values for coordinates (x,y,width,height)");
24+
}
25+
coordinates.add(new Rectangle(rect[0], rect[1], rect[2], rect[3]));
26+
this.coordinates = coordinates;
27+
}
28+
29+
public Coordinates(Rectangle rect) {
30+
Collection<Rectangle> coordinates = new ArrayList<Rectangle>();
31+
coordinates.add(rect);
32+
this.coordinates = coordinates;
33+
}
34+
35+
public Coordinates(String stringCoords) throws IllegalArgumentException {
36+
Collection<Rectangle> coordinates = new ArrayList<Rectangle>();
37+
for (String stringRect : stringCoords.split("\\|")) {
38+
if (stringRect.isEmpty()) continue;
39+
String[] elements = stringRect.split(",");
40+
if (elements.length != 4) {
41+
throw new IllegalArgumentException(String.format("Must supply exactly 4 values for coordinates (x,y,width,height) %d supplied: %s", elements.length, stringRect));
42+
}
43+
coordinates.add(new Rectangle(
44+
Integer.parseInt(elements[0]),
45+
Integer.parseInt(elements[1]),
46+
Integer.parseInt(elements[2]),
47+
Integer.parseInt(elements[3])));
48+
}
49+
this.coordinates = coordinates;
50+
}
51+
52+
53+
public static Coordinates parseCoordinates(Object coordinates) throws IllegalArgumentException {
54+
if (coordinates instanceof Coordinates) {
55+
return (Coordinates)coordinates;
56+
} else if (coordinates instanceof int[]) {
57+
return new Coordinates((int[]) coordinates);
58+
} else if (coordinates instanceof Rectangle) {
59+
return new Coordinates((Rectangle) coordinates);
60+
} else {
61+
return new Coordinates(coordinates.toString());
62+
}
63+
}
1764

1865
public void addRect(Rectangle rect) {
1966
this.coordinates.add(rect);

0 commit comments

Comments
 (0)