private static List<EffectData> generateImageEffects(Context context, Resource resource) { List<EffectData> effects = new ArrayList<>(); Transformation transformation; transformation = new Transformation().effect("sharpen", 250).fetchFormat("webp"); effects.add(new EffectData(resource.getCloudinaryPublicId(), transformation, context.getString(R.string.effect_name_sharpen), context.getString(R.string.effect_desc_face_sharpen))); transformation = new Transformation().effect("oil_paint", 100).fetchFormat("webp"); effects.add(new EffectData(resource.getCloudinaryPublicId(), transformation, context.getString(R.string.effect_name_oil_paint), context.getString(R.string.effect_desc_face_oilpaint))); transformation = new Transformation().effect("sepia").fetchFormat("webp"); effects.add(new EffectData(resource.getCloudinaryPublicId(), transformation, context.getString(R.string.effect_name_sepia), context.getString(R.string.effect_desc_narrow_sepia))); transformation = new Transformation().radius(50).effect("saturation", 100); effects.add(new EffectData(resource.getCloudinaryPublicId(), transformation, context.getString(R.string.effect_name_round_corners), context.getString(R.string.effect_desc_face_sat_round))); transformation = new Transformation().effect("blue:100").fetchFormat("webp"); effects.add(new EffectData(resource.getCloudinaryPublicId(), transformation, context.getString(R.string.effect_name_blue), context.getString(R.string.effect_desc_wide_blue))); return effects; }
private static List<EffectData> generateVideoEffects(Context context, Resource resource) { List<EffectData> effects = new ArrayList<>(); Transformation transformation; transformation = new Transformation().angle(20); effects.add(new EffectData(resource.getCloudinaryPublicId(), transformation, context.getString(R.string.effect_video_name_rotation), context.getString(R.string.effect_video_rotate))); transformation = new Transformation().effect("fade", 1000); effects.add(new EffectData(resource.getCloudinaryPublicId(), transformation, context.getString(R.string.effect_video_name_fade_in), context.getString(R.string.effect_video_fade_in))); transformation = new Transformation().chain().overlay("video:" + resource.getCloudinaryPublicId()).width(0.5).flags("relative").gravity("north_east"); effects.add(new EffectData(resource.getCloudinaryPublicId(), transformation, context.getString(R.string.effect_video_name_overlay), context.getString(R.string.effect_desc_video_overlay))); transformation = new Transformation().effect("noise", 50); effects.add(new EffectData(resource.getCloudinaryPublicId(), transformation, context.getString(R.string.effect_video_name_noise), context.getString(R.string.effect_desc_video_noise))); transformation = new Transformation().effect("blur", 200); effects.add(new EffectData(resource.getCloudinaryPublicId(), transformation, context.getString(R.string.effect_video_name_blur), context.getString(R.string.effect_desc_video_blur))); transformation = new Transformation().effect("reverse"); effects.add(new EffectData(resource.getCloudinaryPublicId(), transformation, context.getString(R.string.effect_video_name_reverse), context.getString(R.string.effect_desc_video_reverse))); return effects; }
breakpoint.transformation(new Transformation().effect("sepia"));
@Test public void testShouldSupportTextValues() { Transformation t = new Transformation(); t.effect("$efname", 100) .variable("$efname", "!blur!"); assertEquals("$efname_!blur!,e_$efname:100", t.generate()); }
@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); }
@Test public void testEffect() { // should support effect Transformation transformation = new Transformation().effect("sepia"); String result = cloudinary.url().transformation(transformation).generate("test"); assertEquals(DEFAULT_UPLOAD_PATH + "e_sepia/test", result); }
@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); }
@Test public void shouldSupportAndTranslateOperators() { String allOperators = "if_" + "w_eq_0_and" + "_h_ne_0_or" + "_ar_lt_0_and" + "_pc_gt_0_and" + "_fc_lte_0_and" + "_w_gte_0" + ",e_grayscale"; assertEquals("should support and translate operators: '=', '!=', '<', '>', '<=', '>=', '&&', '||'", allOperators, new Transformation().ifCondition() .width("=", 0).and() .height("!=", 0).or() .aspectRatio("<", 0).and() .pageCount(">", 0).and() .faceCount("<=", 0).and() .width(">=", 0) .then().effect("grayscale").toString()); assertEquals(allOperators, new Transformation().ifCondition("w = 0 && height != 0 || aspectRatio < 0 and pageCount > 0 and faceCount <= 0 and width >= 0") .effect("grayscale") .toString()); }