Text overlay in transformation rules over resizing
So, I have the following transformation (RoR):
<%= cl_image_tag(photo.url(width: 1500, height: 1500, crop: :fit, :quality=>"auto:best", :dpr => :auto, :secure => true) %>
It works as it should. When I try to add a text-overlay (photographer's credits) to this transformation, all of a sudden the resizing doesn't work anymore and I end up with the original files and text sizing that is proportional to them:
<%= cl_image_tag(photo.url(width: 1500, height: 1500, crop: :fit, :quality=>"auto:best", :dpr => :auto, :overlay=>"text:Arial_24_bold:Test", :secure => true) %>
What I want is to still have the resizing and the text applied on the resized image. Who can help me?
-
Hi @Maxim Piessen,
The reason that the base image is being shown at the original width and height, is that the resize is being applied to the text overlay. If you would like to resize the base image, a chained transformation would need to be added that only includes the overlay as one transformation and the other transformation includes everything else.
e.g. <%= cl_image_tag(photo.url(transformation: [{dpr: "auto", quality: "auto:best", width:150, height: 150, crop: "fit"},{overlay: "text:Arial_24_bold:Test"}], :secure => true) %>
Result:
But also you may want to resize the text overlay, so adding the width will work there as well.
e.g. <%= cl_image_tag(photo.url(transformation: [{dpr: "auto", quality: "auto:best", width:150, height: 150, crop: "fit"},{overlay: "text:Arial_24_bold:Test", width: 150}], :secure => true) %>
Result:
Hope this helps :)
1 -
That helps a ton! Thanks a lot.
0
Post is closed for comments.
Comments
2 comments