Package com.cloudinary

Examples of com.cloudinary.Transformation


  }

  @Test
  public void testEffect() {
    // should support effect
    Transformation transformation = new Transformation().effect("sepia");
    String result = cloudinary.url().transformation(transformation).generate("test");
    assertEquals("http://res.cloudinary.com/test123/image/upload/e_sepia/test", result);
  }
View Full Code Here


  }

  @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("http://res.cloudinary.com/test123/image/upload/e_sepia:10/test", result);
  }
View Full Code Here

  }

  @Test
  public void testDensity() {
    // should support density
    Transformation transformation = new Transformation().density(150);
    String result = cloudinary.url().transformation(transformation).generate("test");
    assertEquals("http://res.cloudinary.com/test123/image/upload/dn_150/test", result);
  }
View Full Code Here

  }

  @Test
  public void testPage() {
    // should support page
    Transformation transformation = new Transformation().page(5);
    String result = cloudinary.url().transformation(transformation).generate("test");
    assertEquals("http://res.cloudinary.com/test123/image/upload/pg_5/test", result);
  }
View Full Code Here

  }

  @Test
  public void testBorder() {
    // should support border
    Transformation transformation = new Transformation().border(5, "black");
    String result = cloudinary.url().transformation(transformation).generate("test");
    assertEquals("http://res.cloudinary.com/test123/image/upload/bo_5px_solid_black/test", result);
    transformation = new Transformation().border(5, "#ffaabbdd");
    result = cloudinary.url().transformation(transformation).generate("test");
    assertEquals("http://res.cloudinary.com/test123/image/upload/bo_5px_solid_rgb:ffaabbdd/test", result);
    transformation = new Transformation().border("1px_solid_blue");
    result = cloudinary.url().transformation(transformation).generate("test");
    assertEquals("http://res.cloudinary.com/test123/image/upload/bo_1px_solid_blue/test", result);
  }
View Full Code Here

  }

  @Test
  public void testFlags() {
    // should support flags
    Transformation transformation = new Transformation().flags("abc");
    String result = cloudinary.url().transformation(transformation).generate("test");
    assertEquals("http://res.cloudinary.com/test123/image/upload/fl_abc/test", result);
    transformation = new Transformation().flags("abc", "def");
    result = cloudinary.url().transformation(transformation).generate("test");
    assertEquals("http://res.cloudinary.com/test123/image/upload/fl_abc.def/test", result);
  }
View Full Code Here

  }
 
  @Test
  public void testOpacity() {
    // should support opacity
    Transformation transformation = new Transformation().opacity(50);
    String result = cloudinary.url().transformation(transformation).generate("test");
    assertEquals("http://res.cloudinary.com/test123/image/upload/o_50/test", result);
  }
View Full Code Here

    assertEquals("http://res.cloudinary.com/test123/image/upload/o_50/test", result);
  }

  @Test
  public void testImageTag() {
    Transformation transformation = new Transformation().width(100).height(101).crop("crop");
    String result = cloudinary.url().transformation(transformation).imageTag("test", Cloudinary.asMap("alt", "my image"));
    assertEquals(
        "<img src='http://res.cloudinary.com/test123/image/upload/c_crop,h_101,w_100/test' alt='my image' height='101' width='100'/>",
        result);
    transformation = new Transformation().width(0.9).height(0.9).crop("crop").responsiveWidth(true);
    result = cloudinary.url().transformation(transformation).imageTag("test", Cloudinary.asMap("alt", "my image"));
    assertEquals(
        "<img alt='my image' class='cld-responsive' data-src='http://res.cloudinary.com/test123/image/upload/c_crop,h_0.9,w_0.9/c_limit,w_auto/test'/>",
        result);
    result = cloudinary.url().transformation(transformation).imageTag("test", Cloudinary.asMap("alt", "my image", "class", "extra"));
    assertEquals(
        "<img alt='my image' class='extra cld-responsive' data-src='http://res.cloudinary.com/test123/image/upload/c_crop,h_0.9,w_0.9/c_limit,w_auto/test'/>",
        result);
    transformation = new Transformation().width("auto").crop("crop");
    result = cloudinary.url().transformation(transformation).imageTag("test", Cloudinary.asMap("alt", "my image", "responsive_placeholder", "blank"));
    assertEquals(
        "<img src='data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7' alt='my image' class='cld-responsive' data-src='http://res.cloudinary.com/test123/image/upload/c_crop,w_auto/test'/>",
        result);
    result = cloudinary.url().transformation(transformation).imageTag("test", Cloudinary.asMap("alt", "my image", "responsive_placeholder", "other.gif"));
View Full Code Here

  @Test
  public void testSignedUrl() {
    // should correctly sign a url
    String expected = "http://res.cloudinary.com/test123/image/upload/s--MaRXzoEC--/c_crop,h_20,w_10/v1234/image.jpg";
    String actual = cloudinary.url().version(1234).transformation(new Transformation().crop("crop").width(10).height(20)).signed(true)
        .generate("image.jpg");
    assertEquals(expected, actual);

    expected = "http://res.cloudinary.com/test123/image/upload/s--ZlgFLQcO--/v1234/image.jpg";
    actual = cloudinary.url().version(1234).signed(true).generate("image.jpg");
    assertEquals(expected, actual);

    expected = "http://res.cloudinary.com/test123/image/upload/s--Ai4Znfl3--/c_crop,h_20,w_10/image.jpg";
    actual = cloudinary.url().transformation(new Transformation().crop("crop").width(10).height(20)).signed(true).generate("image.jpg");
    assertEquals(expected, actual);
  }
View Full Code Here

  }
 
  @Test
  public void testResponsiveWidth() {
    // should support responsive width
    Transformation trans = new Transformation().width(100).height(100).crop("crop").responsiveWidth(true);
    String result = cloudinary.url().transformation(trans).generate("test");
    assertTrue(trans.isResponsive());
    assertEquals("http://res.cloudinary.com/test123/image/upload/c_crop,h_100,w_100/c_limit,w_auto/test", result)
    Transformation.setResponsiveWidthTransformation(Cloudinary.asMap("width", "auto", "crop", "pad"));
    trans = new Transformation().width(100).height(100).crop("crop").responsiveWidth(true);
    result = cloudinary.url().transformation(trans).generate("test");
    assertTrue(trans.isResponsive());
    assertEquals("http://res.cloudinary.com/test123/image/upload/c_crop,h_100,w_100/c_pad,w_auto/test", result);
    Transformation.setResponsiveWidthTransformation(null);
  }
View Full Code Here

TOP

Related Classes of com.cloudinary.Transformation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.