Resizing images for display only with image_tag()

image_tag() has :size option, but only takes height/width parameters. i
want to be able to scale down the image by 50% because all my images are
different sizes so i cannot be specific as image_tag() wants me to be.
is there another RoR method i could use.

note: i don’t want to resize my original images, i just want to be able
to display them %50 smaller. hope i make sense.

btw, great forum, very helpful!

Are you meaning to resize the image to a percentage of it’s current
size or as a percentage of it’s parent html black (like it would act
if you just put percentages in the width and height attributes of the
html img tag)?

If you mean the latter, it’s just a matter of changing the way
‘image_tag’ works so that you can feed it percentage as well as pixel
values but if you mean the former, I’m not sure if you can do it
without resorting to using rmagick (or similar) to find the width and
height of the image and then halve them and use that in the
‘image_tag’ size option.

you could use :height => “50%” and that should give you a
proportionally scaled image.

On Jan 22, 11:02 am, Leandro – [email protected]

idleFingers wrote:

Are you meaning to resize the image to a percentage of it’s current
size or as a percentage of it’s parent html black (like it would act
if you just put percentages in the width and height attributes of the
html img tag)?

If you mean the latter, it’s just a matter of changing the way
‘image_tag’ works so that you can feed it percentage as well as pixel
values but if you mean the former, I’m not sure if you can do it
without resorting to using rmagick (or similar) to find the width and
height of the image and then halve them and use that in the
‘image_tag’ size option.

i mean the latter

[email protected] wrote:

you could use :height => “50%” and that should give you a
proportionally scaled image.

On Jan 22, 11:02�am, Leandro – [email protected]

using :height => “50%” and :width => “50%” worked like a charm. thank
you!