Is there any way to validate the width and height of image when uploaded? using javascript of server side ? like jsp, aspx etc?
A:
I've done this by execing the Image Magick "identify" command.
Easy enough if you're using Unix - although I think it runs on Windows too.
I doubt you can do it client-side.
Darren Greaves
2008-10-09 05:49:47
As far as I understand it, the question is about how you would do it in a server-side environment (using JavaScript, rather than something like PHP, for the server logic), so it's not client-side at all. :-)
Chris Jester-Young
2008-10-09 05:57:02
Ah yes, good point, I mis-read "using javascript of server side" to be "using javascript OR server side". :-)
Darren Greaves
2008-10-09 08:09:00
+1
A:
If you're using the Java platform, you can use ImageIO to read the image, then use getHeight
and getWidth
on the BufferedImage
returned from the read operation.
I admit this is quite a heavyweight approach, so I'm sure there is an even better approach. I just have to find it. :-P
As for .NET, I have no idea. :-)
Chris Jester-Young
2008-10-09 06:00:36