Forum: Ruby on Rails How to crop and show external image with specific size?

B39eadf04a0382f9d9ebd715669e53aa?d=identicon&s=25 Darek F. (darek_f)
on 2012-05-16 22:22
(Received via mailing list)
I get image url via API. It usualy have 360x200 but sometimes 233x350
etc..

I would like to crop them all to specific size 260x186. And show them
using

      <%= image_tag image_url if hotel.images.first %>

I dont want to store this images.
955103d80e386882143a78875fb727bf?d=identicon&s=25 Jeremy W. (jeremy_w)
on 2012-05-16 22:31
(Received via mailing list)
On 16 May 2012 21:20, regedarek <dariusz.finster@gmail.com> wrote:

> I get image url via API. It usualy have 360x200 but sometimes 233x350 etc..
>
> I would like to crop them all to specific size 260x186. And show them
> using
>
>       <%= image_tag image_url if hotel.images.first %>
>
> I dont want to store this images.
>

You can use rmagic to crop the images but there's going to be a
time-cost
here if you don't have the images stored. Probably the best bet is to
have
image_url hit your application, crop the image and then use send_file,
then
delete the image.

You might not want the request to go through your whole Rails stack here
from a load POV. 10 images per page = an extra 10 requests to your
application and these requests will take a bit of time to process the
image
so you could end up blocking actual requests. I'd setup a separate app
using either using Sinatra, or a cut-down version of Rails with just the
necessary stuff loaded. There's also a big risk of caning your CPU here,
if
you have high volume.

Storage is cheap - why not store them?

tl;dr; Real-time image-cropping strikes me as a bad idea, but you could
use
rmagic on a separate application/server to do it.

 --
A47e0a6beeb9d048ff054fc1c3a97418?d=identicon&s=25 Walter Davis (walterdavis)
on 2012-05-16 22:36
(Received via mailing list)
On May 16, 2012, at 4:30 PM, Jeremy Walker wrote:

>
> You can use rmagic to crop the images but there's going to be a time-cost here
if you don't have the images stored. Probably the best bet is to have image_url
hit your application, crop the image and then use send_file, then delete the
image.
>
> You might not want the request to go through your whole Rails stack here from a
load POV. 10 images per page = an extra 10 requests to your application and 
these
requests will take a bit of time to process the image so you could end up 
blocking
actual requests. I'd setup a separate app using either using Sinatra, or a
cut-down version of Rails with just the necessary stuff loaded. There's also a 
big
risk of caning your CPU here, if you have high volume.
>
> Storage is cheap - why not store them?
>
> tl;dr; Real-time image-cropping strikes me as a bad idea, but you could use
rmagic on a separate application/server to do it.

Take a look at Dragonfly, too. You get an API to use ImageMagick against
your photos -- to crop, scale, grayscale, whatever -- and the images are
cached. It runs in Rack, so it's a ready-to-roll solution rather than
you having to build a Sinatra app to do this. The only downside is that,
out of the box, the URLs are amazingly long.

Walter
5f94b9b346c2aa648a80bc259978e5bc?d=identicon&s=25 Colin Law (Guest)
on 2012-05-16 23:19
(Received via mailing list)
On 16 May 2012 21:20, regedarek <dariusz.finster@gmail.com> wrote:
> I get image url via API. It usualy have 360x200 but sometimes 233x350 etc..
>
> I would like to crop them all to specific size 260x186. And show them using
>
>    <%= image_tag image_url if hotel.images.first %>

Can I just check that you do want to *crop* them, not just resize to a
given size, in which case you could use the :size option of image_tag.

Colin
Aa082c8b00a50928e5860dcd70bf2368?d=identicon&s=25 Tamara Temple (Guest)
on 2013-06-07 06:18
(Received via mailing list)
taler k. <lists@ruby-forum.com> wrote:
> hi there, quick searching on Google brings me here.and Im working on
> image cropping ,Is the kooboo source codes written in .Net? If yes ,Plz
> give me some detail guide,thx in adv.as a beginner in image programming
> ,I just can't figure out which open source is best siuting me,like image
> crop sample codes
> (http://www.rasteredge.com/how-to/csharp-imaging/crop-image/) found by
> Google as well as your site.Anysuggestion is appreciated.

Absolutely no idea how you managed to get here.

This is about the Ruby on Rails web application development
framework. Definitely nothing to with .NET, nor image processing.

I can't direct you to any .NET resources, but I can direct you to
ImageMagick, which is the swiss army knife of image processing:

    http://www.imagemagick.org
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.