Forum: Ruby on Rails File_Column w/ Dynamic Sizing

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Dylan S. (Guest)
on 2006-02-22 01:02
(Received via mailing list)
I'm running file_column 0.3.1, and having a few problems... which are:


   - Uploading a 378x567 jpg, and using :magick => {:geometry =>
   "100x100" }, my image ends up being 67x100 ?
   Is there a way to "force" the image to be the size you specify ?

   - My view has a drop-down of sizes, and I'm trying to pass in this
   size into :magick => {:geometry => SIZE_HERE}.
   I've tried replacing SIZE_HERE with self.size, replacing it with a
   @size instance variable in a "before_create"... etc, etc...
   ... but I can't seem to get the proper value included in this hash
   prior to it running.


Any insight into the above would be great,
Thank you !
==
Dylan
Scott (Guest)
on 2006-02-22 01:31
Dylan,
Although you're setting 100x100, the image proportions are being
constrained which is a good thing believe it or not.  If the Proportions
weren't then the image would come out looking squished and stretched.  I
don't believe anything exists that would be able to programmatically
change the image size without  constraint to the proportions and still
have it looking good but I could be wrong.  If their is, the best you
could hope for is that the image would be changed to 67X100 but
incorporated into another image that was 100X100.  The result would be
white (or what ever color you chose) on either side.

Sorry, it may not be the answer you were looking for but at least your
on your way.

Scott.

Dylan S. wrote:
> I'm running file_column 0.3.1, and having a few problems... which are:
>
>
>    - Uploading a 378x567 jpg, and using :magick => {:geometry =>
>    "100x100" }, my image ends up being 67x100 ?
>    Is there a way to "force" the image to be the size you specify ?
>
>    - My view has a drop-down of sizes, and I'm trying to pass in this
>    size into :magick => {:geometry => SIZE_HERE}.
>    I've tried replacing SIZE_HERE with self.size, replacing it with a
>    @size instance variable in a "before_create"... etc, etc...
>    ... but I can't seem to get the proper value included in this hash
>    prior to it running.
>
>
> Any insight into the above would be great,
> Thank you !
> ==
> Dylan
Dylan S. (Guest)
on 2006-02-22 01:35
(Received via mailing list)
Gotcha... thanks for the explanation Scott.
This definitely makes sense, and actually makes my work a little bit
easier.
Thanks again !
Felix McCoey (Guest)
on 2006-02-22 05:13
(Received via mailing list)
i believe you can specify a forced sized by appending a '!' such as
:magick => {:geometry => "100x100!" }

if you look in the rmagick docs under 'geometry strings' there are all
sorts of extras like '<' to resize if it is smaller than the given size.

-felix
Dylan S. (Guest)
on 2006-02-22 07:40
(Received via mailing list)
ahh... brilliant, thanks Felix.  the RMagick docs are huuuuge, and I
probably skipped right over this :(
there are about 100 instance methods for Image itself... and they are
all
actually very applicable :)
This topic is locked and can not be replied to.