[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Check Image File Size

Tj Superfly

4/8/2008 1:54:00 AM

Hello everybody,

I'm looking for a way that I could insert a URL for an image that is
online and have it tell me what size it is?

I've been messing around with File.size? and file.size and havn't quite
gotten it to work, am I missing something?

Thanks in advance.
--
Posted via http://www.ruby-....

2 Answers

Philipp Hofmann

4/8/2008 2:54:00 AM

0


how about

require 'open-uri'
open(ARGV[0]) { |f| puts f.size }

i'm not sure if this will GET the file even if you don't access its
data, because the size info should already have been communicated
within http, in that case there might be are more convinient way only
using http probing for the size.

g phil


On Tue, Apr 08, 2008 at 10:54:23AM +0900, Tj Superfly wrote:
> Hello everybody,
>
> I'm looking for a way that I could insert a URL for an image that is
> online and have it tell me what size it is?
>
> I've been messing around with File.size? and file.size and havn't quite
> gotten it to work, am I missing something?
>
> Thanks in advance.

Phillip Gawlowski

4/8/2008 3:00:00 AM

0

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Tj Superfly wrote:
| Hello everybody,
|
| I'm looking for a way that I could insert a URL for an image that is
| online and have it tell me what size it is?
|
| I've been messing around with File.size? and file.size and havn't quite
| gotten it to work, am I missing something?

Have you tried downloading the image? Or at least an HTTP connection?

AFAIK, HTTP doesn't provide an option to detect the size of a file
without downloading (might be wrong, never messed around with HTTP
headers). (S)FTP might, though, but that requires an open FTP connection.

In any case, you'll need an open network connection to the file.

- --
Phillip Gawlowski
Twitter: twitter.com/cynicalryan

~ That's the difference between me and the rest of the world! Happiness
isn't
good enough for me! I demand euphoria! -- Calvin
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.8 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail....

iEYEARECAAYFAkf635oACgkQbtAgaoJTgL91cwCaAxGjpnWuNkt51jsYXU5PpZwO
l+0AnRQctV3ydxCp4hHU8dhcBOHzJp9+
=BEvE
-----END PGP SIGNATURE-----