473,403 Members | 2,284 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

Reading Image File Size

Is there a way to read the file size of images with JavaScript ? I know
how to read the width and height.

Later, Art.

Jul 23 '05 #1
5 13677


Wazz Up wrote:
Is there a way to read the file size of images with JavaScript ?


I think only IE exposes a property named fileSize e.g.

var img = new Image();
img.onload = function (evt) {
alert(this.fileSize);
}
img.src = 'kiboInside.gif'

but other browsers (at least Mozilla and Opera) do not provide that
property.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #2
Thanks for your reply and info Martin.

Because of the lack of cross browser compatibility, perhaps I should
wait until I learn a server side language. Of course I got a long way to
o with JavaScript before I go there.

Later, Art.

Jul 23 '05 #3
Wazz Up wrote on 27 dec 2004 in comp.lang.javascript:
Thanks for your reply and info Martin.

Because of the lack of cross browser compatibility, perhaps I should
wait until I learn a server side language. Of course I got a long way to
o with JavaScript before I go there.


Javascript is also a serverside language under ASP.

Don't say Javascript if you mean clientside script.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 23 '05 #4
Martin Honnen wrote on 27 dec 2004 in comp.lang.javascript:
I think only IE exposes a property named fileSize e.g.

var img = new Image();
img.onload = function (evt) {
alert(this.fileSize);
}
img.src = 'kiboInside.gif'


I don't know what the "evt" is for.

========== try this [IE6]:

<img src = 'kiboInside.jpg'
onload = "this.alt=this.fileSize+' bytes'">

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 23 '05 #5
Wazz Up wrote:
[...]
I know how to read the width and height.


For some browsers, width and height attributes will only be "readable"
if set. If an image is placed with:

<img src="someImage.jpg" alt="an image">

and you try to read the width or height, you will get undefined.

--
Rob.
Jul 23 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: John | last post by:
I have over 5000 thumbnail pictures of size 5kb each. I would like to able to load all 5000 pictures and view 50 per page using mysql_data_seek(). I would like to know what are the advantages and...
3
by: dave | last post by:
Hello there, I am at my wit's end ! I have used the following script succesfully to upload an image to my web space. But what I really want to be able to do is to update an existing record in a...
4
by: Will McGugan | last post by:
Hi, I'm writing an app that downloads images. It rejects images that are under a certain size - whithout downloading them completely. I've implemented this using PIL, by downloading the first K...
12
by: jcrouse | last post by:
I am using the following code to write to an XML file myXmlTextWriter.Formatting = System.Xml.Formatting.Indente myXmlTextWriter.WriteStartElement("CPViewer"...
3
by: Brad | last post by:
I'm working on a web app which will display LARGE tiff image files (e.g files 10-20+ mb). Files are hidden from users direct access. For other, smaller image files I have used FileStream to read...
2
by: Cameron Walsh | last post by:
Hi all, I'm trying to extract the data from a bitmap or .pnm file using the following code: import Image img = Image.open("test.bmp","r") data=img.getdata() Unfortunately I get the...
0
by: doubts | last post by:
Hi, I have a query regarding reading Image Property for button from a XML file . I read XML files to Generate Screens using System.Windows.Forms.Controls .The XML file is read and properties...
4
by: cyberco | last post by:
I'm using web.py to send an image to the client. This works (shortened): print open(path, "rb").read() but this doesn't: img = Image.open(path) img.thumbnail((10,10)) print img.getdata()
16
by: Jm.GlezdeRueda | last post by:
Hi all, Im trying to read a 24bit bmp with fread, and i have some problems.. I want to read the whole structure in one time, but i dont know why, it only reads the first member well.. I have...
2
by: Adam Teale | last post by:
hey guys Is there a builtin/standard install method in python for retrieving or finding out an image's dimensions? A quick google found me this:...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.