Webmaster Forum


Go Back   Webmaster Forum > Web Development > Web Design Lobby
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Web Design Lobby Forum for general web design issues not specific to scripting or graphics.

   

Reply
 
LinkBack Thread Tools Display Modes
Old 06-29-2007, 09:14 PM   #1 (permalink)
Contributing Member
 
Join Date: 06-20-07
Posts: 57
iTrader: 0 / 0%
Latest Blog:
None

x360 is liked by many
How to resize images

Really stupid question, I know

How do you resize images in HTML?

Say I have <img src=url.png</img> and that image is 190x190 pixels but I want it 150x150 pixels. How do I do that. Thanks
x360 is offline  
Add Post to del.icio.us
Reply With Quote
Old 06-29-2007, 10:43 PM   #2 (permalink)
Empress™
 
chicgeek's Avatar
 
Join Date: 08-19-04
Location: York, UK
Posts: 18,417
iTrader: 0 / 0%
Latest Blog:
My Favourite Poem

chicgeek is a web professional of the highest orderchicgeek is a web professional of the highest orderchicgeek is a web professional of the highest orderchicgeek is a web professional of the highest orderchicgeek is a web professional of the highest orderchicgeek is a web professional of the highest orderchicgeek is a web professional of the highest orderchicgeek is a web professional of the highest orderchicgeek is a web professional of the highest orderchicgeek is a web professional of the highest orderchicgeek is a web professional of the highest order
<img src="url.png" width="150px">

or

<img src="url.png" style="width: 150px;">

I'd tend to use the latter. Though this will not resample your image and may leave your skewed image looking a little funny.
__________________
laura / chicgeek
soprano & web designer
laurakishimoto.ca
Always assume the presence of a belly button!
chicgeek is online now  
Add Post to del.icio.us
Reply With Quote
Old 06-29-2007, 10:51 PM   #3 (permalink)
Inactive
 
Join Date: 06-29-07
Location: Indiana
Posts: 20
iTrader: 0 / 0%
jpmitchell is a jewel in the roughjpmitchell is a jewel in the roughjpmitchell is a jewel in the roughjpmitchell is a jewel in the roughjpmitchell is a jewel in the roughjpmitchell is a jewel in the rough
Send a message via AIM to jpmitchell Send a message via MSN to jpmitchell
Your best bet is to resize it appropriately with a graphics program. If you do not have one, you can download free versions that will allow you to do this. Or you could download a demo/trial of one that isn't free and use it for just this purpose.

Free Solution: Gimp
Non-Free (but may have trial): Photoshop
jpmitchell is offline  
Add Post to del.icio.us
Reply With Quote
Old 06-29-2007, 11:22 PM   #4 (permalink)
Contributing Member
 
Join Date: 03-20-06
Posts: 115
iTrader: 0 / 0%
websiteideas is liked by somebodywebsiteideas is liked by somebodywebsiteideas is liked by somebodywebsiteideas is liked by somebody
If you don't use a graphics program to resize it, but instead use HTML then you're going to be wasting a lot of bandwidth and load time will be slower.
__________________
Website Ideas
websiteideas is offline  
Add Post to del.icio.us
Reply With Quote
Old 06-29-2007, 11:37 PM   #5 (permalink)
Contributing Member
 
lordspace's Avatar
 
Join Date: 05-30-06
Location: Canada
Posts: 466
iTrader: 0 / 0%
Latest Blog:
None

lordspace is just really nicelordspace is just really nicelordspace is just really nicelordspace is just really nicelordspace is just really nicelordspace is just really nicelordspace is just really nicelordspace is just really nicelordspace is just really nicelordspace is just really nicelordspace is just really nice
Send a message via ICQ to lordspace Send a message via Skype™ to lordspace
You used the code below OR give a search at phpclasses.org for OOP style or much more feature rich solution(s).

I found it in a book for PHP 1-2 years ago.

Code:
if (empty($max_width)) $max_width = 100; if (empty($max_height)) $max_height = 80; $image = "image.jpeg" // This is works only with JPEGs. $size = GetImageSize($image); $width = $size[0]; $height = $size[1]; $x_ratio = $max_width / $width; $y_ratio = $max_height / $height; if ( ($width <= $max_width) && ($height <= $max_height) ) { $tn_width = $width; $tn_height = $height; } else if (($x_ratio * $height) < $max_height) { $tn_height = ceil($x_ratio * $height); $tn_width = $max_width; } else { $tn_width = ceil($y_ratio * $width); $tn_height = $max_height; } $src = ImageCreateFromJpeg($image); //$dst = ImageCreate($tn_width,$tn_height); $dst = imagecreatetruecolor($tn_width,$tn_height); //ImageCopyResized($dst, $src, 0, 0, 0, 0, // $tn_width,$tn_height,$width,$height); imagecopyresampled($dst, $src, 0, 0, 0, 0, $tn_width,$tn_height,$width,$height); header('Content-type: image/jpeg'); ImageJpeg($dst, null, 90); ImageDestroy($src); ImageDestroy($dst);
lordspace is offline  
Add Post to del.icio.us
Reply With Quote
Old 06-30-2007, 12:04 AM   #6 (permalink)
Contributing Member
 
Join Date: 06-20-07
Posts: 57
iTrader: 0 / 0%
Latest Blog:
None

x360 is liked by many
Thanks for the help. The first is what I needed and only that will work. Hard to explain why, but thanks.
x360 is offline  
Add Post to del.icio.us
Reply With Quote
Old 06-30-2007, 01:30 PM   #7 (permalink)
Inactive
 
c-low's Avatar
 
Join Date: 04-21-06
Location: Boston
Posts: 28
iTrader: 0 / 0%
Latest Blog:
None

c-low is on the right pathc-low is on the right pathc-low is on the right path
<img src=url.png</img> is not the correct way to format an image tag, the correct way is:

<img src="image.png" /> (no closing tag)

if you want it to validate as xhtml strict you also need to include an alt attribute: <img src="image.png" alt="Description of image" />

finally, you should never resize an image with html because it'll look terrible. resize with an image editor (jpmitchell has good suggestions above) and upload the new version.
c-low is offline  
Add Post to del.icio.us
Reply With Quote
Old 07-02-2007, 12:06 PM   #8 (permalink)
Empress™
 
chicgeek's Avatar
 
Join Date: 08-19-04
Location: York, UK
Posts: 18,417
iTrader: 0 / 0%
Latest Blog:
My Favourite Poem

chicgeek is a web professional of the highest orderchicgeek is a web professional of the highest orderchicgeek is a web professional of the highest orderchicgeek is a web professional of the highest orderchicgeek is a web professional of the highest orderchicgeek is a web professional of the highest orderchicgeek is a web professional of the highest orderchicgeek is a web professional of the highest orderchicgeek is a web professional of the highest orderchicgeek is a web professional of the highest orderchicgeek is a web professional of the highest order
Everyone is making things complicated. Just... straight and simple html above.
__________________
laura / chicgeek
soprano & web designer
laurakishimoto.ca
Always assume the presence of a belly button!
chicgeek is online now  
Add Post to del.icio.us
Reply With Quote
Old 07-02-2007, 12:44 PM   #9 (permalink)
Contributing Member
 
lordspace's Avatar
 
Join Date: 05-30-06
Location: Canada
Posts: 466
iTrader: 0 / 0%
Latest Blog:
None

lordspace is just really nicelordspace is just really nicelordspace is just really nicelordspace is just really nicelordspace is just really nicelordspace is just really nicelordspace is just really nicelordspace is just really nicelordspace is just really nicelordspace is just really nicelordspace is just really nice
Send a message via ICQ to lordspace Send a message via Skype™ to lordspace
... if you display 100 images per page and the user clicks only on 5 images the server load will be huge.
lordspace is offline  
Add Post to del.icio.us
Reply With Quote
Old 07-02-2007, 03:44 PM   #10 (permalink)
Inactive
 
c-low's Avatar
 
Join Date: 04-21-06
Location: Boston
Posts: 28
iTrader: 0 / 0%
Latest Blog:
None

c-low is on the right pathc-low is on the right pathc-low is on the right path
Quote:
Originally Posted by chicgeek View Post
Everyone is making things complicated. Just... straight and simple html above.
yes, straight and simple... of course, the straightest and simplest is to not resize an image with html or css. unless you want funny looking slow loading images
c-low is offline  
Add Post to del.icio.us
Reply With Quote
Old 07-02-2007, 04:29 PM   #11 (permalink)
Empress™
 
chicgeek's Avatar
 
Join Date: 08-19-04
Location: York, UK
Posts: 18,417
iTrader: 0 / 0%
Latest Blog:
My Favourite Poem

chicgeek is a web professional of the highest orderchicgeek is a web professional of the highest orderchicgeek is a web professional of the highest orderchicgeek is a web professional of the highest orderchicgeek is a web professional of the highest orderchicgeek is a web professional of the highest orderchicgeek is a web professional of the highest orderchicgeek is a web professional of the highest orderchicgeek is a web professional of the highest orderchicgeek is a web professional of the highest orderchicgeek is a web professional of the highest order
Yes, but he didn't ask for an opinion on saving bandwidth or how to do it using a program. He asked how to do it in HTML. Not even PHP.

And as far as we know, it's one 300 x 300 image going down to 150 x 150. Not going to crash any servers any time soon.
__________________
laura / chicgeek
soprano & web designer
laurakishimoto.ca
Always assume the presence of a belly button!
chicgeek is online now  
Add Post to del.icio.us
Reply With Quote
Old 07-02-2007, 09:33 PM   #12 (permalink)
Inactive
 
Join Date: 06-29-07
Location: Indiana
Posts: 20
iTrader: 0 / 0%
jpmitchell is a jewel in the roughjpmitchell is a jewel in the roughjpmitchell is a jewel in the roughjpmitchell is a jewel in the roughjpmitchell is a jewel in the roughjpmitchell is a jewel in the rough
Send a message via AIM to jpmitchell Send a message via MSN to jpmitchell
@chicgeek - you are correct they didn't ask for all the options for saving it. However, there is no sense in taking a shortcut (even if one is available). One should be in the habit of doing things the proper way, as it will save them in the long run.

Just my
jpmitchell is offline  
Add Post to del.icio.us
Reply With Quote
Old 07-07-2007, 01:53 PM   #13 (permalink)
v7n Mentor
 
KeithCash's Avatar
 
Join Date: 03-14-06
Location: Montevallo Alabama
Posts: 1,227
iTrader: 0 / 0%
KeithCash is a splendid one to beholdKeithCash is a splendid one to beholdKeithCash is a splendid one to beholdKeithCash is a splendid one to beholdKeithCash is a splendid one to beholdKeithCash is a splendid one to beholdKeithCash is a splendid one to beholdKeithCash is a splendid one to beholdKeithCash is a splendid one to beholdKeithCash is a splendid one to beholdKeithCash is a splendid one to behold
Send a message via Yahoo to KeithCash
Quote:
Originally Posted by jpmitchell View Post
Your best bet is to resize it appropriately with a graphics program. If you do not have one, you can download free versions that will allow you to do this. Or you could download a demo/trial of one that isn't free and use it for just this purpose.

Free Solution: Gimp
Non-Free (but may have trial): Photoshop
Another free solution would be: Paint
__________________
- See me on Twitter - SmartMarketing
- See website - SmartMarketingExpert.com
Life in the Digital World
Social Catalyst
KeithCash is offline  
Add Post to del.icio.us
Reply With Quote
Go Back   Webmaster Forum > Web Development > Web Design Lobby

Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
What type of images and royalty free images do developers and webmasters need? EZRoyaltyFree Web Design Lobby 0 02-26-2008 09:11 AM
Can someone Resize this avatar please... OwnageSoup V7N Forum Support 11 08-01-2007 01:10 PM
watermark png no resize ycpc55 Coding Forum 2 01-08-2007 10:43 AM
Hi, can someone resize this please? louise501 Graphic Design Forum 11 11-09-2006 06:47 PM
Resize Image Please Centertainment Graphic Design Forum 8 08-31-2006 09:17 AM


Sponsor Links
Get exposure! Get exposure! Find Scripts Web Hosting Directory Get exposure! SEO Blog


All times are GMT -7. The time now is 07:38 AM.
© Copyright 2008 V7 Inc