www.webdeveloper.com
Results 1 to 2 of 2

Thread: how to get jpeg original size?

  1. #1
    Join Date
    Aug 2010
    Location
    San Diego
    Posts
    242

    how to get jpeg original size?

    If I get the size of an image like so
    Code:
    var w = $("#myPicture").width;
    var h = $("#myPicture").height;
    the dimensions are the image's size as displayed in the browser, which might not be the image's original size. What's the best way to get the original size of the image?

  2. #2
    Join Date
    Aug 2010
    Location
    San Diego
    Posts
    242
    I think this works, create a new Image like so and the new image's width and height properties will be that of the unresized original image.

    Code:
    function unresizedImg ( img ) {
    	var unresized = new Image();
    	unresized.src =  img.src;
    	return unresized;
    }
    I hope this isn't re-getting the jpeg over the net again. If anyone knows a better way please let me know.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles