For Programmers: Free Programming Magazines  


Home > Archive > ASP > May 2006 > COM object for image processing in ASP









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author COM object for image processing in ASP
Paul

2006-05-30, 6:56 pm

Hi all,

I've been using ASPImage and it frequently causes IIS to crash. Do any
of you have a good alternative to suggest?

I need something to handle resizing and cropping.

Any suggestions would be much appreciated.

Thanks,

Paul

Justin Piper

2006-05-31, 6:56 pm

On Tue, 30 May 2006 19:33:20 -0500, Paul <paul.hester@gmail.com> wrote:

> Hi all,
>
> I've been using ASPImage and it frequently causes IIS to crash. Do any
> of you have a good alternative to suggest?
>
> I need something to handle resizing and cropping.


ImageMagick includes a COM object that may be suitable. The COM object
itself isn't particularly well-documented, but most of the functionality
it offers can be gleaned from the documentation for the command line
tools. I have included at the end of this article an example that will
create 64x64 thumbnails of all the images in the current directory.

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

Example follows:
Option Explicit

' = Function: Resize =
' Use an instance of the ImageMagickObject to change the dimensions of
' an image, preserving its aspect ratio.
'
' Arguments:
' im - An instance of the ImageMagickObject.
' src - The name of the source file.
' dst - The name of the destination file.
' width - The desired maximum width
' height - The desired maximum height
Function Resize(im, src, dst, width, height)
Dim msgs
msgs = im.Convert(src, "-resize", width & "x" & height, dst)
End Function

' = Function: Main =
' The entry point for the script.
'
' Returns:
' The script exit code
Function Main()
Dim im, fso, wd, file

Set im = CreateObject("ImageMagickObject.MagickImage.1")
Set fso = CreateObject("Scripting.FileSystemObject")
Set wd = fso.GetFolder(".")

For Each file In wd.Files
On Error Resume Next
Resize im, file.Name, "thumb_" & file.Name, 64, 64
On Error Goto 0
Next

Main = 0
End Function

WScript.Quit Main()


--
Justin Piper
Bizco Technologies
http://www.bizco.com/
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com