Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Grab Image From Web Server

3 views
Skip to first unread message

Hunter Hillegas

unread,
Nov 29, 2005, 5:42:07 PM11/29/05
to
Hi,

I am still fairly new to Ruby.

Given the URL of an image, I would like to craft some code that grabs the
image from the remote Web server and puts it in a file on the local machine.

Can anyone give me some tips on doing that?

Thanks,
Hunter


Jim Weirich

unread,
Nov 29, 2005, 5:49:19 PM11/29/05
to

requre 'open-uri'
open("output_filename.jpg", "w") { |outfile|
outfile.write open("http://image_url.jpg") { |inf|
ifile.read
}
}

--
Posted via http://www.ruby-forum.com/.


Jim Weirich

unread,
Nov 29, 2005, 5:50:24 PM11/29/05
to
jimweirich wrote:

> requre 'open-uri'
> open("output_filename.jpg", "w") { |outfile|
> outfile.write open("http://image_url.jpg") { |inf|
> ifile.read
> }
> }

Oops ... naming problem with inf and ifile ... both should be infile.

Sorry
-- Jim Weirich

Hunter Hillegas

unread,
Nov 29, 2005, 6:13:26 PM11/29/05
to
Thanks.

This is working like a charm!

James Britt

unread,
Nov 29, 2005, 6:15:27 PM11/29/05
to
Jim Weirich wrote:
> jimweirich wrote:
>
>
>>requre 'open-uri'
>>open("output_filename.jpg", "w") { |outfile|

on Windows, make this "wb" for binary data.


James

--

http://www.ruby-doc.org - Ruby Help & Documentation
http://www.artima.com/rubycs/ - Ruby Code & Style: Writers wanted
http://www.rubystuff.com - The Ruby Store for Ruby Stuff
http://www.jamesbritt.com - Playing with Better Toys
http://www.30secondrule.com - Building Better Tools


Raveendran Perumalsamy

unread,
Apr 20, 2009, 5:56:04 AM4/20/09
to

Hi All,

Get all images from given URL

Desktop Application from jazzez

Kindly go through below link and download the EXE file.

http://www.box.net/shared/m5vxqpr3r1

Install in Windows machine and enjoy with impressed images

Regards,
P.Raveendran
http://raveendran.wordpress.com

Brian Candler

unread,
Apr 20, 2009, 9:48:50 AM4/20/09
to
Could it be at all possible that a class has just been set an exercise
of downloading an image from a webserver, and the class notes also
pointed to the existence of the ruby-talk mailing list? :-)
0 new messages