By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,687 Members | 2,055 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,687 IT Pros & Developers. It's quick & easy.

Restricting inline image size

P: n/a
Hello,

I have an HTML question that I'm not sure can be solved. I want to
restrict the maximum size of an inline image.

For example, I can force the image to be 200x200 if I do this:
<img src=blah.gif width=200 height=200>

But, that messes up the aspect ratio, and could size the image larger than
it's original size.

What I want is a way to size an image such that it's aspect ratio is
preserved and the image is less than the given size (let's say 200x200 for
now).

I've tried placing the image in a table cell, and setting the table cell
size to 200x200, but that doesn't work as the image displays in full size
(stretching the table cell beyond that I specified)

Yes, I know I can do this by manually resizing the image, or fetching the
dimensions of the image and calculating a size myself. But, I am
specifically looking for a way to do it with an inlime image without
fetching it first.

Thanks

-----------------------------------------------------------
Posted using QuadSucker/News, http://www.quadsucker.com
... the ultimate tool for newsgroup downloading!

-----------------------------------------------------------
Jul 24 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
no*****@no-spam.com wrote:
Yes, I know I can do this by manually resizing the image, or fetching the
dimensions of the image and calculating a size myself. But, I am
specifically looking for a way to do it with an inlime image without
fetching it first.


Sounds like you are doing inappropriate things with that image, explain
the context.

--
Spartanicus
Jul 24 '05 #2

P: n/a
In message <11*************@news.supernews.com>, no*****@no-spam.com
writes
Hello,

I have an HTML question that I'm not sure can be solved. I want to
restrict the maximum size of an inline image.

For example, I can force the image to be 200x200 if I do this:
<img src=blah.gif width=200 height=200>

But, that messes up the aspect ratio, and could size the image larger than
it's original size.

What I want is a way to size an image such that it's aspect ratio is
preserved and the image is less than the given size (let's say 200x200 for
now).

I've tried placing the image in a table cell, and setting the table cell
size to 200x200, but that doesn't work as the image displays in full size
(stretching the table cell beyond that I specified)

Yes, I know I can do this by manually resizing the image, or fetching the
dimensions of the image and calculating a size myself. But, I am
specifically looking for a way to do it with an inlime image without
fetching it first.

Thanks

-----------------------------------------------------------
Posted using QuadSucker/News, http://www.quadsucker.com
... the ultimate tool for newsgroup downloading!

-----------------------------------------------------------


(a) Place the image in a containing DIV which you set to the appropriate
width (say 200px).

(b) Then set the <img> size as: width="100%'

That will cause the browser to resize the image and display it as 200px
wide.

Depending on what you are trying to do, resizing the image in an image
editor beforehand is usually the best approach.

What are you trying to do?

regards.
--
Jake

Jul 24 '05 #3

P: n/a
"" wrote in comp.infosystems.www.authoring.html:
What I want is a way to size an image such that it's aspect ratio is
preserved and the image is less than the given size (let's say 200x200 for
now).


Then you want an image processor, such as the free Irfanview (if
you're on Windows, which I imagine you are):
http://www.irfanview.com/

Do not, repeat not, resize images in HTML. First, mst browsers do a
poorer job than most image processors. Second, it's pretty silly to
download a big image and then display it as a small image.

--

Stan Brown, Oak Road Systems, Tompkins County, New York, USA
http://OakRoadSystems.com/
Jul 24 '05 #4

P: 3
In message <114j5m4ennivd64@news.supernews.com>, no-spam@no-spam.com
writes[color=blue]
>Hello,
>
>I have an HTML question that I'm not sure can be solved. I want to
>restrict the maximum size of an inline image.
>
>For example, I can force the image to be 200x200 if I do this:
><img src=blah.gif width=200 height=200>
>
>But, that messes up the aspect ratio, and could size the image larger than
>it's original size.
>
>What I want is a way to size an image such that it's aspect ratio is
>preserved and the image is less than the given size (let's say 200x200 for
>now).
>
>I've tried placing the image in a table cell, and setting the table cell
>size to 200x200, but that doesn't work as the image displays in full size
>(stretching the table cell beyond that I specified)
>
>Yes, I know I can do this by manually resizing the image, or fetching the
>dimensions of the image and calculating a size myself. But, I am
>specifically looking for a way to do it with an inlime image without
>fetching it first.
>
>Thanks
>
>-----------------------------------------------------------[color=green]
>> Posted using QuadSucker/News, http://www.quadsucker.com
>> ... the ultimate tool for newsgroup downloading![/color]
>-----------------------------------------------------------[/color]

(a) Place the image in a containing DIV which you set to the appropriate
width (say 200px).

(b) Then set the <img> size as: width="100%'

That will cause the browser to resize the image and display it as 200px
wide.

Depending on what you are trying to do, resizing the image in an image
editor beforehand is usually the best approach.

What are you trying to do?

regards.
--
Jake
I've got the exact same problem, and i've seen that solution in practice, however i cant seem to work it to solve my problem. Specifically, im not sure how to change the width attribute properly. I've got a simple page with a 1 row table with 3 columns on it.

First column = image
Second column = text
Third column = blank space

I want the first and last columns to be equal size and smaller than the middle column of text. How do i adjust the width of the cell containing the image then to make this work? Do the widths of all the columns have to add up to anything??

Thanks in advance for any help,
Sev
Aug 23 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.