Nested Transformations in Node
I am upgrading some very old code that I wrote with an older version of the Cloudinary SDK and PHP. I am not finding any examples that can help me translate the code to the newer SDK in Node. If you can point me in the right direction, I would greatly appreciate it. The trouble I'm having is knowing how to structure nested transformations, as you see in the nested arrays.
My old code looks like this:
-
Hi Fidel,
Please find below an example of how you can turn that PHP code into NodeJS so that you get back the same exact Cloudinary URL generated:
console.log(
cloudinary.url(result["public_id"], {
resource_type: "image",
type: 'upload',
transformation: [
{ "width": 260, "height": 166, "crop": "scale", "angle": "auto_left" },
{ "underlay": "backborderlogokeyad", "gravity": "north_west", "x": -13, "y": -13 },
{ "overlay": result["public_id"], "gravity": "south_west", "x": 23, "y": 23, "width": 260, "height": 166, "crop": "scale", "angle": "auto" },
{ "overlay": result["public_id"], "gravity": "south_west", "x": 23, "y": 207, "width": 272, "height": 174, "crop": "scale", "angle": "auto" },
{ "overlay": result["public_id"], "gravity": "south_west", "x": 305, "y": 23, "width": 272, "height": 174, "crop": "scale", "angle": "auto" },
{ "overlay": `text:text16:${imageText}`, "gravity": "south_east", "x": 30, "y": 40, "angle": 270 }
],
format: "jpg"
})
);Let me know if this helps?
1 -
Yes, thank you. That helps.
Would you know where I can find similar examples of these nested transformations? I can't find any in the documentation.0 -
Hi Fidel,
You're welcome!
These types of transformations (nested) are called Chained Transformations and we have more details on those in the following section of the documentation:
https://cloudinary.com/documentation/image_transformations#chained_transformationsIf you run into any issues or have any questions on this please let us know.
0
Post is closed for comments.
Comments
3 comments