RMagick Thumbnailing Question

Discussion in 'Ruby' started by Raymond Brigleb, Sep 8, 2005.

  1. Hello: this is my first post, so a brief introduction. My name is
    Ray, I live in Portland, I'm a fresh (circa 2005) Ruby convert, and I
    work with needmoredesigns.com. Hello!

    I'm writing an application (in Rails) that uses much of RMagick's...
    magic. Thumbnails are a big part of the job, but I'm having
    difficulty getting my head around the Geometry (?) class... in a
    sense, what I'm trying to do is create thumbnails that "fill the
    space" rather than are "restricted to the space" they're in. Meaning,
    if I say I want 100x100 thumbnails, I want it to first resize, then
    actually crop a 300x100 image to the middle 100 pixels. Make any
    sense? I just think they'll look better that way.

    My question is, has anybody done this? I've seen it in Backpack
    (backpackhq.com) which I'm just guessing uses this library. I'm
    wondering if anybody has any helpful tips or perhaps some code they
    could share with me.

    Thanks and well met,
    Raymond
    Raymond Brigleb, Sep 8, 2005
    #1
    1. Advertising

  2. Raymond Brigleb

    Joe Van Dyk Guest

    On 9/8/05, Raymond Brigleb <> wrote:
    <snip>=20
    > I'm writing an application (in Rails) that uses much of RMagick's...
    > magic. Thumbnails are a big part of the job, but I'm having
    > difficulty getting my head around the Geometry (?) class... in a
    > sense, what I'm trying to do is create thumbnails that "fill the
    > space" rather than are "restricted to the space" they're in. Meaning,
    > if I say I want 100x100 thumbnails, I want it to first resize, then
    > actually crop a 300x100 image to the middle 100 pixels. Make any
    > sense? I just think they'll look better that way.
    >=20
    > My question is, has anybody done this? I've seen it in Backpack
    > (backpackhq.com) which I'm just guessing uses this library. I'm
    > wondering if anybody has any helpful tips or perhaps some code they
    > could share with me.


    http://studio.imagemagick.org/RMagick/doc/struct.html#Geometry

    Check out the flags at the bottom. In particular, the '!' flag.

    What you probably want is 100!x100! or something similar.
    Joe Van Dyk, Sep 8, 2005
    #2
    1. Advertising

  3. Raymond Brigleb

    Guest

    Sounds to me like you need a 2-step method, assuming the original
    images are not already 300x100.

    Use the change_geometry method to compute the new dimensions for your
    thumbnail. If you want to make sure that your thumbnail is always 100
    pixels high, specify a geometry string argument with just your target
    height, like this: "x100". If you want your thumbnail to be always 300
    pixels wide, just specify the target width: "300". The change_geometry
    method will compute new dimensions you can use as arguments to the
    resize method. If the result still doesn't have the right shape you can
    use the crop method to crop the resized image to the shape you want. If
    you want the middle 100x100 part of the image you can use something
    like:

    img.crop!(Magick::CenterGravity, 100, 100)
    , Sep 8, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Blasting Cap

    Thumbnailing graphics from a sister site

    Blasting Cap, Nov 15, 2006, in forum: ASP .Net
    Replies:
    6
    Views:
    331
    kferron
    Nov 16, 2006
  2. Replies:
    2
    Views:
    440
    Alvin
    Nov 24, 2005
  3. Joe Van Dyk

    RMagick question

    Joe Van Dyk, Apr 7, 2005, in forum: Ruby
    Replies:
    16
    Views:
    230
    Chris Pine
    Apr 12, 2005
  4. Joe Van Dyk

    rmagick question

    Joe Van Dyk, Aug 26, 2005, in forum: Ruby
    Replies:
    16
    Views:
    249
    Timothy Hunter
    Sep 1, 2005
  5. Pito Salas
    Replies:
    1
    Views:
    123
    Tim Hunter
    Apr 24, 2009
Loading...

Share This Page