user1025852 user1025852 - 1 year ago 97
Node.js Question

cloudinary crop with node.js doesn't work?

I uploaded some image to cloudinary - tried to manipulate (crop) the image but get the same image url (not cropped) - bug in cloudinary npm or I miss something?

var cloudinary = require('cloudinary');
....
var sourceUrl = cloudinaryImageDetails.url;
var croppedUrl = cloudinary.url(sourceUrl, {
width:30,
height: 30,
crop:'fill'
})

Answer Source

cloudinary.url works when supplied with the public_id of the uploaded image as first argument (instead of full image's URL).

For example,

cloudinary.url (`public_id`, { width:30, height: 30, crop:'fill' })

outputs -

http://res.cloudinary.com/cloud_name/image/upload/c_fill,h_30,w_30/public_id