Forums

ASP

This topic is locked

C#/Image Resizer/globals?

Posted 24 Jan 2006 19:02:17
1
has voted
24 Jan 2006 19:02:17 Sarah Marshall posted:
Hi All,

This message has also been posted in the dreamweaver.appdev group. My apologies to those who read both groups...since th script is loosely related to DMXZone, I thought perhaps this was a better place to post.

I am working to shore up a DUGallery installation. This is an app that
allows the viewer to upload an image, creates a thumbnail on the fly, and
inserts the image path, title, description, height and width into the
database. The upload code is George Petrov's Pure ASP Upload. The height
and width inserted into the database are the result of a javascript fired on
submission of the form.

The problem: The height and width do not get inserted if the image is
uploaded via Firefox/Mozilla browser, because that browser's security
settings do not allow the javascript to access the file. (However, the
thumbnail is created perfectly and uploaded along with the original file.)

What I want to do: I want to capture the dimensions of the uploaded image
(which I know are determined via the aspx file --using
system.drawing.imaging, I think) and place those dimensions in a variable
that I can then use to input the dimensions in the database. I've found a
single post on the whole web by a person who has supposedly done this. He
writes: "I fixed it by rewriting the ASPX image resizer to return the
original sizes and I pass that to globals that insert the values in the
correct place in the DB. So I no longer have to worry about browser security
problems." Unfortunately, I have been unable to contact this person, and
despite hours of trying to decipher what he is saying, I have failed.

I am no .net programmer, and worse yet, the file is written in C#, which I
can barely spell. So...can anybody give me an idea of how to transfer
those width and height integers to the form (which is in a regular asp page)
so I can submit them to the Access database via the form? I will glady post
whatever code will assist in the efforts.

I'd be very grateful for any advice.

Sarah

Replies

Replied 26 Jan 2006 16:11:25
26 Jan 2006 16:11:25 Tom Theys replied:
take a look at this, maybe it helps
www.dmxzone.com/ShowDetail.asp?NewsId=564

or try this (haven't tested it)

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>GET SIZE</title>
</head>

<script language="javascript">
<!--
var origimg2;
function loadimgs2()
{
if (!document.images) return;
origimg2=new Image(); origimg2.src = ""+document.form2.img2.value;
waitforcomplete2();
}
function waitforcomplete2()
{
if (origimg2.complete)
{
document.form2.imgwidth2.value = origimg2.width;
document.form2.imgheight2.value = origimg2.height;
}
else setTimeout ("waitforcomplete2();", 500);
}
function preview2()
{
var imgwidth2 = (document.form2.imgwidth2.value.length<1 ? 400 : parseInt(document.form2.imgwidth2.value)+50);
var imgheight2 = (document.form2.imgheight2.value.length<1 ? 200 : parseInt(document.form2.imgheight2.value)+50);
prev = window.open('', '', 'width='+imgwidth2+',height='+imgheight2+',menubar=yes,resizable=yes');
prev.focus();
prev.document.open ("text/html";
prev.document.writeln ("<html><body bgcolor=\"white\" text=\"black\"><center><table width=100% height=100% border=0><tr><td align=center valign=middle><img src="+escape(document.form2.img2.value)+"></td></tr></table></body></html>";
prev.document.close();
}
//-->
</script>

<body>
<form name="form2">
<table border="1" align="center" width="440" bgcolor="#cccccc" cellpadding="2">
<tr>
<td align="left" valign="top" width="440">
<font face="Times New Roman" size="2"><b>If your image is on a server...</b></font>
<p><font face="Times New Roman" size="3">Enter the full Url without the "". The image you chose must be in .jpg or .gif format.</font>
<p><font face="Times New Roman" size="3"><b></b>
<input type="text" name="img2" size="14">   <input type="button" value="Detect Size" onClick="loadimgs2();">   <input type="button" value="View" onClick="preview2();"></font>
<p><font face="Times New Roman" size="3">Width of this image: <input type="text" name="imgwidth2" size="3">   Height of this image: <input type="text" name="imgheight2" size="3"></font>
</td>
</tr>
</table>
</form>


</body>
</html>
Replied 28 Jan 2006 04:27:22
28 Jan 2006 04:27:22 Sarah Marshall replied:
Tom,

Thank you very much for taking the time to post. The untested code you provided works perfectly; I'm working to integrate it with my existing pages. I don't have it figured out yet, but will post back when I do. I'm also looking into the code posted on 4Guys from Rolla.

You've given me a new direction. Thank you.

Reply to this topic