image naturalWidth return zero... that's it, why ?
var newimage = new Image(); newimage.src = 'retouche-hr' + newlinkimage.substring(14,17) + '-a.jpg'; var width = newimage.naturalWidth; alert (width);
HELP, i dont know why !
*** that path is good, the image show up !
The naturalWidth property returns the original width of an image. For example, if you have an image that is originally 100 pixels wide. Then, you style the image with CSS/or by using the HTML "width" attribute to make it 500 pixels wide.
Definition and Usage The naturalHeight property returns the original height of an image. For example, if you have an image that is originally 200 pixels high. Then, you style the image with CSS/or by using the HTML "height" attribute to make it 500 pixels high.
I'd guess it's because you're not waiting for the image to load - try this:
var newimage = new Image(); newimage.src = 'retouche-hr' + newlinkimage.substring(14,17) + '-a.jpg'; newimage.onload = function() { var width = this.naturalWidth; alert(width); }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With