Consecutive transformation chains with layer_apply on a fetchlayer overlay layer - is this possible?
Hi all,
Sorry if a version of this question has been asked before; I searched through the forum and couldn't find anything quite like it, being that this is a very unusual use-case and is hard to even describe. What I'm trying to do is to apply multiple consecutive transformations that are meant to be applied to an overlay layer (remote image). In this specific scenario, these are consecutive transformations with different crop styles (e.g. "scale" vs "crop"), applied to a single fetch overlay layer.
More specifically, I want to first resize the overlay to an exact width and height using "scale" as the crop type, and then slice half of that using "crop" as the crop type + specifying new dimensions and gravity. The issue I'm running into is with chaining more than one transformation that needs to be applied to an overlay instead of the base layer. If I chain more than one transformation with fl_layer_apply, without a new overlay in between, I get a 404 error. Unfortunately, because I also want to do things like change the angle before slicing, I need to have multiple chains to achieve what I want.
-----
Here is an example showing everything working, with just one chain:
----
Now, if I try to apply another crop, slicing the overlay in half, I get a 404:
----
If I remove the "layer_apply" flag in my second transformation, it works, but then it is cropping the entire base, rather than just the overlay, which is not what I want:
----
I realize this simply might not be possible. My guess is that, internally in Cloudinary, when it sees the "layer_apply" flag it looks back just one step in the chain for the overlay to apply to instead of traversing the chain until it finds an overlay. So in my case, it would go one step back, and try to apply a transformation to a transformation, which probably just fails.
If this is the case, I can probably achieve what I want using the distort effect and just specifying the exact coordinates I want. That just means more math and work for me, which is I why I am posing this question to the community.
----
Thanks everyone! Sorry for the extremely long post, but this was difficult for me to summarize.
- Joshua
-
Official comment
Hi Joshua,
You can apply multiple transformations on the same layer, then use fl_layer_apply to do the actual composition. The parameters of the composition (gravity, x, y, etc) should be on the same component as the fl_layer_apply. In general, it's recommended to keep each component performing a single operation (there is no enforcement, it just makes things easier to understand).
So in your case:
Best,
-- Tal
-
Hi Joshua,
The error is caused because on the times there is no layer to apply it on(missing an image).
You can add an image to apply:
Or remove the layer:
Please let me know if that makes sense,
0 -
Hi Shirly,
Thanks for the explanation - that makes sense and is basically what I was afraid of.
Fortunately, the distort effect should be a suitable workaround for me, or, as I recently realized, you can get around this by simply using the cloudinary URL itself as a fetchlayer, like so:
1 -
Tal,
Thank you so much! That was exactly the information I was looking for, and the way you explained it really helped me realize I had been misunderstanding part of how Cloudinary handles transformations - I was not even aware you could hold off on the layer_apply flag until the end of the chain!
Your solution is perfect for what I need; thanks again!
- Joshua
1
Post is closed for comments.
Comments
4 comments