How to display an image when you don't know the size ?

C

Chris Leonard

Can someone offer some help please.

I have written a guestbook for my site which allows the user to upload
images of themselves. I've restricted the upload to only 50K so I'm not
expecting many large files. My problem comes when I display the image on the
page, if it's a small image then no problem it will fit into the table
cell - but, somepeople have uploaded larger images.

How can I display a large image in a table cell when I don't know the size.
OK, I can always set an image size but if the uploaded image is small then
if you resize it large it look poor.

Any ideas please ?

TIA.

Chris
 
D

David Dorward

How is the quality of resized images compared with GD?

I couldn't say - I've never used GD.
Is it difficult to install Imagemagic on a Windows-server?

Again, I can't say. I don't even use Windows for workstations these days. I
do know that its possible to get it running under Windows though.
 
N

nice.guy.nige

Can someone offer some help please.

I have written a guestbook for my site which allows the user to upload
images of themselves. I've restricted the upload to only 50K so I'm
not expecting many large files. My problem comes when I display the
image on the page, if it's a small image then no problem it will fit
into the table
cell - but, somepeople have uploaded larger images.

How can I display a large image in a table cell when I don't know the
size. OK, I can always set an image size but if the uploaded image is
small then if you resize it large it look poor.

If you are using PHP as a server-side language you can use the following;

<?php
$size = getimagesize ("myimage.jpg");
echo "<img src=\"myimage.jpg\" {$size[3]}>";
?>

getimagesize() returns an array, where element [3] is the "width=n height=n"
string which you can easily output in your <img> tag as shown in the above
example.

Hope that helps,
Nige

--
Nigel Moss.

Email address is not valid. (e-mail address removed). Take the dog out!
http://www.nigenet.org.uk | Boycott E$$O!! http://www.stopesso.com
"How strange the change from major to minor..."
 
C

Chris Leonard

Thanks to everyone.

My host has ASPJpeg installed so I'm looking at this method. I'd rather use
the php example but php is not available to me - is there an ASP alternative
do you know ?

Chris
 
D

Dave Saville

Can someone offer some help please.

I have written a guestbook for my site which allows the user to upload
images of themselves. I've restricted the upload to only 50K so I'm not
expecting many large files. My problem comes when I display the image on the
page, if it's a small image then no problem it will fit into the table
cell - but, somepeople have uploaded larger images.

I have a site that people can upload pics to and automatically produce
an index. The approach I took was that the cgi upload dumps the
pictures into a directory called bigpics. It then runs a program called
PMView, which is a damn good image viewer and its latest incarnation
has a batch mode. I set it up to take bigpics/<uploaded image> and
produce smallpics/<uploaded image.gif> that is 200 pixels wide. I then
build the index page with the smallpics image as a link to the original
bigpics image.

PMView understands just about any image format on the planet and can
convert between them so bigpics is a mixture but smallpics are all
gifs. http://www.pmview.com/

Regards

Dave Saville

NB switch saville for nospam in address
 
C

Chris Leonard

Switch to UNIX, its much more user friendly then Microsoft's offerings :)I've head UNIX called many things before but user friendly are you barking
mad ??

Notepad vs Vi

Vi wins hands down on functionality but on user friendliness ....... ummm 1
nill Microsoft
 
D

David Dorward

Chris said:
I've head UNIX called many things before but user friendly are you barking
mad ??

Notepad vs Vi

Ah ha - so you are comparing a "very simple text editor" to "a very
powerful, programmable editor for programmers"?

Try Notpad Vs Nano
 
N

nice.guy.nige

While the city slept said:
Ah ha - so you are comparing a "very simple text editor" to "a very
powerful, programmable editor for programmers"?

Try Notpad Vs Nano

Or Vi, or Notepad Vs Emacs / Xemacs. Especially Xemacs -- a powerful text
editor that comes complete with games and a (admittedly f**king awful) web
browser??

Cheers,
Nige

--
Nigel Moss.

Email address is not valid. (e-mail address removed). Take the dog out!
http://www.nigenet.org.uk | Boycott E$$O!! http://www.stopesso.com
"How strange the change from major to minor..."
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top