Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old July 20th, 2005, 08:15 PM
homecurr@yahoo.com
Guest
 
Posts: n/a
Default <Img> tag, width, height

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
  #2  
Old July 20th, 2005, 08:15 PM
Kris
Guest
 
Posts: n/a
Default Re: <Img> tag, width, height

In article <2d5d0ce4.0407020833.640265fd@posting.google.com >,
homecurr@yahoo.com wrote:
[color=blue]
> 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?[/color]

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
<kristiaan@xs4all.netherlands> (nl)
  #3  
Old July 20th, 2005, 08:15 PM
C A Upsdell
Guest
 
Posts: n/a
Default Re: <Img> tag, width, height

<homecurr@yahoo.com> wrote in message
news:2d5d0ce4.0407020833.640265fd@posting.google.c om...[color=blue]
> 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?[/color]

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.



  #4  
Old July 20th, 2005, 08:15 PM
Neal
Guest
 
Posts: n/a
Default Re: <Img> tag, width, height

On 2 Jul 2004 09:33:50 -0700, <homecurr@yahoo.com> wrote:
[color=blue]
> 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?[/color]

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.
  #5  
Old July 20th, 2005, 08:16 PM
jmm-list-tr
Guest
 
Posts: n/a
Default Re: <Img> tag, width, height

homecurr@yahoo.com wrote:[color=blue]
> 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,[/color]

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)
  #6  
Old July 20th, 2005, 08:16 PM
cruiserweight
Guest
 
Posts: n/a
Default Re: <Img> tag, width, height

homecurr@yahoo.com wrote in message news:<2d5d0ce4.0407020833.640265fd@posting.google. com>...[color=blue]
> 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[/color]

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]";
 

Bookmarks

Thread Tools

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 Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles