AspImage Sample Code

ASPImage allows you to create images on the fly from ASP. Features include:

  • Create GIF* (RLE encoding only. Loading of GIFs not supported) JPG, PNG, BMP, TGA and PCX format images.
  • Modify existing images (JPG, BMP, PNG, TGA and PCX)
  • Gradient fills
  • Animated GIF creation
  • A large variety of draw methods
  • Transparent PNG and GIF

 

<%  
 
      Set Image = Server.CreateObject("AspImage.Image")  
        
        rem Set various font parameters  
        Image.FontColor = vbBlack 
        Image.Italic = True 
        Image.Bold = True 
        Image.FontName = "Arial" 
        Image.FontSize = 12 
        Image.PadSize = 10 
        
        rem Calculate how big our text info is and set the image to this size  
        rem  This has to be done since we want to fill the area with a gradient  
        strMessage = "Welcome to" 
        ImageImage.MaxX = Image.TextWidth (strMessage)  
        ImageImage.MaxY = Image.TextHeight (strMessage)  
        
        rem Create a one way gradient  
        Image.GradientOneWay vbRed, vbWhite, 0  
        
        rem Print our string to the image  
        Image.TextOut strMessage, Image.X, Image.Y, false  
        
        rem Set the filename and save  
        Image.FileName = "d:\inetpub\wwwroot\images\msg1.jpg" 
        if Image.SaveImage then  
          rem The image was saved so write the <img src> tag out for the browser to pick up  
          Response.Write "<img src=""/images/msg1.jpg""><br>"  
        else  
          rem Something happened and we couldn't save the image so just use an HTML header  
          rem   We need to debug the script and find out what went wrong. See Image.Error for details  
          Response.Write "<h2>Welcome to</h2>"  
        end if  
 
%> 
 

Article ID: 320, Created On: 4/24/2009, Modified: 4/25/2009