Forum Moderators: not2easy

Message Too Old, No Replies

One Dimmensional Image Scaling

...file under stupid HTML tricks?

         

lexipixel

5:25 am on Sep 2, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I was experimenting with some image scaling and inadvertantly only used the WIDTH= parameter in the <IMG SRC=""> tag and it scaled the image keeping the proper aspect ratio.

I then tried a 100w x 100h image and used tags like-

<IMG SRC="test.jpg" WIDTH="200">

to double the size of the image

<IMG SRC="test.jpg" WIDTH="50">

to half the size of it.

Then tried HEIGHT= (without "WIDTH=" marked up), and other combination. I'm using MS-IE 5.5 and it worked fine.

So long as I didn't put both parameters in it properly scaled the image. I should note that using

<IMG SRC="test.jpg" WIDTH="200" HEIGHT="">

results in the height being set to '0' and the image is not displayed, but omit height and it scales...

I'm wondering if this is a documented JPG/GIF HTML or browser feature or just a fluke... it sure makes scaling a batch of images to the same width or height simple --- no math, just give it one parameter/value and it scales.

(I do know it's not scaling the actual image file, just altering the appearance in the browser).

Anyone ever used this or avoided it for some reason?

Cross-browser comments?

benihana

8:05 am on Sep 2, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



avoided it for some reason?

its likely to introduce distortion and lower the image quality.

if you scale it down, the file size will be greater than it would be if you used a graphics program to change the image size.

lexipixel

9:24 am on Sep 2, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Thanks for the comments Beni

I'm no newbie.. I understand graphic image files and the proper way to scale an image.

The HTML was output from one of my Perl scripts. The script manages an image database. To accomplish the scaling the "proper way" I'd either need to upload a thumbnail of every image, or load Perl modules (like Image:Magik) to accomplish it on the fly. That would make lots of extra files and/or lots of extra server processing.

I need to scale the images to a certain width regardless of height... this just did it very neatly.

If this "stupid HTML trick" will work accros a broad range of browsers it would accomplish a few things:

1). no server image file manipulation
2). no additional files (thumbnails) needed
3). no need to load non-standard Perl modules

I am more interested in cross-browser compatability for this than suggestions for other ways to scale images.

Feedback from anyone who trys this and can tell me if it worked and on what browser/platform/version would be appreciated.

benihana

2:20 pm on Sep 2, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



okay

just responding to the post as you put it.