Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
|
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 29th, 2007, 11:37 AM
tal tal is offline
Authorized User
 
Join Date: Apr 2007
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default Get image size without loading?

Hi all,
Any ideas how to retrieve image size without loading it?
What i found so far is no good: using the img tag or the Image object won't work, since the image has to load first (which happens asynchronously). On the other hand, using the onload function is also no good: i lose context till the loading is finished.:(

Any Ideas

 
Old June 30th, 2007, 12:16 AM
Authorized User
 
Join Date: Jun 2007
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi tal

What is your server side technology ?

I think you can load your image on server side using an image manipulation library, obtain it's size and retrieve it on client side using AJAX.

Ehsan Zaery Moghaddam
 
Old June 30th, 2007, 05:55 AM
tal tal is offline
Authorized User
 
Join Date: Apr 2007
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hmm, that's an interesting idea, i'm sure i can implement it easily.
Although it could have been much cooler to have something ready :(

 
Old June 30th, 2007, 07:05 AM
Friend of Wrox
 
Join Date: Nov 2005
Posts: 223
Thanks: 0
Thanked 0 Times in 0 Posts
Default

To get the size of an image with javascript the image will have to be loaded in your browser first you could make a pre-loader (which i do not recommend) but the best way is just to get the image size with PHP,ASP,JSP or what ever serverside scripting you use.

__________________________________________________ ________
I am DJ Kat...that's my name. Its a D and a J and a Kat with a K.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Loading Image to Image Control using JavaScript ctranjith General .NET 1 May 28th, 2013 05:43 AM
image loading abaso.jadhav01 ASP.NET 2.0 Basics 0 October 28th, 2006 01:24 AM
Loading a jpg and determining the pixel size jaucourt Flash (all versions) 0 January 19th, 2005 07:09 AM
loading pages with custom size, toolbars etc dunc Javascript How-To 6 August 18th, 2004 04:37 PM
control window loading size, toolbars etc dunc Javascript How-To 1 August 18th, 2004 06:33 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.