Raised This Month: $ Target: $400
 0% 

HTML Image question


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Dizzy
Veteran Member
Join Date: Jun 2004
Location: Massachusetts
Old 03-22-2008 , 13:01   HTML Image question
Reply With Quote #1

When you use the <img> tag in HTML you obviously fill out the src value and sometimes, not all, use the width and height values.

When an image is too large for the site and you want all the images (varying from different sizes) to be half the size, is there a way to do this without using calc.exe to find that a 974x562 image is 487x281 and plugin it in where the next image is 1232x834...

I was thinking possibly to do this:

Code:
<img src="images/art.jpg" width="1232/2" height="834/2" alt="Artwork" border="0">

<img src="images/art.jpg" width="1232*.5" height="834*.5" alt="Artwork" border="0">
But, with doubt, I was sure these wouldn't work, but I was wondering if there was a way to do this?
__________________
My Plugins

Purchase Mod - Stable
Type Sounds - Stable
Monster Spawner - Stable
Nade Giver - Maintenance
Dizzy is offline
Send a message via AIM to Dizzy
ContactLens
New Member
Join Date: Mar 2008
Old 03-22-2008 , 14:35   Re: HTML Image question
Reply With Quote #2

Lol...Its math,not counter strike problem -_-
ContactLens is offline
Dizzy
Veteran Member
Join Date: Jun 2004
Location: Massachusetts
Old 03-22-2008 , 16:14   Re: HTML Image question
Reply With Quote #3

Which is why I posted in the Off Topic/General Chat section of the forums...

Forget which thread you're in?
__________________
My Plugins

Purchase Mod - Stable
Type Sounds - Stable
Monster Spawner - Stable
Nade Giver - Maintenance
Dizzy is offline
Send a message via AIM to Dizzy
hoboman
Senior Member
Join Date: Jul 2007
Old 03-22-2008 , 16:21   Re: HTML Image question
Reply With Quote #4

my html is a bit rusty, but did you try making the image size in percentages or use "em" instead of the default "px" units
__________________
hoboman is offline
Dizzy
Veteran Member
Join Date: Jun 2004
Location: Massachusetts
Old 03-22-2008 , 16:43   Re: HTML Image question
Reply With Quote #5

I have tried the %age and did <img src="images/art.jpg" width="50%" height="50%" alt="Artwork" border="0">

I thought that that would work, cause it looked correct, but it didn't appear on the page. Similar to making it width="0" and height="0"

I am unfamiliar with em and wouldn't know how to do that, I will search a little bit on google.

Thanks for the great ideas though hoboman
__________________
My Plugins

Purchase Mod - Stable
Type Sounds - Stable
Monster Spawner - Stable
Nade Giver - Maintenance
Dizzy is offline
Send a message via AIM to Dizzy
Dizzy
Veteran Member
Join Date: Jun 2004
Location: Massachusetts
Old 03-22-2008 , 16:53   Re: HTML Image question
Reply With Quote #6

Wait a second...

This is weird...

When I put:
Code:
<img src="images/art.jpg">
It comes in normal at full size.

When I put:
Code:
<img src="images/art.jpg" width="100%" height="100%">
It comes in at 50%...

Code:
<img src="images/art.jpg" width="50%" height="50%">
That makes it come in even smaller. I'm not sure why it is working all of the sudden. Maybe I have to define the original widths and heights in like javascript or something. Any ideas?

EDIT:

Here is a page I made, check the code see what's up...

Notice that the image at 100% isn't that same size as the original and the one at 50% isn't 50% than the original...

http://dizzythermal.oxyhostsfree.com/picture.html

That's the page... Thanks guys!

EDIT: I was also thinking that I might be able to use JAVASCRIPT (like I said before)

Code:
	<script type="text/javascript">
		if (document.images)
		{
			picture		= new Image
			picture.src	= 'picture.bmp'
			picture.width	= '200px'
			picture.height	= '200px'
		}
	</script>
This didn't work, not sure if this 'might' work and I just have the wrong syntax.
__________________
My Plugins

Purchase Mod - Stable
Type Sounds - Stable
Monster Spawner - Stable
Nade Giver - Maintenance

Last edited by Dizzy; 03-22-2008 at 17:38.
Dizzy is offline
Send a message via AIM to Dizzy
commonbullet
Veteran Member
Join Date: Oct 2005
Old 03-22-2008 , 19:03   Re: HTML Image question
Reply With Quote #7

Quote:
Originally Posted by Dizzy View Post
Wait a second...

This is weird...
That's because that 'percentage' is related to browser's flow area rather than the image absolute size. I don't know what you're doing but counting on browsers to resize images is not a good idea due to distortion.

Last edited by commonbullet; 03-22-2008 at 19:06.
commonbullet is offline
Send a message via ICQ to commonbullet Send a message via MSN to commonbullet
Dizzy
Veteran Member
Join Date: Jun 2004
Location: Massachusetts
Old 03-22-2008 , 22:22   Re: HTML Image question
Reply With Quote #8

Basically, what I want to ultimately do, for faster coding purposes, be able to do <img src="pic.jpg" width="50%" height="50%"> and move on, not have to tidiously use Windows Calculator, take 747 and divide it in half. All the pictures are too big, because I render them in Rhinoceros 3D in high quality. But I want them to appear on the site in half the size.

It was mainly for faster coding purposes. I wasn't sure that it could be done, this is why I asked. I have looked on line for it, but I see how it references to the size of the page. I would want it to take that pic's size and divide it in half so it is half the size of the original picture.

Just wasn't sure if I could do this... I'm willing to keep editing the test page to try and get it right.
__________________
My Plugins

Purchase Mod - Stable
Type Sounds - Stable
Monster Spawner - Stable
Nade Giver - Maintenance
Dizzy is offline
Send a message via AIM to Dizzy
Lee
AlliedModders Donor
Join Date: Feb 2006
Old 03-23-2008 , 14:46   Re: HTML Image question
Reply With Quote #9

I'm don't know if you have a relevant medical condition (if that's the right term), but you really should be able to divide by two in your head. I can't imagine how this would be faster for you to write, it wastes bandwidth and is dependent on Javascript being enabled. It's just not a good idea.

Anyway..

PHP Code:
<script type="text/javascript">
<!--
function 
halfImageSize()
{
    var 
images document.getElementsByTagName("img");
    
    for (
0images.lengthi++)
    {
        
images[i].width /= 2;
        
images[i].height /= 2;
    }
}
// -->
</script>

<body onLoad="halfImageSize();"> 

Last edited by Lee; 03-23-2008 at 17:57.
Lee is offline
ContactLens
New Member
Join Date: Mar 2008
Old 03-23-2008 , 17:07   Re: HTML Image question
Reply With Quote #10

Maybe the motd thing resize it because the picture too big?Maybe...
ContactLens is offline
Reply



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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 12:38.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode