473,395 Members | 1,694 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

constrain image size but retain proportions

I have a bunch of images that are

600x800
800x600
640x480
480x640

I want to use HTML to contrain the size of these images. I basically
want to display them as thumnails. Here is what I am trying to do:

"Display a thumbnail of this image, contraining the largest of the two
dimensions to 100 pixels and set the other dimension to the proper
relative size, scaled appropriately."

I dont want to actually resize the images, I just want them to be
displayed smaller. Is there an easy way to do this with HTML? With
CSS?
Jul 20 '05 #1
6 28670
ca*********@yahoo.com (J. VerSchave) wrote in
news:c5**************************@posting.google.c om:
I have a bunch of images that are

600x800
800x600
640x480
480x640

I want to use HTML to contrain the size of these images. I basically
want to display them as thumnails. Here is what I am trying to do:

"Display a thumbnail of this image, contraining the largest of the two
dimensions to 100 pixels and set the other dimension to the proper
relative size, scaled appropriately."

I dont want to actually resize the images, I just want them to be
displayed smaller. Is there an easy way to do this with HTML? With
CSS?


You can but you really, really, *really* shouldn't. What you're trying to
do is often called "dumbnailing." Especially in photo-gallery situations,
it *sucks*. First of all, all the "dumbnails" take just as long to load as
the full-size images. If, say, you have a gallery of 20 50K photos, you
have to load a whole megabyte just to see the thumbnails. Secondly, most
browsers do a *terrible* job of rescaling images by more than a few
percent. Dumbnails almost always look *severely* distorted. Finally,
dumbnailed pages often really badly slow down browsers; just scrolling or
navigating becomes extremely slow.

That said, dumbnails can be "achieved" by merely setting the height and
width of an image, in either HTML or CSS, to something smaller than the
image's actual dimensions. But the results are going to be *far* from
satisfactory, and if you want your visitors to have a good experience with
your site, you will want to create true thumbnails. Don't inconvenience
all your visitors just to save yourself a little bit of time or learning.
Jul 20 '05 #2
J. VerSchave wrote:
[snip]
I dont want to actually resize the images, I just want them to be
displayed smaller. Is there an easy way to do this with HTML? With
CSS?


You may have seen the reply from Eric Bohlman, and want a second opinion. Here
it is.

He is absolutely correct.

--
Barry Pearson
http://www.Barry.Pearson.name/photography/
http://www.BirdsAndAnimals.info/
http://www.ChildSupportAnalysis.co.uk/
Jul 20 '05 #3
In article <c5**************************@posting.google.com > in
comp.infosystems.www.authoring.html, J. VerSchave
<ca*********@yahoo.com> wrote:
I want to use HTML to contrain the size of these images.


No, you don't.

You want to use your favorite image editor to create thumbnails, and
have _those_ in your page. N.B. Don't just shrink an image; crop it
first.

If you "use HTML" to constrain the size of images, your visitors
have the worst of it two ways: the full download time, and then an
inferior reduction.

--
Stan Brown, Oak Road Systems, Cortland County, New York, USA
http://OakRoadSystems.com/
HTML 4.01 spec: http://www.w3.org/TR/html401/
validator: http://validator.w3.org/
CSS 2 spec: http://www.w3.org/TR/REC-CSS2/
2.1 changes: http://www.w3.org/TR/CSS21/changes.html
validator: http://jigsaw.w3.org/css-validator/
Jul 20 '05 #4
Luckily for me, I am NOT creating a photo album nor any kind of
massive image viewing website. I am writing an application that
displays about 4 - 6 images, a few of which may be annoyingly large.
Generating thumbnails is not an option for this application. I could
get into the specifics of why it is not, but its a long and boring
story.

I am a huge fan of using ImageMagick or some other application to
generate thumbails when possible but such is not the case with this
project. I am just looking for options with my specific case. I dont
care so much if the images are distorted, they just need to be
recognizable. Thanks for everyones input.
Jul 20 '05 #5
In article <c5**************************@posting.google.com > in
comp.infosystems.www.authoring.html, J. VerSchave
<ca*********@yahoo.com> wrote:
I am writing an application that
displays about 4 - 6 images, a few of which may be annoyingly large.
Generating thumbnails is not an option for this application.


If the images are "annoyingly large", then you're right that
generating thumbnails is not an option. It's a requirement.

Very few users will sit and wait while big images download. Most
will simply click elsewhere. The exception is when you have used a
proper thumbnail and disclosed the size of the big picture that the
thumbnail links to, so that users have some idea of whether it will
be worth the wait.

--
Stan Brown, Oak Road Systems, Cortland County, New York, USA
http://OakRoadSystems.com/
HTML 4.01 spec: http://www.w3.org/TR/html401/
validator: http://validator.w3.org/
CSS 2 spec: http://www.w3.org/TR/REC-CSS2/
2.1 changes: http://www.w3.org/TR/CSS21/changes.html
validator: http://jigsaw.w3.org/css-validator/
Jul 20 '05 #6
I have a bunch of images that are

600x800
800x600
640x480
480x640

I want to use HTML to contrain the size of these images. I basically
want to display them as thumnails. Here is what I am trying to do:

"Display a thumbnail of this image, contraining the largest of the two
dimensions to 100 pixels and set the other dimension to the proper
relative size, scaled appropriately."

I dont want to actually resize the images, I just want them to be
displayed smaller. Is there an easy way to do this with HTML? With
CSS?
There is a PHP script called ImageThumb available here: http://www.olivo.net/software/imagethumb/

It will allow you to do exactly what you're talking about. Certain folks would do well to remember that if it were so important to NEVER resize large images, that HTML wouldn't allow you to do it. I'm sure you're intelligent enough to have weighed the pros and cons of using this sort of method and determined that resizing the images is the best way to do it.

I can think of one situation where dynamic resizing of images would be necessary. A gallery of images that can be generated on the fly by users, using an XML code back, wouldn't be able to have thumbnails made for every image a user might upload. Not unless you want to pay some graphic designer ridiculous amounts of money to do it 24/7. Time or budget constraints may prevent this project from incorporating something as complicated as Google's image search.
Jun 27 '06 #7

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

Similar topics

3
by: dave | last post by:
Hello there, I am at my wit's end ! I have used the following script succesfully to upload an image to my web space. But what I really want to be able to do is to update an existing record in a...
11
by: Stephane D'Alu | last post by:
Do you know if it is possible to have an image to be scalled to a maximum width/height, but with keeping its aspect ratio. The two ideas I had were: - <img src="toto.jpg" style="max-width:...
1
by: timm.wong | last post by:
Hi, I have a program where I load images to a screen. How would I go about determining the size of an image prior to loading it on the screen? Thanks, Tim
5
by: Neo Geshel | last post by:
I still have a problem displaying images from an access DB using asp.net. This showimage.aspx is for an admin site. I need to pull the correct image from the correct table, hence the two GET...
3
by: Keith G Hicks | last post by:
In MS Access image controls there's a property setting for "Size Mode" --> Clip, Zoom or Stretch. I don't see any similar property in an asp image control. When I have an image on a page, it seems...
9
by: zacariaz | last post by:
I dont know, and i dont much like javascript, however, i am told that the only way to do want i want to do, is with javascript, so here goes. zoom and cut is the only features i need. 1. the...
9
by: tshad | last post by:
Is there a way to display images (imageButtons or linkbuttons for instance) as a max size (200px by 50px) and not have it stretch the image? What I want to be able to do is limit the real estate...
3
by: Diego F. | last post by:
Hi all. I have a listview with images and my application must be able to rotate one image. I need a method to rotate 90 degrees rigth (i.e.). Is that possible? -- Regards, Diego F.
4
by: Peter May | last post by:
Hi. I know the dimensions area visible on the screen and I would like to picture that there put dynamically, match its size to the window, while retaining the proportions of course. For...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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,...
0
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...

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.