how about upload an image?

J

James

if any one knows how to upload an image to a server and save that image
as is and also save a smaller thumbnail of that image to the same
directory, please let me know the code.
think u!
 
J

James H.

Ooh! Thanks for the link.

Something else you might want to check out, James, is RMagick
(http://rmagick.rubyforge.org/). This is a Ruby interface (not in the
Java sense) to allow image manipulation via ImageMagick, or
GraphicsMagick. It's a bit tedious to install, but it appears to be
quite powerful.

Best of luck,

James H.
 
D

Dave Burt

James said:
Ooh! Thanks for the link.

Something else you might want to check out, James, is RMagick
(http://rmagick.rubyforge.org/). This is a Ruby interface (not in the
Java sense) to allow image manipulation via ImageMagick, or
GraphicsMagick. It's a bit tedious to install, but it appears to be
quite powerful.

I'd like to say, I installed RMagick, and expected to have to do a bunch
of work to get the image info and some relatively involved manipulations
I wanted, but it was dead simple. RMagick kicks butt.

Here's a snippet from a Rails app of mine. (This is simple
thumbnail-making, not the stuff I was talking about above.) image_data
is the contents of an uploaded image, as a string. THUMB_GEOMETRY is
"120x120>", meaning shrink to fit inside a 120x120 box unless it already
does.

image = Magick::Image.from_blob(image_data).first
image.change_geometry(THUMB_GEOMETRY) do |cols, rows, image|
image.resize! cols, rows
end
image.write File.join(RAILS_ROOT, 'public', thumbnail)

Cheers,
Dave
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
474,206
Messages
2,571,068
Members
47,674
Latest member
scazeho

Latest Threads

Top