Print Page | Close Window

ASPImage Image Resize Re-Size

Printed From: Web Wiz Forums
Category: Web Wiz Web App Support Forums
Forum Name: Web Wiz Forums
Forum Description: Support forum for Web Wiz Forums application.
URL: https://forums.webwiz.net/forum_posts.asp?TID=6015
Printed Date: 12 April 2026 at 4:23am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: ASPImage Image Resize Re-Size
Posted By: JohnnySlotCar
Subject: ASPImage Image Resize Re-Size
Date Posted: 27 September 2003 at 12:56pm

Has anyone gotten ASPImage 2.0 to work as an uploaded image file resizer?  If so, could you share code?

Thanks in advance - looking for ways to limit my uploaded images to 390px wide.

Johnny




Replies:
Posted By: Corobori
Date Posted: 27 September 2003 at 3:13pm

Look at the code shown below, this load an image using SA File UP then makes two pics of it a bigger and a smaller one.

I have a slightly more complicated sample showing how to use ASPImage to cut off parts of an image, draw a circle, write a text here: http://www.corobori.com/Image.asp - http://www.corobori.com/Image.asp

cSizeBigPic=500
cSizeSmallPic=250

sFileName0n = "REG" & lRe_Id & "."   &  Mid(upl.Form("fi_ImageToUpload").UserFilename, InstrRev(upl.Form("fi_ImageToUpload").UserFilename, ".") + 1)   
sFileName1n = Server.Mappath("../Pics") & "\"   & sFileName0n
sFileName0p = "REC" & lRe_Id & "."   &  Mid(upl.Form("fi_ImageToUpload").UserFilename, InstrRev(upl.Form("fi_ImageToUpload").UserFilename, ".") + 1)
sFileName1p = Server.Mappath("../Pics") & "\"   & sFileName0p
         
'on error resume next
'upl.Delete sFileName1
Err=0
          
upl.Form("fi_ImageToUpload").SaveAs sFileName1n
            
Set Image = Server.CreateObject("AspImage.Image")
Image.LoadImage (sFileName1n)

image.GetImageFileSize sFileName1n,iX,iY
                                
if cint(iX) > cSizeBigPic then
    intYSize = (cSizeBigPic / Image.MaxX) * Image.MaxY
 Image.ResizeR cSizeBigPic, intYSize

end if
image.FileName = sFileName1n
   
image.SaveImage
               
image.LoadImage (sFileName1n)

image.GetImageFileSize sFileName1n,iX,iY
                                
if cint(iX) > cSizeSmallPic then
    intYSize = (cSizeSmallPic / Image.MaxX) * Image.MaxY
    Image.ResizeR cSizeSmallPic intYSize

end if
image.FileName = sFileName1p
   
image.SaveImage       &nb sp; 
                            
if Err <> 0 Then 
 sError = err.description  & " " & Err.number & "<BR>"
else
 sSQL = " UPDATE tblMYtable "
 sSQL = sSQL & " SET    Re_ImageSmall ='" & sFileName0p & "', "
 sSQL = sSQL & "        Re_ImageBig ='" & sFileName0n & "' "
 sSQL = sSQL & " WHERE Re_Id = " & lRe_Id
 Set cmdTemp.ActiveConnection = conCorpocas
 cmdTemp.CommandText = sSQL
   
 on error resume next
 cmdTemp.Execute 
 if Err <> 0 Then 
  sError = err.description  & " " & Err.number & "<BR>"
 end if
end if


 



Posted By: JohnnySlotCar
Date Posted: 28 September 2003 at 9:36am

I appreciate both pieces of code!  My ISP only supports ASPImage 2.0 at the moment, but I see what you're doing in the prev. message...

May be you can help me with this ASPImage code.  I have placed the following in upload_images.asp, on about line 190-200 (right above the 'post back' statement):

'###################################

Dim Image

Set Image = Server.CreateObject("ASPImage.Image")

Dim intXSize
Dim intYSize
intXSize= 390

Image.LoadImage strFileUploadPath & "strImageName"
Image.FileName = strFileUploadPath & "strImageName"
Image.ImageFormat = 1
Image.JPEGQuality = 60

intYSize = (intXSize / Image.MaxX) * Image.MaxY

Image.ResizeR intXSize, intYSize

Image.SaveImage

Set Image = nothing

'###################################

My file still uploads, but no resizing.  The intYSize should support proportional resizing according to the docs - can anyone help with this?  Again, I am trying to resize uploaded images to 390px wide.

Thanks in advance!

Johnny
http://www.shoost.com/JohnnySlotCar - http://www.shoost.com/JohnnySlotCar

 



Posted By: martionline
Date Posted: 04 February 2005 at 5:54pm
plz i need this code too help about aspimage



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net