473,789 Members | 3,060 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

<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
Jul 20 '05 #1
5 12306
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*******@xs4a ll.netherlands> (nl)
Jul 20 '05 #2
<ho******@yahoo .com> wrote in message
news:2d******** *************** ***@posting.goo gle.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?


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
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
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
ho******@yahoo. com wrote in message news:<2d******* *************** ****@posting.go ogle.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($m yImage);
echo "$theSize[3]";
Jul 20 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
2856
by: MyndPhlyp | last post by:
I've been busting my head trying to figure this out for quite some time. With IE6 and NS7, no problems. I can simply code the HTML <img height="100%"> and be done with it. But NS4 and NS6 (and probably a couple of other IE and NS versions I can't get to right now) don't want to play nice unless I hard code the image height. (Yes, I'm one of those who insists on still coding for NS4.)
2
2234
by: David D. | last post by:
If an <IMG> specifies a WIDTH but not a HEIGHT, then height is internally determined so as to maintain the image's aspect ratio. Aspect ratio is also preserved if HEIGHT but not WIDTH is specified. What is the value of an unspecified HEIGHT or WIDTH attribute. How do I dynamically set the attribute to unspecified, after having previously used the <IMG> with explicit HEIGHT and WIDTH attributes? - David
9
72125
by: Wladimir Borsov | last post by:
As well known for <IMG ...> tags in web pages a width and a height attribute can be applied. What I want to do now is to fix the width for ALL the images on my web page to exactly lets say 70 pixel regardless how big the originals are. The height should be adjusted proportional so that the resulting thumbnail is not distorted. But as far as I know there is no such attribute like <IMG SRC=...... WIDTH=70 HEIGHT="Adjust proportional to...
7
2630
by: Zhang Weiwu | last post by:
Hello. This is problem puzzled me a long time. I wish to organize some block elements and let them flow one after each other like text. Think about a album, I wish the album have 12 thumbnails, each one has a comment line under the picture. And I wish when the screen size is big, this thumbnails arrange 3 rows, 4 columns; if the browser window is smaller, arranges 4 rows, 3 columns; if it's even smaller, 6 rows with 2 columns. If there...
15
122166
by: Gérard Talbot | last post by:
Hello all, I'd like to know and understand the difference between, say, <img src="/ImageFilename.png" width="123" height="456" alt=""> and <img src="/ImageFilename.png" style="width: 123px; height: 456px;" alt="">
10
3320
by: News | last post by:
I am trying to be able to manipulate the width and height of an <img> but do not seem to be able. "Yes", I know the JavaScript will "not" manip anything, which is ok. I simply do not know how to capture the width or height. Once I can do that I can manipulate them. Here is the HTML for the <img> <div class="ImgMnp" id="myImg" onmouseover="imgSize('myImg','fpImg)"> <img src="images/FirePlace.jpg" width="480" height="640" id="fpImg" />
1
4628
by: Carl | last post by:
Hi all I have a javascript function that drags and drops an element (ie img) into a container (ie bordered div). The function works and returns the element and and container. My next step is to center the element in the container if the user is sloppy with positioning it. I can only test this on IE6 and IE5.5 and it fails. It positions the element too much right and low. Here is the function: function SnapToContainer(Container,El) {
4
1987
by: bgold12 | last post by:
Hey, I've come across a strange behaviour that shows itself in IE 7.0 and Firefox 3 and probably other browsers. In the code below, which is a complete HTML document which validates as XHTML 1.0 Strict, I display an image named Images/DivLine1.jpg (which is a simple 1x5 pixel blue line) inside two divs across 100% of their width, the first of which has 50px height and the second of which has 100px height. In both cases, I set the image...
0
10408
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10139
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9983
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9020
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7529
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6768
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5417
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4092
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3697
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.