Reputation: 5442
I want to change an image size to 200x150 using tag. Can you please help me to do this?
Upvotes: 0
Views: 259
Reputation: 700172
You just set the width and height attributes:
<img src="..." width="200" height="150" alt="..." />
Note that this only changes how the image is displayed. The file loaded from the server is still the same size so it still takes as long to load. Also, the visual result is varying from browser to browser, some recent browsers are pretty good at resizing images, but generally an image resized this way can look pretty bad.
If you want the best possible quality this method won't do. You have to resize the actual image instead of just specifying how it's displayed.
Upvotes: 2
Reputation: 2761
As Guffa said, using the width and height attributes of the image tag just affects the way it is displayed by the browser.
If you want to resize your image, you have either to use server side code for that (like asp.net, php, ...) and serve the resized image, or you have to resize it manualy with a picture editor.
Upvotes: 1
Reputation: 16007
The other answers are correct. They do what you ask. But:
To fix these things you can create your small images offline (if that's appropriate for your application) or venture into imagemagick or something like that to render them more efficiently.
Upvotes: 1
Reputation: 37906
You mean like this?
<img src="path/to/img" width="200" height="150" />
Upvotes: 1
Reputation: 887225
Like this:
<img width="200" height="150" src="..." alt="My Small Image" />
Upvotes: 1