Wednesday, 15 August 2012

imagemagick - Carrierwave: resize image to fixed width and height -


I have a Rail 4 app, where I allow users to upload images. I have assumptions for the minimum dimension of 640X385 and thus the minimum aspect ratio of 1.6623376623376624 is that it means that the user can not upload small images in terms of dimensions or aspect ratios. And when they upload a large image, reset it to resize the image magic. But it changes the size of a proportional width and height and my dimension recognition fails. If I use resize_to_fill, then smaller images also increase and the recognition of the aspect ratio left, how do I get the 640X385 dimension to completely resize the size of an image to resize the method?

"itemprop =" text ">

Then I do not know what you expect for different sizes. I use ImageMagick on the command line so I can not have a small script with the example or help you output:

  # / bin / bash # cleanup rm * .jpg # Converted Origin Size 640x385 XC: White img0.jpg # 800x400 XC Convert to Big Aspect Ratio (2.0) Size: White img1.jpg # Less Aspect Ratio (1.0) 800x800 XC of Convert Size: White img2.jpg # Large Aspect Ratio ( 2.0) but small conversion-size 400x200 xc: white img3.jpg # small rows on the following aspect ratio (1.0) 200x200 to Pantrit xc size: img img in white img4.jpg * for; Shape # images to fit in the box, but convert aspect ratio to $ {img} -receased 640x385 r1 Change the size of images containing aspect ratios to fit the $ {Img} # box. But shrink only # images, images that are small are not big. $ {Img} Converted 640x385 \ & gt; Change R2 $ {Img} changes the size of images that ignore aspects to fit in the # box. But shrink only # images, images that are small are not big. $ {Img} -Sechen 640x385 \ & gt; \ \ Convert R3 $ {Img} has been formatted "% f:% w% h \ n" * .jpg  

The output is as follows:

  img0 .jpg: 640 385 img1.jpg: 800 400 img2.jpg: 800 800 img3.jpg: 400 200 img4.jpg: 200 200 r1.img0.jpg: 640 385 r1.img1.jpg: 640 320 r1.img2 .jpg : 385 385 r1.img3.jpg: 640 320 r1.img4.jpg: 385 385 r2.img0.jpg: 640 385 r2.img1.jpg: 640 320 r2.img2.jpg: 385 385 r2.img3.jpg: 400 200 r2.img4.jpg: 200 200 r3.img0.jpg: 640 385 r3.img1.jpg: 640 385 r3.img2.jpg: 640 385 r3.img3.jpg: 400 200 r3.img4.jpg: 200 200 < / Code> 

My guess is that you are looking for a previous version where the output name is r3. & Lt; Something & gt; .

for

Take a look at this:

I hope it will be helpful.


No comments:

Post a Comment