Pieter Cooreman
Developer QuickerSite

Image Resizing, Recoloring and Cropping

Classic ASP Developers never had an easy way to resize, recolor and crop images, unless they used expensive 3rd party Image components.

Therefore I decided to come up with something useful. The script offered for download below this page takes care of the following:

  • automatically resize images
  • recolor images
  • crop images

I am using this resizing-trick for some years in QuickerSite (, a Classic ASP CMS that I develop, sell and support.

Enjoy !

Download Code!

U like this? Please consider to buy me a beer :)

Joe Conti says (08/03/2019 07:56:28):
Thank you for this. Still using classic ASP. Works fine for me. Your little code did wonders for me. Thank you :)
Alvaro Brayan says (21/02/2019 10:57:04):
Where is the location/path of the image resized so that I upload it to server?
Thanks :]
venett says (29/08/2018 21:23:07):
I have tried and it runs faster, I want to use it for resizing the huge files the users upload from their cellphones but I understand is a rezer on the fly.

Are there a way to save the resized images for saving disk space in the hosting?

thanks friend
Stephane says (05/07/2017 19:59:48):
I'm wondering why you are rotating 2 times the fullsize image ?

Would'nt that flip the picture upside down ?
Anon says (23/06/2017 09:12:26):
Hi Pieter

I have replaced
ImageObj.Save(Response.OutputStream, ImageFormat.png)

With this:

Dim io As New MemoryStream(100)
ImageObj.Save(io, ImageFormat.Png)
Dim ba As Byte() = io.GetBuffer()

and now my png transparency seems to display Ok, but it is not saving with tarnsaparency.

around line

ImageObj.Save(Server.MapPath(sOutputURL), ImageFormat.Png)

Any ideas. Thansk in advance
ran says (01/03/2016 14:58:24):
why in some pictures it totally reduce quality ? (FSR=1)
Marco says (17/07/2015 14:06:46):
Hi, you have done a great job!
I have a problem with png, when i use png do not display image...

Any help?
This script only works for jpg files.
Jerry says (20/11/2014 15:57:57):
Awesome! Thanks for the tip. Works like a charm.

Jerry says (19/11/2014 22:55:33):
I downloaded the code and it works fine the first time, but if I upload a new original file the resizer does not run correctly. I get back the original image. If I recycle the application pool, then it correctly resizes the newly uploaded image. It seems there is some object in the .Net page not being destroyed correctly. Do you have any ideas? I am not familiar with .Net so I am poking blind.

Thanks for the awesome tool though. Once I resolve this it should work perfect for our needs.

remove fhe first line in showthumb.aspx that reads: <%@ OutputCache Duration="600" VaryByParam="*" %>

This is .net output caching. You may have to get rid of it in your application.
Tomaso says (20/07/2014 18:59:09):
Very nice and good script, it saves me a lot of time!
There is any chance that it works with a url image and not only a path (www.yyyy.kk/image.jpg instead of /public/image.jpg)

tnx a lot
Hello Tomaso, this can work, but it requires quite a rework. The image needs to be loaded from an url, rather than from the local disk (server.mappath). I'm not an ASP.NET export, but I think this can rather easily be added to the code... Not sure though?
Alan says (21/05/2014 20:18:42):
I have captured these errors in a powerpoint slide. but the error reads:
Warning BC42021: function without an 'As' clause: return type of object assumed

in lines 293 and line 312

does this help ?
Does it help to add "as System.Drawing.Bitmap" to these lines?

Like this:

Public Function GrayScale (ByVal image As System.Drawing.Bitmap) as System.Drawing.Bitmap
Alan says (21/05/2014 18:43:31):
As far as I can check I am running v2.0.50727 plus later versions. In IIS the .net compilation basic settings is set to AppPool. thats about my limit with .net configurations im afraid, is ther any other information I can give you ?

Alan, what does your browser return when you call the url to showthumb.aspx directly? Like: ....
Alan Cook says (21/05/2014 12:13:57):
Hi, I downloaded your image resizing code about a month ago for a family history web site I have been developing. It worked brilliantly first time and for about a month but now it has suddenly stopped working. All I get when I try to load an image is the little red cross - on any of my pages using images. Could you possibly point me in the right direction to try and resolve this - I will happly buy you a beer if you can help, this is a brilliant package that I want to use. Thanks Alan
Alan, all I know is that this script requires ASP.NET 2.0. I have never tested it on newer versions of ASP.NET (3.5 or 4). Which version of ASP.NET are you using?
Dave says (01/12/2013 22:52:43):
Is there anyway to make it overwrite an existing image, i.e. where IptFl and OptFl are the same value?

Dave, I assume you refer to the version of my script on You may want to ask over there... My version of the script does not support (over)writing images for security reasons...
Dave says (01/12/2013 22:52:22):
Is there anyway to make it overwrite an existing image, i.e. where IptFl and OptFl are the same value?

steve says (25/06/2013 02:18:15):
This works great on images. I was wondering if there was a way to use this in conjunction with a jscript for arrays. I'm pulling data from sql using classic asp. I want to create script array from data(image) and perform on mouse out and mouse over using this aspx code. Is this possible? So far I have :
if rs("image2") <> "" then


<script type="text/javascript">
var imgArray = new Array(
imgArray[0] = <%= rs("image2").Value %>;
imgArray[1] = <%= rs("image3").Value %>;
imgArray[2] = <%= rs("image4").Value%>;
imgArray[3] = <%= rs("image5").Value %>;
imgArray[4] = <%= rs("image6").Value %>;
imgArray[5] = <%= rs("image7").Value%>;
imgArray[6] = <%= rs("image8").Value%>;
imgArray[7] = <%= rs("image9").Value%>;
imgArray[8] = <%= rs("image10").Value%>;

var imgPath = "media/images/";

function swapImage(imgID) {
var theImage = document.getElementById('theImage');
var newImg;
newImg = imgArray[imgID];
theImage.src = imgPath + newImg;

function preloadImages() {
for(var i = 0; i < imgArray.length; i++) {
var tmpImg = new Image;
tmpImg.src = imgPath + imgArray[i];

<% end if%>

using this I call

float:left"><img src="Resize_Image.aspx?ImgWd=100&IptFl=media/talentMedia/<%=rs("image2")%>" onmouseover="swapImage(0)" onmouseout="swapImage(5)"/></div>

nothing happens.
Thanks in advance
Darryl says (10/05/2013 13:13:16):
is it possible to resize images from another site that i have linked to my site

currently when i put the full URL in it doesnt work.
nope... but you can use CSS to resize images in that case. (style="width:300px")
Ben Ellingson says (24/04/2013 02:04:27):
Pieter - a final note... (I couldn't let it go.)

I replaced this:

ImageObj.Save(Response.OutputStream, ImageFormat.png)

With this:

Dim io As New MemoryStream(100)
ImageObj.Save(io, ImageFormat.Png)
Dim ba As Byte() = io.GetBuffer()

& now the PNG w/transparency is being saved AND displaying to the screen.

Thanks again for setting me on the right path!

Thanks for sharing Ben. It's weird though. For me, that output to screen works fine on my code. I did not test the savetofile though. If ever I face issues, I'll be happy to rely on your fix.
Ben Ellingson says (23/04/2013 23:28:52):
Hey Pieter - thanks so much for your quick response! I have added in the PNG-specific code from your file & now they're saving with transparency, no problem. On an interesting side note (one that doesn't actually matter for my purposes) the re-sized PNG isn't displaying on the screen when the source is coming back through the .aspx file even though it's saving to a directory just fine. Seems that maybe the "Response.OutputStream" is not sufficient for a PNG in that regard.(?) Anyway... thanks again!
Ben Ellingson says (23/04/2013 00:59:08):
Pieter - got the "EasierThan" version working in a snap. This is quite helpful for a Classic ASPer! One question though: PNG transparency is saving as black for me. Any ideas on how to keep it clear?


Ben, the version available download right now (uploaded it a minute ago) fixes the png-problem. Still not working for GIF's though, but who uses GIF's today?
TigerTiger says (21/03/2013 21:29:18):
Stephane says (11/03/2013 15:35:11):
Hi Pieter,
Thank you very much for this, have you finaly add the width and height in your code ?

I have my own ASP Classic CMS since 2002 but still need a dll (aspimage or aspjpg...) and i'm very happy to be able to use something free.

Maybe we can talk about ASP Classic together, i have done some stuffs I can share with you (class form for exemple but you should have your own i guess ;) )

Ok, btw thank's a lot !

See you,
David Barton says (16/02/2013 21:44:59):
Hi Pieter,

I've uploaded the amended version to my blog:

Please have a look and check you're happy.

I hope it may prove of some use to yourself or others.

Thanks again,
EasierThan Website Design
David Barton (EasierThan Website Design) says (15/02/2013 15:50:25):
Hi Pieter,

Many thanks for the code. I've taken it and adapted it significantly to include querystring options for height, width, cropping, padding (with specified colour), input and output locations, option not to output to screen and existing special effects, along with annotation and instructions.

I was thinking of adding the result to my blog: where I've also published a couple of other such solutions.

I would acknowledge and carry links through to yourself as the original source (and to your CMS site under an appropriate title if you like).

As the original author, I thought it polite to ask your thoughts before proceeding.

Best Regards,
EasierThan Website Design
Hello David, thanks for asking. I appreciate. Please share your work. I'll be the first the download and study it. Pieter
Scott Swain says (03/10/2012 23:46:26):
I'm stumped :-(
When I use ImageObj.Save(Response.OutputStream, ImageFormat.Jpeg), along with my new querystring param mods to your aspx, it works.
When I use ImageObj.Save(Server.MapPath(imageUrl), ImageFormat.Jpeg), it does not work.
If I knew a way to have your file redirect or a way to call your file server-side, then I bet I could get it working... ideas? Thanks! Sorry if I'm throwing a lot at you! Happy to send you my code to look at if you want.
Scott Swain says (03/10/2012 23:32:58):
Aha! I realized When I changed ImageObj.Save(Response.OutputStream, ImageFormat.Jpeg)
ImageObj.Save(Server.MapPath(imageUrl), ImageFormat.Jpeg), it was no longer supplying my client-side image display with a valid SRC! OK so now I need to figure out how to make this thing change the file on the server...
Scott Swain says (03/10/2012 23:20:00):
I tried adding a button on my Classic ASP page that displays the image and has a "browse" button (the first page I mentioned above that sends to the receiving page). The button's onclick event calls some javascript that replaces the SRC value of the IMG tag with ImageResize.aspx?newWidth=263&newHeight=392&img=images/kc/00000016.jpg.
Oh and yeah I renamed (to "ImageResize.aspx") and added to your ASPX file the ability to receive and use "newWidth" and "newHeight". Anyway, when I click the button, what I get is a javascript error: GET 500 (Internal Server Error)
Scott Swain says (03/10/2012 22:55:43):
Hi! Thank you so much for creating this and putting it out there for free use! You partially answered my question above with your answer to Roy Walters. I have an ASP page where a user uploads an image via form submission. The receiving ASP page then sends the image file name to a database. I'd like in that page to call your ASPX page and then redirect to another ASP page. The part I'm unclear with is what other ways (besides what you show as img src) I can call your code? Optimally I could call it with my image receive page, sending the parameters you ask for but adding a "url" parameter so your page, when done processing, would then redirect to the url. But I don't know .Net so I don't know how to modify your code to include that redirect. Ideas?
Manish Gupta says (10/09/2012 06:57:11):
Thanks for the code and sorry for my little knowledge of ASP.NET. I downloaded the code in wwwroot folder and directly ran the default.asp file but it seems like image is not auto-resized.

Do I need to do anything special in order to configure the aspx page. My machine is WinXP with IIS5.1 and ASP.NET Version is 4.0.

Appreciate your help.
Hello, make sure ASP.NET is activated in your local IIS. It is not always automatically the case. Actually, I think ASP.NET 4 does not fit into IIS5.1. You may have to install a ASP.NET2 package and select 2.0 as the default version in your IIS.
Roy Walters says (01/03/2012 12:24:50):
asp resizer: thanks for this. I was starting to despair as I was relying on asp to achieve this. I've uploaded a few dlls to attempt this but nothing has (to date) worked. Nice clean fix thanks :-)

now I need to find a way to write the resulting thumbnails back to the server...

best wishes, Roy (UK)
hello Roy, you can easily achieve that by changing the line:

ImageObj.Save(Response.OutputStream, ImageFormat.Jpeg)


ImageObj.Save(Server.MapPath(imageUrl), ImageFormat.Jpeg)

be aware though that this line erases the original file. you may want to alter the file name/path

Leave a message:

Your name:*
Your email:
Your message:*
Are you human?CAPTCHA
(*) Mandatory field