Skip to main content

What is the difference between "Fill", "Fit" and "Limit" scaling modes?

Comments

8 comments

  • Nickolas Olazabal

    Thank you! That exactly what I was looking for some time (there is a mistake in "fit" text before the second URL: is "...the fill crop mode..." should be "...the fit crop mode..." ).

    0
  • Julien Bornstein

    And the difference between "fill" and "thumb" ?

    0
  • Itay Taragano

    The `fill` crop mode will resize the original image and may crop either the width or the height in case the requested aspect ratio is different than the original:
    http://res.cloudinary.com/demo/image/upload/w_200,h_200,c_fill/face_left.jpg

    When it comes together with the `face` or the `faces` gravity modes, the `thumb` crop mode will create a thumbnail cropped version, of the face(s) coordinates:
    http://res.cloudinary.com/demo/image/upload/w_200,h_200,c_thumb,g_face/face_left.jpg

    0
  • Lennart Giaccotto

    I want to prevent users to upload an image smaller than a given height and/or width so i don't have to upscale so much using one of the options explained above. Is this possible?

    0
  • Daniel Mendoza

    Hello Lennart,


    Thanks for reaching out to us and I would like to apologize for not responding sooner.


    Yes, it is possible and the two options you are looking for are "min_image_height" and "min_image_width" in the upload widget options (http://cloudinary.com/documentation/upload_widget#upload_widget_options).

    0
  • Lennart Giaccotto

    Thank you Daniel! That wil do the trick!

    0
  • Mathieu Frenette

    Hello,

    We are looking for a crop mode similar to "lfill" (limit fill) but that returns an image that respects the ratio of the size we requested.  For example, if the original is 400x200 and we request a filled/cropped version of size 800x100, we would expect an image with a 8:1 ratio, without upscaling, with a size 400x50.  Currently, "lfill" returns an image with size 400x100. It prevents upscaling correctly, but does not respect the requested ratio (4:1 instead of 8:1).

    That is a very common case for us. Let's say we have a 800x100 container where we want to display the image. Because the original 400x200 image has the wrong ratio, when we display the image and scale it (dynamically at render time) to fill its container, the top and bottom will not be visible, so those hidden pixels are wasted. We are OK with the fact that the image will be blurry because of dynamic/render-time upscaling, but we don't want upscaling to happen on the server side, because it wastes bandwidth, disk-space and/or memory.

    Do you have anything to handle that or something in your roadmap?

    Thanks in advance for any info! :)

    0
  • Ido

    Hi

    Its possible to use the `aspect_ratio` transformation in conjuncture with `lfill` to enforce an aspect ratio you want to retain.

    Note If you specify both width and height either for `fill` or `lfill` crop modes then these would be the derived image's dimensions (assuming that the original image is larger then requested dimensions). 

     So in order to enforce an aspect ratio and also prevent upscaling if the original image is smaller then the requested dimensions, only one parameter of the dimensions should be specifically specified, in order for the aspect ratio to fit.

    So something like the below might answer your use case.

    Note that the original image's width is 283, but the enforced aspect ratio of 8:1 enforces a height of 50px since the requested height is 400px

    https://res.cloudinary.com/demo/image/upload/c_lfill,g_north,w_400,ar_8:1/face_top.jpg

     

    Let us know if that helps?

    0

Please sign in to leave a comment.