Home     Products      Support      Corporate     Sign In 
Support Knowledge Base, Article 220
Product
ImgWriter
Version
1.x
Title
HOW TO: Upload and modify an image using ImgWriter and FileUp
Problem

The following sample demonstrates how to upload and modify an image then save it, as well as the image in its original state.
Solution

The recommended method to manipulate and upload an image then save both the modified and original images, is to use ImgWriter and FileUp together. First use FileUp to extract the binary contents from the file. Load the binary data into ImgWriter, then with the ImgGen object manipulate the image and save to its destination.

Here is a sample which demonstrates how to use FileUp's UseMemory and UploadContents properties to extract the image's binary contents, before loading it into ImgWriter.

<% 

Set Upload = Server.CreateObject("SoftArtisans.FileUp")

'---tell FileUp to store file in memory
Upload.UseMemory = True
Dim origFilename, strFullFileName, strResizedFileName 

'---extract user's original filename
origFilename = Mid(Upload.UserFilename, InstrRev(Upload.UserFilename, "\") + 1)

'---designate paths to save both images
strFullFileName = "C:\originalimages" & "\" & origFilename
strResizedFileName = "C:\resizedimages" & "\" & "RESIZED" & origFilename

Dim saImgWriter 
set saImgWriter = Server.CreateObject("SoftArtisans.ImageGen")

'--- Load binary data into ImgWriter from FileUp	
saImgWriter.LoadImage Upload.UploadContents(2)
set Upload = nothing

'--- Save full-sized image	
'--- NOTE:  this is assuming jpegs
saImgWriter.SaveImage saiFile, saiJPG, CStr(strFullFileName)

'--- Resize image (could also use CreateThumb())	
saImgWriter.ResizeImage 200, 150

'--- Save smaller image	
saImgWriter.SaveImage saiFile, saiJPG, CStr(strResizedFileName)

%>
Created : 1/15/2003 12:00:00 AM (last modified : 1/23/2003 9:09:28 PM)
Rate this article!
 
Comments