Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Community Discussions (All other subjects)
 grabbing image height and width in JS
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

redbrad0
Advanced Member

USA
3725 Posts

Posted - 02 December 2002 :  04:00:26  Show Profile  Visit redbrad0's Homepage  Send redbrad0 an AOL message
I know i have saw a piece of code before that you could select an image on your hard drive and with js it would fill in 2 text boxed one with height and one with width. does anyone know where i can find code like this?

Brad
Oklahoma City Online Entertainment Guide
Oklahoma Event Tickets

Gremlin
General Help Moderator

New Zealand
7528 Posts

Posted - 02 December 2002 :  04:07:05  Show Profile  Visit Gremlin's Homepage
http://www.experts-exchange.com/Web/Web_Languages/JavaScript/Q_20322154.html

Kiwihosting.Net - The Forum Hosting Specialists
Go to Top of Page

dayve
Forum Moderator

USA
5820 Posts

Posted - 02 December 2002 :  13:10:41  Show Profile  Visit dayve's Homepage
here is something I shared with everyone awhile back...

http://hafresno.org/development/imgSize.htm

Go to Top of Page

DJBBIZ
Junior Member

214 Posts

Posted - 02 December 2002 :  14:40:18  Show Profile  Visit DJBBIZ's Homepage
dayve: My java is not very good but it looks like it is reading the file and posting the sizes in an alert function upon page load, but what I am not sure of is if this is also resizing the file upon presentation?


"The difference between good ideas and good results is performance"
the management institute | tmiFinance | tmiCreative | ProfileOnDemand
Go to Top of Page

@tomic
Senior Member

USA
1790 Posts

Posted - 02 December 2002 :  15:42:11  Show Profile  Visit @tomic's Homepage  Send @tomic an ICQ Message
Of course not. What a scary thing it would be if you could!

@tomic

SportsBettingAcumen.com
Go to Top of Page

dayve
Forum Moderator

USA
5820 Posts

Posted - 02 December 2002 :  18:09:53  Show Profile  Visit dayve's Homepage
the code merely displays the width and height of the original image. I also added an example for how one could restrict the size of the image by using the these values. you can not actually resize/resmaple the original image without a server side component.

Go to Top of Page

DAVEinAZ
Starting Member

USA
16 Posts

Posted - 02 December 2002 :  18:36:11  Show Profile
I know js script was requested, but found a free com object that returns image size others may be interested in.

ImageSize from http://www.serverobjects.com/products.htm#free


dp
Go to Top of Page

redbrad0
Advanced Member

USA
3725 Posts

Posted - 02 December 2002 :  22:00:28  Show Profile  Visit redbrad0's Homepage  Send redbrad0 an AOL message
well i couldnt get that to work like i wanted but after alot of playing i got this to work...


<HTML><BODY>
<FORM enctype="multipart/form-data" NAME="ImageUpload" method="post" action="pop_image.asp?action=add">
<IMG name="picname" id="picname" SRC="3-20021201235449.jpg" width="1" height="1">
<INPUT TYPE="FILE" NAME="FILE1" onChange="showPreview()">
<input type="text" name="height" value="">  <input type="text" name="width" value="">
<SCRIPT>
function showPreview()
{
if (document.ImageUpload.FILE1.value != "") {
 img=new Image ();
 img.src= document.ImageUpload.FILE1.value
 document.images[0].src=img.src
 document.ImageUpload.height.value = img.height
 document.ImageUpload.width.value = img.width
 alert(img.width)
 alert(img.height)
}
else {
  document.picname.src='brad.gif'; }
}



</SCRIPT>
</form>
</BODY>
</HTML>

Brad
Oklahoma City Online Entertainment Guide
Oklahoma Event Tickets
Go to Top of Page

redbrad0
Advanced Member

USA
3725 Posts

Posted - 02 December 2002 :  23:01:31  Show Profile  Visit redbrad0's Homepage  Send redbrad0 an AOL message
ok well i did get the above to work in a test.html file but when trying to add it to my site im getting problems. I dont know what the problem is and I dont know JS 2 well.
img=new Image (); this sets a new image?
img.src= document.ImageUpload.FILE1.value why cant i specify the image i want to set the pic like document.PREVIEWPIC.src

like i said i really dont know anything about JS i dont know what i need to post or show you, any help would be GREAT.

Brad
Oklahoma City Online Entertainment Guide
Oklahoma Event Tickets
Go to Top of Page

Webbo
Average Member

United Kingdom
982 Posts

Posted - 04 December 2002 :  03:51:30  Show Profile  Visit Webbo's Homepage
Here's one I use as part of an image upload but using asp:
http://www.maggotdrowning.com/read/check.asp

I could zip you the files if you want them, just let me know

Dave
Go to Top of Page

redbrad0
Advanced Member

USA
3725 Posts

Posted - 04 December 2002 :  18:56:15  Show Profile  Visit redbrad0's Homepage  Send redbrad0 an AOL message
Webbo I would love to see this code. If you could post a .txt file I would be very greatful. Is this pure ASP script?

Brad
Oklahoma City Online Entertainment Guide
Oklahoma Event Tickets
Go to Top of Page

Webbo
Average Member

United Kingdom
982 Posts

Posted - 20 December 2002 :  04:58:01  Show Profile  Visit Webbo's Homepage
Whoops, nearly missed the last post redbrad0,

Here are links to the text files:

check.txt
clsImage.txt
clsUpload.txt

Feel free to use them,

Dave
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.54 seconds. Powered By: Snitz Forums 2000 Version 3.4.07