Web Hosting Talk







View Full Version : should be easy but!!!


qnctv.com
11-27-2002, 01:45 PM
I have a slide show working @

http://qnctv.com/preacher/slide.htm

but I want to be able to get the correct sizes for the pictures.

I have attempted an "if else" condition but it doesn't work.

if thisPic = ("http://qnctv.com/preacher/sofa.jpg","http://qnctv.com/preacher/cow.jpg","http://qnctv.com/preacher/hill.jpg","http://qnctv.com/preacher/luge.jpg","http://qnctv.com/preacher/train.jpg") {document.myPicture.src(height="300" width="400")=myPix[thisPic]}
else {document.myPicture.src(height=400 width=300)=myPix[thisPic]}
document.myPicture.src=myPix[thisPic]

there is also a specification in the body width height etc... but the idea would be to define for the pictures.


Can you have a look it is very tiny. it is in Javascript

full source @

http://qnctv.com/preacher/slidesize.htm

can anyone help

ServerCorps
11-27-2002, 02:11 PM
to get an image's size in php:
http://www.php.net/manual/en/function.getimagesize.php

to make the pic scale properly, just set one size attribute. either width or height,but not both. Then all pictures will be in proportion, but still constrained to some max width or height.

qnctv.com
11-27-2002, 05:48 PM
so I use something like

<?php $size = getimagesize ("http://www.example.com/gifs/logo.gif"); ?>

this puts the size in the variable $size

How do I REASSIGN IT?

Also I have to resign it to each image.

Is there a smart way to use my database to store the images

create an interigation loop asign them to an array or just call them straight

and then assing the fixed parameter in the slide show?

I can't get the combination of events needed.

ServerCorps
11-27-2002, 06:30 PM
I lost track of what your ultimate goal is. Is it to just ensure all pictures in your slide show fit on the screen?

i'm not a php programmer, but If you are just scaling images to get them to fit on a page, use getimagesize to get width and height, if either one is larger than the threshold you define for max height or width then resize the image by writing out the width or height attribute into the client side html <img> tag, but not both, which will maintain the image proportions.

So:
<pseudocode>

if width > 800 is false , but height is > 600,
then we need to set the height attribute in the client side html
<img src="someimage.jpg" height="400" />
</pseudocode>


This will proportionally resize the image to ???x400 pixels, with the ??? unknown, but the image wont be stretched all out of whack.

Test both width and height, and if either or both are bigger than your pre-defined sizes, size the biggest extent to the right size.

If your'e totally confused, sorry, but I tried to cover all the bases without knowing exactly what you are trying to accomplish.

qnctv.com
11-28-2002, 06:06 AM
Basically I have some long tall pictures and some wide pictures.

The way the height and width was set up it was only for the long tall ones, so the short wide pictures looked sqashed.

<body>
<IMG SRC="http://qnctv.com/preacher/sofa.jpg" NAME="myPicture" WIDTH="300" HEIGHT="400" ALT="Slideshow">

<!--//* where the size is determined the array myPictures is in the head section along with other code to call, loop etc...*//-->
</body>


So some pictures in the myPictures array needed to be say height 300 width 400

Others need to be tall i.e. height 400 width 300

but the sizing of the pictures as done above from the array only alowes one size.

So I wanted to generate an if statement saying that if the picture was tall then size = H400 W300. This I didn't mind specfying with each picture i.e.

<some code>
if $myPicture=tall1.jpg,tall4.jpg and tall5.jpg then {size = H400 W 300}

else {size H300 W400}
</some code>

Now you have told me about getimagesize I was wondering if there was a beter way of doing it e.g.

<some code>
$pictures = newArray(tall.jpg,wide3.jpg etc...)
max = number of images in array
i=o
if i<max then
get ith picture
getimagesize of ith image
image.src=ith image (if H<W then display @ H300 W400
if H==W then display @ H400 W400
else H400 W300)
i++
if i>max i=0
</some code>

Hope this helps

Quincy