Variable height for image assets in Django
I have jpegs of paintings. The paintings have certain dimensions.
Painting 1: 52cm x 40cm
Painting 2: 30cm x 50cm
The jpeg of these images may with various widths in pixels in similar dimensions and I have uploaded them into Cloudinary using CloudinaryField in Django.
Now I want to show the thumbnails of these images by translating cm -> px. Meaning I was to show the thumbnail in 52px x 40px. How can I use template tag to display them in the new sizes?
-
Hi Howard,
In digital imaging, the image is stored as pixels, physical units such as centimeters, inches, is usually a calculated based on this pixel dimension and other metadata, such as DPI (Dot Per Inch) or PPI (Pixel Per Inch). So dimensions in cm shouldn't be relevant for this intent & purposes.
With that said, if you want to transform to 52x40px, you can specify width and height values. Example:
https://res.cloudinary.com/demo/image/upload/w_52,h_40/sample.jpg.
By default the above will do `crop: scaling`. To learn different kind of cropping, please refer to the following documentation: https://cloudinary.com/documentation/transformation_reference#c_crop_resize
Hope this helps, let me know if you have any question.
Regards,
Erwin Lukas0
Post is closed for comments.
Comments
1 comment