Is the order of transformations in a preset guaranteed?
I have a list of eager transformation in one of my presets. I get the following as upload response:
-- Upload response --
{
// -- [snip] --
"eager": [
{
"transformation": "c_scale,q_100,w_500/c_fill,g_face:auto,h_300,r_max,w_300/png",
"width": 300,
"height": 300,
"bytes": 105152,
"url": "http://res.cloudinary.com/cloudninecare/image/upload/c_scale,q_100,w_500/c_fill,g_face:auto,h_300,r_max,w_300/v1557902199/dp/vw6trk7uaqfr4renvnbe.png",
"secure_url": "https://res.cloudinary.com/cloudninecare/image/upload/c_scale,q_100,w_500/c_fill,g_face:auto,h_300,r_max,w_300/v1557902199/dp/vw6trk7uaqfr4renvnbe.png"
},
{
"transformation": "c_scale,q_100,w_300/png",
"width": 300,
"height": 412,
"bytes": 105152,
"url": "http://res.cloudinary.com/cloudninecare/image/upload/c_scale,q_100,w_300/v1557902199/dp/vw6trk7uaqfr4renvnbe.png",
"secure_url": "https://res.cloudinary.com/cloudninecare/image/upload/c_scale,q_100,w_300/v1557902199/dp/vw6trk7uaqfr4renvnbe.png"
}
]
}
---
The problem is I need to know which transformation is what. Because I need to store in database as orig_image, profile_image_round, profile_image_rect
If the order is guaranteed, I can just say:
profile_image_round=eager[0];
profile_image_rect=eager[1];
Is it the right approach to recognize which transformation is what?
Please help me.
Thanks for reading,
Nishant
-
Hi,
Thank you for reaching out.
I'm checking your inquiry with the team and will update soon with our insights.
Warmest regards,
Eyal1 -
Hi Nishant,
The order of transformations in the Upload response is the same as mentioned in the `eager` argument of the `upload` method, Though, In your case, I'd recommend identifying the "round" version of the image by searching the `r_max` string in the `transformation` element of the eager response. This way you're fail-proof from any changes that may take place on our backend (no such change is planned).
Hope this helps, please let me know if you have any further questions.
Thanks,
Eyal1 -
Hey thanks for the response, I appreciate it. I am using a preset, so I guess the order is going to be the order it shows in the preset UI.
So, essentially there is no way to tell which URL is what transformation -- you will have to infer it from the transformation string. Cool, I can do that.
It would be great if one could name transformation and the eager array has transformation_name attribute in each transformation. But, for now I can work with transformation string.
Thanks again,
Nishant0 -
Hi Nishant,
I'm not sure if you've seen the feature before but we actually do support "named transformations" in which you can name and predefine a set of transformations that you want to apply to your resources so that you don't have to type out the same set of transformations to apply for each and every image. This would also help you identify which transformation is which as the URL will include the parameter t_<named_transformation>. You can read more about this in our docs here:
https://cloudinary.com/documentation/image_transformations#named_transformations
and you can view the following article with video tutorials here:
https://support.cloudinary.com/hc/en-us/articles/360018902952-Developing-and-Using-Named-Transformations-with-Cloudinary-Images-and-Videos
Hope this helps!0 -
Hey Marissa,
ha ha, what a coincident I saw the feature moments after my comment and I was going to experiment with that and write back here. Glad you mentioned.
Thanks for vouching this for me. I will give it a go.
Nishant0 -
Hi Nishant,
Great I'm glad to hear that! As always we're here if you have any questions and always please feel free as well to open a direct support ticket with us at https://support.cloudinary.com/hc/en-us/requests/new
Cheers.0
Post is closed for comments.
Comments
6 comments