I have a Classic ASP application running on IIS 7.5 (Windows Server 2008r2). What I need is actually pretty simple:
(1) Users upload an image.
(2) First thing is I want to dupe the image they uploaded so I have a "virgin" version and a "version we can play with". Everything below will be working on the "version we can play with" (the new/duped version).
(3) Resize the image to be 450w x 253h.
(4) I want to create a new image that is the same width as the old one but twice as tall (450w x 506h). I want to then copy the old image, putting one version of it above an exact duplicate; thus making the new image that is twice as tall as the original. Sort of like mirroring.
Preferred if there is a way to do this without a commercial component, like with .Net and I can call the .Net page/functions from my Classic ASP. My experience/knowledge is with vbScript (ASP) and barely any experience with VB in .Net.
Here is an image I made to try to explain what I'm doing: image of what I'm looking to build on the fly http://www.casemodo.com/images/image_build_on_the_fly.jpg
On this site I saw someone provide a solution for stacking images side-by-side instead of one-on-top-of-the-other like I want. Also the solution is written in C#, which I have zero experience with. Here is what they wrote:
Bitmap bitmap = new Bitmap(image1.Width + image2.Width, Math.Max(image1.Height, image2.Height)); using (Graphics g = Graphics.FromImage(bitmap)) { g.DrawImage(image1, 0, 0); g.DrawImage(image2, image1.Width, 0); }
What I need is someone to go super high level with me and show me how this would sit in a aspx file and perhaps even how I would call it from one of my Classic ASP pages. I know I'm asking for a lot. I just don't know how it can be done another way, except for perhaps spending money I don't have on a commercial ActiveX component I can call from Classic ASP.
Thanks for any help or direction you can give! Scott
This is a composite of a lot of things, as you know! It would be suprising if somebody wrote it for you. I don't have the time.
BTW, a commercial component would be just as hard to interface with, and I'd challenge you to find one to do this obscure thing ;-)
Make a .NET 'class library' (dll or assembly) with your functionality, not an ASP.NET program. You can call that directly from classic ASP...
Like this: http://support.microsoft.com/kb/817248
Or this: http://forums.asp.net/t/1442595.aspx/1
Bottom line is, you check something in the .NET project options 'expose to Com/ActiveX', and then, classic ASP will see it.
Simplest is to have the caller ASP generate a unique temp filename, save the file as that to the file system, pass the name to the .NET. I'll give pseudocode using that method.
You can pass the content as a large string, too, it could be converted in .NET using System.Text.Encoding. Safest would be base64, if you can go to and from that in ASP; strings might handle utf8, but if you get 'generic GDI+ error' from the .NET 'New Bitmap' line, the data is corrupt and the conversion is going wrong. First try the file method.
Note that in the file method sample I give, you'd replace the File names with Memory streams. which, you'd have to convert to/from the byte arrays. A few things to google, but if you can figure out ASP classic, you can figure that out using the search words I gave you.
You will have to lean on Intellisense, help, and google just a tiny bit here if there are typos.
Public Sub DoubleImage(FileIn as string, FileOut as string)
dim bmpIn as new Bitmap(FileIn)
dim bmpOut as new bitmap(bmpin.width,bmpin.height*2)
using g as new graphics.FromImage(bmpOut)
g.drawimage(bmpin,0,0,bmpin.width,bmpin.height)
g.drawimage(bmpin,0,bmpin.height,bmpin.width,bmpin.height)
end using
bmpout.save(FileOut)
end sub
Put this in a class library project, go to the properties and expose it to COM. Reference it from your ASP.
P.S. see the GDI+FAQ to learn how to grok .NET graphics: https://web.archive.org/web/20141230145656/http://bobpowell.net/faqmain.aspx