Skip to content

Transformation erroneously replacing all overlay spaces to underscore #160

Description

@edumelzer

Currently, Transformation class is replacing all spaces on parameters to underscore in this line:

transformations.add(Expression.normalize(joined));

This is causing some issues, like when I try to use some font name that contains spaces (eg: Roboto Condensed), it replaces with underscores and the URL become invalid (because font is invalid). The same applies to text content (overlay), when using the text My Text Content it appears on final Image as My_Text_Content.

Example:

cloudinary.url()
		.signed(true)
		.resourceType("video")
		.transformation(new Transformation()
				.height(480)
				.width(720)
				.crop("fill")
				.chain()
				.color("white")
				.overlay("text:Roboto_70_bold:My Text Content"))
		.format("jpg")
		.generate("video/2130");

Results in:

Activity

  1. aditimadan-Cloudinary commented on Feb 9, 2019

    @aditimadan-Cloudinary
    Contributor

    Hi Eduard,

    Can you please try using %20 instead of space and test

    Eg:

    cloudinary.url()
    		.signed(true)
    		.resourceType("video")
    		.transformation(new Transformation()
    				.height(480)
    				.width(720)
    				.crop("fill")
    				.chain()
    				.color("white")
    				.overlay("text:Roboto%20Condensed_70_bold:My%20Text%20Content"))
    		.format("jpg")
    		.generate("video/2130");
    

    Thanks,
    Aditi

  2. edumelzer commented on Feb 9, 2019

    @edumelzer
    Author

    Hi Aditi,

    Using %20 works, thanks!

    Is this a particularity of the cloudinary's java sdk?

  3. aditimadan-Cloudinary commented on Feb 9, 2019

    @aditimadan-Cloudinary
    Contributor

    Hi Eduard,

    That was a workaround. We also have a TextLayer class - that already handles all the encoding for you: https://github.com/cloudinary/cloudinary_java/blob/master/cloudinary-core/src/main/java/com/cloudinary/transformation/TextLayer.java

    Example:

    TextLayer t=layer.text("Roboto Condensed_70_bold:My Text Content");
    		String url=cloudinary.url()
    		.signed(true)
    		.resourceType("video")
    		.transformation(new Transformation()
    				.height(480)
    				.width(720)
    				.crop("fill")
    				.chain()
    				.color("white")
    				.overlay(t))
    		.format("jpg")
    		.generate("video/2130");
    

    Thanks,
    Aditi

  4. sagar-savaliya commented on Oct 15, 2020

    @sagar-savaliya

    Hi Aditi,

    using %20 in text font style throws below error:
    Unknown text style - Roboto%20Condensed_48_LEFT

    code:

    String source = "https://qa4-cdata-app.sprinklr.com/EXPORT/400002/d00a533e-18d9-469e-92c0-e191b1141424-1528232385/VORK5CYII_.png";
    Transformation transformation = new Transformation().chain().overlay("text:Roboto%20Condensed_48_LEFT:This%20is%20static");
    final Map<String, Object> options = Maps.newHashMap();
    options.put("public_id", "transformation_test"); 
    options.put("transformation", transformation);
    cloudinary.uploader().upload(source, options);
    
    
  5. aditimadan-Cloudinary commented on Oct 15, 2020

    @aditimadan-Cloudinary
    Contributor

    Hi Sagar,

    As I mentioned in my last response that using %20 was a workaround. You can use the TextLayer class that already handles all the encoding for you: https://github.com/cloudinary/cloudinary_java/blob/master/cloudinary-core/src/main/java/com/cloudinary/transformation/TextLayer.java. And if you still have any issues then please raise a support ticket here:https://support.cloudinary.com/hc/en-us/requests/new and share your cloud name so that I can check further.

  6. sagar-savaliya commented on Oct 16, 2020

    @sagar-savaliya

    Hi Aditi,

    I used TextLayer and it encodes text, but the issue is Cloudinary doesn't accept encoded font style.
    So I want to pass font style with space to Cloudinary but the library doesn't support that. it replaces space with an underscore.

    After changing the logic of this method to not replace space with the underscore and it's working fine.

    Thanks.

  7. aditimadan-Cloudinary commented on Oct 16, 2020

    @aditimadan-Cloudinary
    Contributor

    Hi Sagar,

    Can you please share your cloud name and I will be able to check further? I just tested a font file with space in between using the TextLayer class and it worked. Please add the format at the end of the overlay when accessing a custom font.
    TextLayer t=layer.text("Roboto Condensed.ttf_70_bold:My Text Content");
    Another thing to check will be the name of the file should be the same as the uploaded file.
    You can also open a support ticket and share the cloud name if privacy is a concern.

  8. sagar-savaliya commented on Oct 17, 2020

    @sagar-savaliya

    Hi Aditi,

    I have opened a support ticket #133163. can you please check?
    Also, The issue is with the font name with space (i. e. Roboto Condensed) and not the font file.

    Thanks.

  9. aleksandar-cloudinary commented on Oct 17, 2020

    @aleksandar-cloudinary

    Hi @sagar-savaliya - Thanks for raising the ticket. I've just responded on there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions