Is there any way to check the height and width dimensions of an image uploaded with <cffile action="upload">? Or even just an image sent with a form.
The height and width of an image are stored inside the image and each image type (jpg, gif, bmp, png, ..) stores this differently. The best way to do this is to find a custom tag which can read the image formats you're interested in and have it run after the <cffile> upload. I would take a look in the Allaire Custom Tag Gallery as I'm sure someone has written a tag to retrieve the height & width from the popular formats.
ohhh... thanks for the response, but I don't think I have access to the server to install custom tags and such. I'll just see about finding a better way to do this.
Well, you could always use CFFile to open the image and read in the contents and parse out the height and width yourself. You would need to find the specs on the .jpg, .gif, etc.. file formats but this should be readily available. I would only recommend this as a last resort as that type of coding is no trivial task.
the following is JavaScript code that will return image width and height; note that image object has to be created and completely downloaded by the client BEFORE it can be accessed through images collection. another disadvantage is that this can work on the client side only. in other words, you will have to create a "dummy" page that will display the image, read the image params and submit that to cf server for processing;
like GunJack said, you have a choice of using the custom tag - the easiest and probably the best way to go, or basically, writing the code yourself that will "read" the image specs and return those values to you; using JavaScript is another way but somewhat amaturish - knowing that there is better way to accomplish this task...
good luck
<img src="images/default.jpg" width="100" height="44" border="0" alt="">
<script>
var w=window.document.images[0].width;
var h=window.document.images[0].height;
alert('image width: '+w+'; image height: '+h+';');
</script> Sylvano
dsylvano@hotmail.com
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.