File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed
test/java/com/cloudinary/test Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -326,6 +326,18 @@ public Transformation zoom(float value) {
326326 public Transformation zoom (double value ) {
327327 return param ("zoom" , new Double (value ));
328328 }
329+
330+ public Transformation aspectRatio (double value ) {
331+ return param ("aspect_ratio" , new Double (value ));
332+ }
333+
334+ public Transformation aspectRatio (String value ) {
335+ return param ("aspect_ratio" , value );
336+ }
337+
338+ public Transformation aspectRatio (int nom , int denom ) {
339+ return aspectRatio (Integer .toString (nom ) + ":" + Integer .toString (denom ));
340+ }
329341
330342 public Transformation responsiveWidth (boolean value ) {
331343 return param ("responsive_width" , value );
@@ -469,6 +481,7 @@ public String generate(Map options) {
469481 String [] simple_params = new String [] {
470482 "ac" , "audio_codec" ,
471483 "af" , "audio_frequency" ,
484+ "ar" , "aspect_ratio" ,
472485 "bo" , "border" ,
473486 "br" , "bit_rate" ,
474487 "cs" , "color_space" ,
Original file line number Diff line number Diff line change @@ -883,6 +883,19 @@ public void testVideoTagWithPoster() {
883883 assertEquals (expectedTag , actualTag );
884884
885885 }
886+
887+ @ Test
888+ public void testAspectRatio () {
889+ String actual = cloudinary .url ().transformation (new Transformation ().aspectRatio ("1.5" ))
890+ .generate ("test" );
891+ assertEquals (DEFAULT_UPLOAD_PATH + "ar_1.5/test" , actual );
892+ actual = cloudinary .url ().transformation (new Transformation ().aspectRatio (1.5 ))
893+ .generate ("test" );
894+ assertEquals (DEFAULT_UPLOAD_PATH + "ar_1.5/test" , actual );
895+ actual = cloudinary .url ().transformation (new Transformation ().aspectRatio (3 ,2 ))
896+ .generate ("test" );
897+ assertEquals (DEFAULT_UPLOAD_PATH + "ar_3:2/test" , actual );
898+ }
886899
887900 public static Map <String , String > getUrlParameters (URI uri ) throws UnsupportedEncodingException {
888901 Map <String , String > params = new HashMap <String , String >();
You can’t perform that action at this time.
0 commit comments