@@ -126,8 +126,70 @@ public T y(Object value) {
126126 return param ("y" , value );
127127 }
128128
129+ /**
130+ * Add rounding transformation.
131+ * <p>
132+ * Radius can be specified either as value in pixels or expression. Specify 0 to keep corner untouched.
133+ *
134+ * @param value rounding radius for all four corners
135+ * @return updated transformation instance for chaining
136+ */
129137 public T radius (Object value ) {
130- return param ("radius" , value );
138+ return radius (new Object []{value });
139+ }
140+
141+ /**
142+ * Add rounding transformation.
143+ * <p>
144+ * Radius can be specified either as value in pixels or expression. Specify 0 to keep corner untouched.
145+ *
146+ * @param topLeftBottomRight rounding radius for top-left and bottom-right corners
147+ * @param topRightBottomLeft rounding radius for top-right and bottom-left corners
148+ * @return updated transformation instance for chaining
149+ */
150+ public T radius (Object topLeftBottomRight , Object topRightBottomLeft ) {
151+ return radius (new Object []{topLeftBottomRight , topRightBottomLeft });
152+ }
153+
154+ /**
155+ * Add rounding transformation.
156+ * <p>
157+ * Radius can be specified either as value in pixels or expression. Specify 0 to keep corner untouched.
158+ *
159+ * @param topLeft rounding radius for top-left corner
160+ * @param topRightBottomLeft rounding radius for top-right and bottom-left corners
161+ * @param bottomRight rounding radius for bottom-right corner
162+ * @return updated transformation instance for chaining
163+ */
164+ public T radius (Object topLeft , Object topRightBottomLeft , Object bottomRight ) {
165+ return radius (new Object []{topLeft , topRightBottomLeft , bottomRight });
166+ }
167+
168+ /**
169+ * Add rounding transformation.
170+ * <p>
171+ * Radius can be specified either as value in pixels or expression. Specify 0 to keep corner untouched.
172+ *
173+ * @param topLeft rounding radius for top-left corner
174+ * @param topRight rounding radius for top-right corner
175+ * @param bottomRight rounding radius for bottom-right corner
176+ * @param bottomLeft rounding radius for bottom-left corner
177+ * @return updated transformation instance for chaining
178+ */
179+ public T radius (Object topLeft , Object topRight , Object bottomRight , Object bottomLeft ) {
180+ return radius (new Object []{topLeft , topRight , bottomRight , bottomLeft });
181+ }
182+
183+ /**
184+ * Add rounding transformation.
185+ * <p>
186+ * Radius can be specified either as value in pixels or expression. Specify 0 to keep corner untouched.
187+ *
188+ * @param cornerRadiuses rounding radiuses for corners as array
189+ * @return updated transformation instance for chaining
190+ */
191+ public T radius (Object [] cornerRadiuses ) {
192+ return param ("radius" , cornerRadiuses );
131193 }
132194
133195 public T quality (Object value ) {
@@ -694,7 +756,7 @@ public String generate(Map options) {
694756 params .put ("h" , Expression .normalize (height ));
695757 params .put ("o" , Expression .normalize (options .get ("opacity" )));
696758 params .put ("q" , Expression .normalize (options .get ("quality" )));
697- params .put ("r" , Expression .normalize (options .get ("radius" )));
759+ params .put ("r" , Expression .normalize (radiusToExpression (( Object []) options .get ("radius" ) )));
698760 params .put ("so" , startOffset );
699761 params .put ("t" , namedTransformation );
700762 params .put ("vc" , videoCodec );
@@ -902,4 +964,22 @@ public T customFunction(CustomFunction action) {
902964 public T customPreFunction (CustomFunction action ) {
903965 return param ("custom_function" , "pre:" + action .toString ());
904966 }
967+
968+ private String radiusToExpression (Object [] radiusOption ) {
969+ if (radiusOption == null ) {
970+ return null ;
971+ }
972+
973+ if (radiusOption .length == 0 || radiusOption .length > 4 ) {
974+ throw new IllegalArgumentException ("Radius array should contain between 1 and 4 values" );
975+ }
976+
977+ for (Object o : radiusOption ) {
978+ if (o == null ) {
979+ throw new IllegalArgumentException ("Radius options array should not contain nulls" );
980+ }
981+ }
982+
983+ return StringUtils .join (radiusOption , ":" );
984+ }
905985}
0 commit comments