com.cloudinary.Url.transformation()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(9.7k)|赞(0)|评价(0)|浏览(148)

本文整理了Java中com.cloudinary.Url.transformation()方法的一些代码示例,展示了Url.transformation()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Url.transformation()方法的具体详情如下:
包路径:com.cloudinary.Url
类名称:Url
方法名:transformation

Url.transformation介绍

暂无

代码示例

代码示例来源:origin: cloudinary/cloudinary_java

@Test
public void testExplicit() throws IOException {
  Map result = cloudinary.uploader().explicit("sample", asMap("eager", Collections.singletonList(new Transformation().crop("scale").width(2.0)), "type", "upload", "moderation", "manual"));
  String url = cloudinary.url().transformation(new Transformation().crop("scale").width(2.0)).format("jpg").version(result.get("version")).generate("sample");
  String eagerUrl = (String) ((Map) ((List) result.get("eager")).get(0)).get("url");
  String cloudName = cloudinary.config.cloudName;
  assertEquals(eagerUrl.substring(eagerUrl.indexOf(cloudName)), url.substring(url.indexOf(cloudName)));
}

代码示例来源:origin: cloudinary/cloudinary_java

@Test
public void testAspectRatio() {
  String actual = cloudinary.url().transformation(new Transformation().aspectRatio("1.5"))
      .generate("test");
  assertEquals(DEFAULT_UPLOAD_PATH + "ar_1.5/test", actual);
  actual = cloudinary.url().transformation(new Transformation().aspectRatio(1.5))
      .generate("test");
  assertEquals(DEFAULT_UPLOAD_PATH + "ar_1.5/test", actual);
  actual = cloudinary.url().transformation(new Transformation().aspectRatio(3, 2))
      .generate("test");
  assertEquals(DEFAULT_UPLOAD_PATH + "ar_3:2/test", actual);
}

代码示例来源:origin: cloudinary/cloudinary_java

@Test
public void testAngle() {
  // should support angle
  Transformation transformation = new Transformation().angle(12);
  String result = cloudinary.url().transformation(transformation).generate("test");
  assertEquals(DEFAULT_UPLOAD_PATH + "a_12/test", result);
  transformation = new Transformation().angle("exif", "12");
  result = cloudinary.url().transformation(transformation).generate("test");
  assertEquals(DEFAULT_UPLOAD_PATH + "a_exif.12/test", result);
}

代码示例来源:origin: cloudinary/cloudinary_java

@Test
public void testBackground() {
  // should support background
  Transformation transformation = new Transformation().background("red");
  String result = cloudinary.url().transformation(transformation).generate("test");
  assertEquals(DEFAULT_UPLOAD_PATH + "b_red/test", result);
  transformation = new Transformation().background("#112233");
  result = cloudinary.url().transformation(transformation).generate("test");
  assertEquals(DEFAULT_UPLOAD_PATH + "b_rgb:112233/test", result);
}

代码示例来源:origin: cloudinary/cloudinary_java

@Test
public void testFlags() {
  // should support flags
  Transformation transformation = new Transformation().flags("abc");
  String result = cloudinary.url().transformation(transformation).generate("test");
  assertEquals(DEFAULT_UPLOAD_PATH + "fl_abc/test", result);
  transformation = new Transformation().flags("abc", "def");
  result = cloudinary.url().transformation(transformation).generate("test");
  assertEquals(DEFAULT_UPLOAD_PATH + "fl_abc.def/test", result);
}

代码示例来源:origin: cloudinary/cloudinary_java

@Test
public void testEffectWithParam() {
  // should support effect with param
  Transformation transformation = new Transformation().effect("sepia", 10);
  String result = cloudinary.url().transformation(transformation).generate("test");
  assertEquals(DEFAULT_UPLOAD_PATH + "e_sepia:10/test", result);
}

代码示例来源:origin: cloudinary/cloudinary_java

@Test
public void testDensity() {
  // should support density
  Transformation transformation = new Transformation().density(150);
  String result = cloudinary.url().transformation(transformation).generate("test");
  assertEquals(DEFAULT_UPLOAD_PATH + "dn_150/test", result);
}

代码示例来源:origin: cloudinary/cloudinary_java

@Test
public void testPage() {
  // should support page
  Transformation transformation = new Transformation().page(5);
  String result = cloudinary.url().transformation(transformation).generate("test");
  assertEquals(DEFAULT_UPLOAD_PATH + "pg_5/test", result);
}

代码示例来源:origin: cloudinary/cloudinary_java

@Test
public void testTransformationArray() {
  // should support array of named transformations
  Transformation transformation = new Transformation().named("blip", "blop");
  String result = cloudinary.url().transformation(transformation).generate("test");
  assertEquals(DEFAULT_UPLOAD_PATH + "t_blip.blop/test", result);
}

代码示例来源:origin: cloudinary/cloudinary_java

@Test
public void testArtisticFilter() {
  Transformation transformation = new Transformation().effect("art", "incognito");
  String result = cloudinary.url().transformation(transformation).generate("test");
  assertEquals(DEFAULT_UPLOAD_PATH + "e_art:incognito/test", result);
}

代码示例来源:origin: cloudinary/cloudinary_java

@Test
public void testDefaultImage() {
  // should support default_image
  Transformation transformation = new Transformation().defaultImage("default");
  String result = cloudinary.url().transformation(transformation).generate("test");
  assertEquals(DEFAULT_UPLOAD_PATH + "d_default/test", result);
}

代码示例来源:origin: cloudinary/cloudinary_java

@Test
public void testAudioFrequency() {
  // should support an integer value
  String actual = cloudinary.url().resourceType("video")
      .transformation(new Transformation().audioFrequency(44100)).generate("video_id");
  assertEquals(VIDEO_UPLOAD_PATH + "af_44100/video_id", actual);
  // should support a string value
  actual = cloudinary.url().resourceType("video").transformation(new Transformation().audioFrequency("44100"))
      .generate("video_id");
  assertEquals(VIDEO_UPLOAD_PATH + "af_44100/video_id", actual);
}

代码示例来源:origin: cloudinary/cloudinary_java

@Test(expected = IllegalArgumentException.class)
public void testOverlayError1() {
  // Must supply font_family for text in overlay
  cloudinary.url().transformation(new Transformation().overlay(new TextLayer().fontStyle("italic"))).generate("test");
}

代码示例来源:origin: cloudinary/cloudinary_java

@Test(expected = IllegalArgumentException.class)
public void testOverlayError2() {
  // Must supply public_id for for non-text underlay
  cloudinary.url().transformation(new Transformation().underlay(new Layer().resourceType("video"))).generate("test");
}

代码示例来源:origin: cloudinary/cloudinary_java

@Test
public void testUnderlay() {
  Transformation transformation = new Transformation().underlay("text:hello");
  String result = cloudinary.url().transformation(transformation).generate("test");
  assertEquals(DEFAULT_UPLOAD_PATH + "u_text:hello/test", result);
  // should not pass width/height to html if underlay
  transformation = new Transformation().underlay("text:hello").width(100).height(100);
  result = cloudinary.url().transformation(transformation).generate("test");
  assertNull(transformation.getHtmlHeight());
  assertNull(transformation.getHtmlWidth());
  assertEquals(DEFAULT_UPLOAD_PATH + "h_100,u_text:hello,w_100/test", result);
}

代码示例来源:origin: cloudinary/cloudinary_java

@Test
public void testCrop() {
  Transformation transformation = new Transformation().width(100).height(101);
  String result = cloudinary.url().transformation(transformation).generate("test");
  assertEquals(DEFAULT_UPLOAD_PATH + "h_101,w_100/test", result);
  assertEquals("101", transformation.getHtmlHeight());
  assertEquals("100", transformation.getHtmlWidth());
  transformation = new Transformation().width(100).height(101).crop("crop");
  result = cloudinary.url().transformation(transformation).generate("test");
  assertEquals(DEFAULT_UPLOAD_PATH + "c_crop,h_101,w_100/test", result);
}

代码示例来源:origin: cloudinary/cloudinary_java

@Test
public void testVariousOptions() {
  // should use x, y, radius, prefix, gravity and quality from options
  Transformation transformation = new Transformation().x(1).y(2).radius(3).gravity("center").quality(0.4).prefix("a");
  String result = cloudinary.url().transformation(transformation).generate("test");
  assertEquals(DEFAULT_UPLOAD_PATH + "g_center,p_a,q_0.4,r_3,x_1,y_2/test", result);
}

代码示例来源:origin: cloudinary/cloudinary_java

@Test
public void testSupportUrlSuffixForPrivateCdn() {
  String actual = cloudinary.url().suffix("hello").privateCdn(true).generate("test");
  assertEquals("http://test123-res.cloudinary.com/images/test/hello", actual);
  actual = cloudinary.url().suffix("hello").privateCdn(true).transformation(new Transformation().angle(0)).generate("test");
  assertEquals("http://test123-res.cloudinary.com/images/a_0/test/hello", actual);
}

代码示例来源:origin: cloudinary/cloudinary_java

@Test
public void testSupportUseRootPathForPrivateCdn() {
  String actual = cloudinary.url().privateCdn(true).useRootPath(true).generate("test");
  assertEquals("http://test123-res.cloudinary.com/test", actual);
  actual = cloudinary.url().privateCdn(true).transformation(new Transformation().angle(0)).useRootPath(true).generate("test");
  assertEquals("http://test123-res.cloudinary.com/a_0/test", actual);
}

代码示例来源:origin: cloudinary/cloudinary_java

@Test
public void testBaseTransformationArray() {
  // should support array of base transformations
  Transformation transformation = new Transformation().x(100).y(100).width(200).crop("fill").chain().radius(10).chain().crop("crop").width(100);
  String result = cloudinary.url().transformation(transformation).generate("test");
  assertEquals("100", transformation.getHtmlWidth());
  assertEquals(DEFAULT_UPLOAD_PATH + "c_fill,w_200,x_100,y_100/r_10/c_crop,w_100/test", result);
}

相关文章