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

<Img> tag, width, height

P: n/a
I am writing a tool to generate html and have a problem with the <img>
tag. The tool generates something like "<img src="...">". At the time
the html is generated, the tool does not know the actual image size,
but I do want to resize any image so that their width and height will
both be smaller than 100. I also want to keep the iamge width/height
ration so the image looks "normal". If I use <img src="..." width=100
height=100> the image will be resized. If I use <img src="..." width =
100>, it does not work if the height is larger than the width. If I
define the height, same thing. Is there a way I can do what I want?

Thanks,

John
Jul 20 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
In article <2d**************************@posting.google.com >,
ho******@yahoo.com wrote:
I am writing a tool to generate html and have a problem with the <img>
tag. The tool generates something like "<img src="...">". At the time
the html is generated, the tool does not know the actual image size,
but I do want to resize any image so that their width and height will
both be smaller than 100. I also want to keep the iamge width/height
ration so the image looks "normal". If I use <img src="..." width=100
height=100> the image will be resized. If I use <img src="..." width =
100>, it does not work if the height is larger than the width. If I
define the height, same thing. Is there a way I can do what I want?


I cannot help you. I can only add to your problems: next is the required
ALT attribute. How will your tool guess the value for that one?

--
Kris
<kr*******@xs4all.netherlands> (nl)
Jul 20 '05 #2

P: n/a
<ho******@yahoo.com> wrote in message
news:2d**************************@posting.google.c om...
I am writing a tool to generate html and have a problem with the <img>
tag. The tool generates something like "<img src="...">". At the time
the html is generated, the tool does not know the actual image size,
but I do want to resize any image so that their width and height will
both be smaller than 100. I also want to keep the iamge width/height
ration so the image looks "normal". If I use <img src="..." width=100
height=100> the image will be resized. If I use <img src="..." width =
100>, it does not work if the height is larger than the width. If I
define the height, same thing. Is there a way I can do what I want?


If you do not use the real image size, the image will be distorted. Also,
if the real image is larger than what you specify, the load time will
increase unnecessarily.

If you want the image size to be no larger than 100x100, tell your graphics
designers to design within this restriction.

Jul 20 '05 #3

P: n/a
On 2 Jul 2004 09:33:50 -0700, <ho******@yahoo.com> wrote:
I am writing a tool to generate html and have a problem with the <img>
tag. The tool generates something like "<img src="...">". At the time
the html is generated, the tool does not know the actual image size,
but I do want to resize any image so that their width and height will
both be smaller than 100. I also want to keep the iamge width/height
ration so the image looks "normal". If I use <img src="..." width=100
height=100> the image will be resized. If I use <img src="..." width =
100>, it does not work if the height is larger than the width. If I
define the height, same thing. Is there a way I can do what I want?


Congratulations, you've discovered one of the reasons resizing in the HTML
isn't effective! To do what you want, you'll need to have the image
library gone through and all images with a dimension larger than 100px
should be reduced.

Always, always, always serve the images at the right size, don't rely on
the HTML for that.
Jul 20 '05 #4

P: n/a
ho******@yahoo.com wrote:
I am writing a tool to generate html and have a problem with the <img>
tag. The tool generates something like "<img src="...">". At the time
the html is generated, the tool does not know the actual image size,


Fix your tool to extract the width/height from the image. It is not
rocket science; the specs for gif/png/jpeg/tiff are public domain. Then
just use either width or height attribute to force the image to resize
proportionately.
As others have mentioned, though, downloading a large image and using
HTML to reduce it is wasteful. If the source of the images cannot be
convinced to reduce the images, have your tool do it. After all, what good
is a tool that only does half the job?
A final note: Providing correct width/height info makes the browser's
job of rendering easier since it knows how much space to allow for the
image. This reduces the problem of a page constantly changing size as it
is loaded.

--
jmm dash list at sohnen-moe dot com
(Remove .TRSPAMTR for email)
Jul 20 '05 #5

P: n/a
ho******@yahoo.com wrote in message news:<2d**************************@posting.google. com>...
I am writing a tool to generate html and have a problem with the <img>
tag. The tool generates something like "<img src="...">". At the time
the html is generated, the tool does not know the actual image size,
but I do want to resize any image so that their width and height will
both be smaller than 100. I also want to keep the iamge width/height
ration so the image looks "normal". If I use <img src="..." width=100
height=100> the image will be resized. If I use <img src="..." width =
100>, it does not work if the height is larger than the width. If I
define the height, same thing. Is there a way I can do what I want?

Thanks,

John


if you are "writing a tool to generate html" then you probably have
the skills to use PHP and getImageSize(). It will solve you problems
as fast as you can type

$theSize = getImageSize($myImage);
echo "$theSize[3]";
Jul 20 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.