Tips Station Asp.net Article Seo Articles
Tutorials Code Samples
›  Home
›  Mission
›  About us
›  Contact Us
›  Feedback
›  Terms & Condition
Asp Articles
IT Solutions
 
› ASP.NET

› Programming Tips

› Ajax

› Asp

› ADO.NET

› Databases

› SEO

› CSS And Designing

› Php

 
Most Viewed Articles
 
› Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.

› Change theme dynamically without page refresh in ASP.NET

› Simple ASP Image Resize Function

› Install AJAX On Machines Running Visual Studio 2005

› ASP.Net Interview Questions And Their Answers

› Creating Pretty Popups Using AJAX

› Encode Url using ASP

› SQL Server Performance Counters

› .NET Data Access Performance Comparison

› UpdatePanel control in Asp.net Ajax

more...
 
 
Home> Asp
 
Simple ASP Image Resize Function
 
This sample uses Chart object from OWC library to resize any image and convert the image to a specified format (.jpg, .png, .bmp, .gif...). The image is placed to the chart using SetTextured property, which can load any image file from a disk. Then you can use border property to set some frame around the image (or left the frame blank) and export the picture using ExportPicture method to a disk or get the picture as a binary data for BinaryWrite using GetPicture method.

  1. 'Resize image using ASP/VBS  
  2. '2007 www.motobit.com   
  3. Function ResizeImage(FileName, OutFormat, Width, Height)  
  4.   Dim Chs, chConstants  
  5.   'Create an OWC chart object  
  6.   Set Chs = CreateObject("OWC10.ChartSpace")  
  7.     
  8.   Set chConstants = Chs.Constants  
  9.     
  10.   'Set background of the chart  
  11.   Chs.Interior.SetTextured FileName, chConstants.chStretchPlot, , chConstants.chAllFaces  
  12.   Chs.border.color = -3  
  13.   
  14.   'Do something with border  
  15.   'Chs.border.color = &H0000FF  
  16.   'Chs.border.Weight = 3  
  17.   
  18.   'export the picture to a file  
  19.   'Chs.ExportPicture OutFileName, OutFormat, Width, Height  
  20.     
  21.   'or return it as a binary data for BinaryWrite  
  22.   ResizeImage = Chs.GetPicture(OutFormat, Width, Height)  
  23. End Function  
 
Upload and image resize sample

      Next piece of VBScript code if from the live resize sample and demonstrates the ResizeImage function. The source gif, jpeg or png image from upload is saved to a temp folder. The code reads data for the resize - new width and height and out format and then calls response.binarywrite ResizeImage().
  1. 'Set timeout to 30 minutes  
  2. Server.ScriptTimeout = 1800  
  3.   
  4. 'Set an upload limit to 5MB  
  5. Form.SizeLimit = 5*&H100000  
  6.   
  7. 'Set the destination path - Path to store uploaded files.  
  8. Dim DestinationPath: DestinationPath = Form.WindowsTemp & "\upload\"  
  9.   
  10. Const fsCompletted  = 0  
  11.   
  12. If Form.State = fsCompletted and len(Form("Image").FileName) >0 Then 'Completted  
  13.   'was the Form successfully received?  
  14.     
  15.     Form("Image").Save DestinationPath  
  16.       
  17.     Dim TempFileName, OutFormat, Width, Height  
  18.     TempFileName = DestinationPath & Form("Image").FileName  
  19.     OutFormat = Form("OutFormat")  
  20.     Width = clng(Form("Width"))  
  21.     if Width>8000 then Width = 8000  
  22.     Height = clng(Form("Height"))  
  23.     if Height>8000 then Height = 8000  
  24.       
  25.     'Export the picture from the ASP script  
  26.     response.ContentType = "image/" & OutFormat  
  27.     response.binarywrite ResizeImage(TempFileName, OutFormat, Width, Height)  
  28.   
  29.     createobject("Scripting.FileSystemObject").DeleteFile TempFileName   
  30.     response.end  
  31. ElseIf Form.State > 10 then  
  32.   Const fsSizeLimit = &HD  
  33.   Select case Form.State  
  34.     case fsSizeLimit: response.write  ".."  
  35.     case else response.write ".."  
  36.   end Select  
  37. End If'Form.State = 0 then  

 

 
 
Vrp Technologies
 
Serversea Hosting
 
 
Latest Articles
 
› Sending SMS With PHP

› MySQL Join Tutorial

› Make An RSS Feed Using PHP

› Intro To Object: Option Variables

› Design An Online Chat Room With PHP And MySQL

› Create Tell A Friend Script With HTML & PHP

› Benchmark And Optimize PHP Script Speed

› What Kind of DBA Are You?

› SQL Server Performance Counters

› SQL Server Performance Tips

more...
 
Random Articles
 
› Access Master Page controls from the Content Page - Asp.net

› Understanding VARCHAR(MAX) In SQL Server 2005

› UpdatePanel control in Asp.net Ajax

› Discovering Your Google PR (Page Rank) Value

› Make An RSS Feed Using PHP

› How to Send an Email in Asp.Net

› Creating Tableless Sites - Why And Some Basics

› Search Engine Friendly Web Design - 3 Ways To Use CSS

› Display records from Microsoft Excel in ASP

› Find which control caused a postback - Asp.net

more...
 
Home Mission About us Contact us Feedback Terms Conditions
2008 © Copyright TipsStation. All rights reserved.