ASP Forum
ASP - Get Image Size
blackey | Posted 2:24pm 6. November 2006 Server Time |

Is there anyway to get an image's size with ASP?

I currently have a page where people can upload their own pictures. I want to make a page that resizes the image height/width if it's too large. i.e. if width > 500 then width=500 else do nothing...
blackey | Posted 4:50pm 6. November 2006 Server Time |

Don't worry everyone i figured it out, i found a script that did exactly what i wanted.

<%
dim iWidth, iheight
sub ImgDimension(img)
dim myImg, fs
Set fs= CreateObject("Scripting.FileSystemObject")
if not fs.fileExists(img) then exit sub
set myImg = loadpicture(img)
iWidth = round(myImg.width / 26.4583)
iheight = round(myImg.height / 26.4583)
set myImg = nothing
end sub

ImgDimension(Server.MapPath("server image file"))
%>
WizzKidd | Posted 5:36pm 6. November 2006 Server Time |

Just curious blackey, is this a compoment you're using? It looks like it to me. Because as far as I am aware, loadpicture() is not an integrated asp function. Unless im wrong.

- WizzKidd
blackey | Posted 5:52pm 6. November 2006 Server Time |

Loadpicture() IS integrated...

http://www.w3schools.com/vbscript/func_loadpicture.asp
asp_asp | Posted 4:07am 20. February 2007 Server Time |

blackey hello!

      How come it won't work on me? I do this

function ImgDimension(img)
dim myImg, fs
Set fs= CreateObject("Scripting.FileSystemObject")
'if not fs.fileExists(img) then exit sub
set myImg = loadpicture(img)
iWidth = round(myImg.width / 126.4583)
iheight = round(myImg.height / 126.4583)
set myImg = nothing
end function

<%=ImgDimension(Server.MapPath("uploads/"&theID&"/p_gallery/"&request.QueryString("pic_name")&""))%>

It doesn't return any value :(
enigma | Posted 8:22am 20. February 2007 Server Time |

blackey & WizzKidd,

ImageMagick is one of the best, free, open source, and most compatible graphic manipulators that I have come accross.

http://www.imagemagick.org/script/index.php

Cheers,
enigma


Reply to Post ASP - Get Image Size



Back to Forum Page