Note that there are some explanatory texts on larger screens.

plurals
  1. PORails + Carrierwave + RMagick : Crop only if image is large
    primarykey
    data
    text
    <p>I am using carrier-wave to upload images. On upload I am creating thumbnails for the image which is done using Rmagick method, resize_to_fill like below.</p> <pre><code>version :thumb do process :resize_to_fill=&gt; [150, 150] end </code></pre> <p>Here is output of all the RMagick methods carrierwave <a href="http://carrierwave.rubyforge.org/rdoc/" rel="nofollow noreferrer">supports</a> (none of which I want):</p> <ol> <li><code>:resize_to_fill =&gt; [150,150]</code></li> </ol> <p><strong>This works fine on larger images but my smaller images are enlarged to 150 x 150.</strong> <img src="https://i.stack.imgur.com/R9oHc.png" alt=":resize_to_fill =&gt; [150,150]"></p> <ol start="2"> <li><code>:resize_to_fit =&gt; [150,150]</code></li> </ol> <p><strong>Again it was resized, I want it left alone!</strong></p> <p><img src="https://i.stack.imgur.com/0JHLn.png" alt=":resize_to_fit =&gt; [150,150]"></p> <ol start="3"> <li><code>:resize_to_limit =&gt; [150,150]</code></li> </ol> <p><strong>This one leaves it as is, but larger images are not cropped. They are resized to keep the aspect ratio.</strong></p> <p><img src="https://i.stack.imgur.com/7RdTn.png" alt="enter image description here"></p> <p><img src="https://i.stack.imgur.com/uQ45t.jpg" alt="enter image description here"></p> <p><strong>Here is the result I want and how my small and larger images should look.</strong></p> <p><img src="https://i.stack.imgur.com/gAiIC.jpg" alt="enter image description here"> <img src="https://i.stack.imgur.com/7RdTn.png" alt="enter image description here"></p> <p>How do this? I want smaller images to be left alone and crop only larger images to 150 x 150. Is there another method or options I can pass to resize_to_fill?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload