Forum: Ruby Grab Image From Web Server

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.
lists (Guest)
on 2005-11-30 00:42
(Received via mailing list)
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 W. (Guest)
on 2005-11-30 00:49
lists wrote:
> 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

requre 'open-uri'
open("output_filename.jpg", "w") { |outfile|
  outfile.write open("http://image_url.jpg") { |inf|
    ifile.read
  }
}
Jim W. (Guest)
on 2005-11-30 00:50
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 W.
lists (Guest)
on 2005-11-30 01:15
(Received via mailing list)
Thanks.

This is working like a charm!
james_b (Guest)
on 2005-11-30 01:19
(Received via mailing list)
Jim W. 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 .. (Guest)
on 2009-04-20 13:56
lists wrote:
> 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

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 C. (Guest)
on 2009-04-20 17:48
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? :-)
This topic is locked and can not be replied to.