Typically, it's best practice to maintain the original files unchanged and utilize Cloudinary for generating on-demand transformed versions of your media assets.
If, however, you wish to preserve a transformed version as the original, you can achieve this by using the original image's URL as the upload source and applying an incoming transformation. Here's an example in Ruby that uploads an image from an existing resource, retains its public ID, and restricts its size to a maximum of 1000 x 1000 pixels:
Cloudinary::Uploader.upload("http://res.cloudinary.com/<your_cloud_name>/image/upload/v1392564715/my_image.jpg", :width => 1000, :height => 1000, :crop => "limit", :public_id => "my_image", :invalidate => true)
Please note the inclusion of `invalidate => true`. This is essential because if the original image's URL was accessed before, it might be cached in the CDN. Consequently, accessing the same URL may still provide the original image rather than the resized one.
Comments
2 comments
Hi,
How would I go about doing this using python and using the quality:auto transformation?
Hi Christopher,
Please see our documentation on transformations- https://cloudinary.com/documentation/image_transformations#adjusting_image_quality
In general, you can try something like the following-
CloudinaryImage("<my_image>").image(quality="auto")
Please sign in to leave a comment.