fischadler
Programmer
Is there a way an ASP page can determine the size (width x height) of a picture file without having to use any third party applications/dlls?
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
<script>
function sizer(imgObj){
imgWidth = imgObj.width
imgHeight = imgObj.height
maxWidth = 100
maxHeight = 75
if (imgWidth > maxWidth){
imgObj.width = maxWidth
newRatio = imgWidth / maxWidth
imgObj.height = imgHeight / newRatio
}
imgWidth = imgObj.width
imgHeight = imgObj.height
if (imgHeight > maxHeight){
imgObj.height = maxHeight
newRatio = imgHeight / maxHeight
imgObj.width = imgWidth / newRatio
}
}
</script>
<img onLoad="sizer(this)" src="myImg.jpg">
function sizeall(){
var imgObj = document.getElementsByTagName("img");
for (var i=0; i<imgObj.length; i++){
sizer(imgObj[i]);
}
}