ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old August 12th, 2005, 09:51 PM
casagrande casagrande is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2005
Posts: 15 casagrande User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 3 m 38 sec
Reputation Power: 0
maximum image size

I am trying to display images with paths stored in a database, and wanted to make the maximum width of the image to be 500...

<cfoutput query="spec_pic" maxrows="1">

<img src="http://127.0.0.1:8500/videos/#spec_pic.filename#" width="500">
</cfoutput>

------------
however, i want to make it so it only forces the maximum width if the image width is greater than 500. Is there any built in variables made to retieve this info on the image or any other way to complete this task? Mayber javascript?

Reply With Quote
  #2  
Old August 18th, 2005, 05:55 AM
jamieB jamieB is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Nov 2002
Posts: 596 jamieB User rank is Sergeant (500 - 2000 Reputation Level)jamieB User rank is Sergeant (500 - 2000 Reputation Level)jamieB User rank is Sergeant (500 - 2000 Reputation Level)jamieB User rank is Sergeant (500 - 2000 Reputation Level)jamieB User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 2 Days 3 h 19 m 33 sec
Reputation Power: 17
you're right about the javascript - give the img element an id tag & an onLoad handler, then in the handler test the image.width, .height and adjust if necessary

Reply With Quote
  #3  
Old August 18th, 2005, 08:07 AM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,682 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 15 h 45 m 53 sec
Reputation Power: 53
You can get the image dimensions using cfx_image, the Java Advanced Imaging API (downloadable add-on to the core Java runtime), or something like the Alagad Image Components. I'm sure there are others as well, try Googling or searching the Macromedia Exchange.
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian.
How to Post a Question in the Forums

Reply With Quote
  #4  
Old August 19th, 2005, 09:45 AM
CLupo CLupo is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 11 CLupo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 4 m 18 sec
Reputation Power: 0
Here you go

I didnt have a DB to work from but I am sure you can change this to suite your needs ....


Code:
<Cfset imglist = "1,2,3,4,5,6">
<cfoutput>
	<Cfloop list="#imglist#" index="img">
		<script language="JavaScript">
			function resizeImg(othis){
				myImage = new Image() 
				myImage.src = othis.src;
				if(myImage.width > 500){
					othis.width = 500
				}
			}
		</script>
		<img src="images/#img#.jpg" name="#img#" onload="resizeImg(this)"><br>
	</CFLOOP>
</cfoutput>

Reply With Quote
  #5  
Old August 19th, 2005, 12:20 PM
jamieB jamieB is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Nov 2002
Posts: 596 jamieB User rank is Sergeant (500 - 2000 Reputation Level)jamieB User rank is Sergeant (500 - 2000 Reputation Level)jamieB User rank is Sergeant (500 - 2000 Reputation Level)jamieB User rank is Sergeant (500 - 2000 Reputation Level)jamieB User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 2 Days 3 h 19 m 33 sec
Reputation Power: 17
Quote:
Originally Posted by CLupo
I didnt have a DB to work from but I am sure you can change this to suite your needs ....


Code:
<Cfset imglist = "1,2,3,4,5,6">
<cfoutput>
	<Cfloop list="#imglist#" index="img">
		<script language="JavaScript">
			function resizeImg(othis){
				myImage = new Image() 
				myImage.src = othis.src;
				if(myImage.width > 500){
					othis.width = 500
				}
			}
		</script>
		<img src="images/#img#.jpg" name="#img#" onload="resizeImg(this)"><br>
	</CFLOOP>
</cfoutput>

looks good, if you move the javascript outside of the loop. (More of a picky thing, use var for method-local variables to avoid blatting global ones)

Reply With Quote
  #6  
Old August 19th, 2005, 04:49 PM
casagrande casagrande is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2005
Posts: 15 casagrande User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 3 m 38 sec
Reputation Power: 0
nice thanks

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > maximum image size


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT