Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transformation erroneously replacing all overlay spaces to underscore #160

Open
edumelzer opened this issue Feb 8, 2019 · 9 comments
Open
Assignees
Labels

Comments

@edumelzer
Copy link

edumelzer commented Feb 8, 2019

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:

@aditimadan-Cloudinary
Copy link
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

@edumelzer
Copy link
Author

edumelzer commented Feb 9, 2019

Hi Aditi,

Using %20 works, thanks!

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

@aditimadan-Cloudinary
Copy link
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

@sagar-savaliya
Copy link

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);

@aditimadan-Cloudinary
Copy link
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.

@sagar-savaliya
Copy link

sagar-savaliya commented Oct 16, 2020

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.

@aditimadan-Cloudinary
Copy link
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.

@sagar-savaliya
Copy link

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.

@aleksandar-cloudinary
Copy link

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
Labels
Projects
None yet
Development

No branches or pull requests

5 participants