Pages: [1]
|
 |
|
Author
|
Topic: PHP CODING QUESTION (Read 1378 times)
|
pirate
ZboXian
 
Offline
Posts: 32

TE NAMASTE,SCARLET
|
HI ALL:
DOES ANYBODY IN HERE KNOW HOW TO ADD CODE TO A PHP SCRIPT?
I HAVE THIS GREAT SCRIPT FROM ZBOX. HOWEVER, I WOULD LIKE TO BE ABLE TO ADD VARIABLES GIVING ME THE WIDTH AND HEIGHT OF THE IMAGE IN THE VIEWER???
WOULD ANYBODY KNOW THESE?
http://s25test.zboxhosting.com/ack.html
THANK YOU
SCARLET
|
|
|
|
|
Logged
|
|
|
|
dlilahl
Mega ZboXian
  
Offline
Posts: 99

|
Scarlet..hi.
I have a php code to show size underneath individual images that might be incorporated into ths Browse script. Bert might be able to help with this. (hint)
Seems like the script would almost have to be rewritten for anything else. HTH
lila ©
PS. I will see if I can change this..also, let me know if you want the size script.
|
|
|
|
« Last Edit: March 21, 2007, 06:02:53 AM by dlilahl »
|
Logged
|
|
|
|
dlilahl
Mega ZboXian
  
Offline
Posts: 99

|
Scarlet...just in case... here are some things that I posted about your question.
http://www.dlilahl.zboxhosting.com/PHPfunc/1gives_size.php
http://dlilahl.zboxhosting.com/PHPfunc/1gives_size.txt
The below is text from the Browse script which may tell us something as to how it could or could not work well. Quote: - i have added a new varible (scale) to decide if you want to scale the pictures that do not excede the max width/height variable - fixed a bug where images that were wider than tall could exceed
the max height varible and images that were taller than wide could exceed the max width variable
HTH lila ©
|
|
|
|
« Last Edit: February 24, 2007, 08:44:20 AM by dlilahl »
|
Logged
|
|
|
|
|
|
garenasix
Posting Maniac
    
Offline
Posts: 233

|
i found this dont know if it will help you
Getting Started
Let's say you have a great line of socks that you want to sell through your site. Well, you're proud of these fantastic socks and want people to see as much of them as possible: on the product views page, on the search page, on the listing page, etc. But this doesn't mean that you have to use the default image size each time, nor risk the quality of the image being degraded when it is stretched or crunched into a space. Some socks are longer than others and so you might have the image sizes ranging from 200x400 up to 600x750 pixels.
To begin writing the function, we have to declare it as such... Then we have to throw in our attributes. We want to restrict our image, so we have to let the function know the dimensions to which we want to restrict it, and we have to know what the original image size is to begin with (we'll get to that part in a second).
<?php
function imageResize($width, $height, $target) {
//takes the larger size of the width and height and applies the formula accordingly...this is so this script will work dynamically with any size image
if ($width > $height) { $percentage = ($target / $width); } else { $percentage = ($target / $height); }
//gets the new value and applies the percentage, then rounds the value $width = round($width * $percentage); $height = round($height * $percentage);
//returns the new sizes in html image tag format...this is so you can plug this function inside an image tag and just get the
return "width=\"$width\" height=\"$height\"";
}
?>
Before we take our new function on a test drive, we need to get the width and height of the image that we want to display. There is a magical command in PHP called getimagesize(). This command, used properly, will return the image width, height, type, and even the width and height in HTML image tag format (width="x" height="y").
$mysock = getimagesize("images/sock001.jpg");
Now, $mysock is an array that holds vital information about the particular image we want to display. In index 0, we have the width ($mysock[0]), and in index 1, we have the height ($mysock[1]). That's really all we need, in order to get what we want done. Want to see the function... well, function? Here we go! The Function in Action
Let's say you want to display a list of your beautiful socks, but you want room on the page to show them neatly in a row, and to do that they cannot be larger than 150 pixels tall or wide.
<?php
//get the image size of the picture and load it into an array $mysock = getimagesize("images/sock001.jpg");
?>
<!-using a standard html image tag, where you would have the width and height, insert your new imageResize() function with the correct attributes -->
<img src="images/sock001.jpg" <?php imageResize($mysock[0], $mysock[1], 150); ?>>
That's it! Now, no matter what the original file size, it will be restricted to no more than 150 pixels in width or height (or whatever you specify).
Now, you may think "This sounds too good to be true. Is there any circumstance where using this technique could prove disastrous?"
Actually, there is. Keep in mind that you aren't changing the file's original size. That same 200x400, 50 KB picture you uploaded only moments ago is still 200x400, 50 KB. This script only changes height and width attribute in HTML, so that your original picture conforms to the height and width you think will look best on your Web page.
Having said that, if you have a page that lists 50-something products, the page will display the way you want it to, but uses will have to download all 50 of those 50 KB pictures, which could take some time. So I'd have to recommend this technique in situations where you're only showing a few pictures at a time.
|
|
|
|
« Last Edit: February 24, 2007, 06:54:48 PM by garenasix »
|
Logged
|
|
|
|
pirate
ZboXian
 
Offline
Posts: 32

TE NAMASTE,SCARLET
|
HI ALL:
UHHHH....eeeeeeeeeek!!! MORE CAFE, POR FAVOR? LOL
I JUST GOT ONLINE AND I AM NOT PROCESSING YET. I HAVE TO STUDY THE LAST RESPONSE.
THANK YOU ALL SOOOOO MUCH FOR HELPING ME?
I AM NOT SURE WHAT TO DO WITH WHAT YOU HAVE SAID THOUGH? I AM THAT DUHHHHH RE: PHP. I FEEL VERYY SATISFIED IF I CAN GO IN AND JUST CHANGE PARMS IN A SCRIPT WITHOUT BLOWING IT UP. LOLOL
YESTERDAY,,,, I FOUND THIS!!!
$old_x=imageSX($src_img); $old_y=imageSY($src_img);
IT SUPPOSEDLY IS SUPPOSED TO DISPLAY THE WIDTH AND HEIGHT SIZE.
I DON*T NEED THE WIDTH AND HEIGHT OF THE THUMBNAILS BUT THE ORIGINAL (OR ONE DISPLAYED AT TOP) IMAGE.
HOWEVER,,,,,IF THIS DOES NOT WORK AND,,,, I HAVE NO IDEA WHERE TO "STICK IT" (BE NICE :-)))
THEN I AM AFRAID I WILL WIND UP GETTING INTO MORE AND MORE TROUBLE WHEN I HAVE ALREADY RECONFIGURED THE SCRIPT TO WHAT I WANT IT TO LOOK LIKE.
IT ALSO DAWNED ON ME THAT I HAVE OTHER PHP IMAGE VIEWERS THAT DO DISPLAY HEIGHT AND WIDTH BUT, AGAIN, SAME PROBLEM?
THE SCRIPTS WHEN LOOKED AT, SEEM SO SPECIFIC RE: WHERE TO PUT WHAT PARAMETERS THAT EVEN IF I HAVE THE PARMS. I HAVE NOOOO IDEA WHERE TO PLACE THEM?
AGAIN,,,, I WILL HAVE TO STUDY
IS THAT A VALID QUESTION OR TOO EARLY?
HOW DOES A PERSON KNOW , IF ONE FINDS PARAMETER CODE TO USE, WHERE TO PLACE IT WITHIN THE SCRIPT? (THESE SCRIPTS SEEM VERY TAILOR MADE)
THANK YOU SCARLET
|
|
|
|
|
Logged
|
|
|
|
pirate
ZboXian
 
Offline
Posts: 32

TE NAMASTE,SCARLET
|
HI ALL:
WELL, I FINALLY GOT A BUNCH OF OTHER PROBLEMS SOLVED AND I AM BACK ON THIS ONE.
GARENASIX,,,,I AM TRYING TO DISPLAY ON THE VIEWER THE HEIGHT AND WIDTH.
DO I USE THE CODE YOU POSTED IN YOUR REPLY?
IF SO, WHERE DO I PUT IT IN THE SCRIPT?
RE: THE CODE I POSTED THAT I HAD FOUND. ?????? FAWGET IT???
I SEARCHED AND SEARCHED. THERE ARE SOOO MANY PLACES THAT ONE IS BETTER OFF TALKING TO "REAL" PEOPLE WHO KNOW WHAT THEY ARE DOING. LIKE YOU :-)
I ONLY NEED TO DISPLAYED THE IMAGE HEIGHT AND WIDTH OF THE MAIN IMAGE AT THE TOP THAT WILL BE SHOWING , NOT THE THUMBNAILS.
IF THERE IS A WAY, GREAT. IF NOT, THAT IS FINE TOO.
THANK YOU SCARLET
|
|
|
|
|
Logged
|
|
|
|
daysjourney
Newbie

Offline
Posts: 2
|
Hi Everyone,
I am a long time lurker but this is my first post. I have been using a CGI image_lister viewer script from Ultra's free scripts. This viewer includes the height and width of all the images in a directory. Just beam in the Zip file below to any directory where you want it. The Zip has two files including a readme file, but basically all you have to do is CHMOD the image_lister.cgi file to 755 and click on it.
http://lanny.zboxhosting.com/temporary/image_lister1.zip
Lanny
|
|
|
|
|
Logged
|
|
|
|
ZboX
Founder
Administrator
Posting Maniac
    
Offline
Posts: 1491

What 'ya got there??
|
Hi Everyone, I am a long time lurker but this is my first post. I have been using a CGI image_lister viewer script from Ultra's free scripts. This viewer includes the height and width of all the images in a directory. Just beam in the Zip file below to any directory where you want it. The Zip has two files including a readme file, but basically all you have to do is CHMOD the image_lister.cgi file to 755 and click on it. http://lanny.zboxhosting.com/temporary/image_lister1.zipLanny Well done on your first post Lanny. Hope to see more of ya.
~;-)
Bert
|
|
|
|
|
Logged
|
|
|
|
pirate
ZboXian
 
Offline
Posts: 32

TE NAMASTE,SCARLET
|
HI LANNY: THANK YOU FOR THE INFO BUT I ALREADY HAVE IT, HAVE FOR YEARS. THEN I FOUND ONE THAT I COULD ADJUST THE CODE TO CHANGE THE SIZE OF THE THUMBNAILS BY RIVERDRIFT. HOWEVER, COMPARED TO THE SCRIPT THAT BERT RECENTLY GAVE ME, IT LOADS VERY SLOWLY AND FILLS UP WEBTV USER'S CACHE VERY QUICKLY.
THE ONE I POSTED IS GREAT FOR RATE OF LOADING , BEING ABLE TO CHANGE THUMBNAIL SIZES AND NUMBER OF THUMBNAILS PER ROW. HOWEVER, IT DOES NOT HAVE 2 THINGS THAT IMAGERS GO ACCORDING TO WHEN LOOKING AT GRAPHICS,,THE NAMES OF THE IMAGES AND THE HEIGHT AND WIDTH.
THAT IS WHY I HAVE BEEN ASKING IF ANYONE WHO KNOWS HOW TO CODE PHP COULD HELP ME CODE THIS PROGRAM? IF WE HAD THOSE OPTIONS SHOWN TO US ALSO, THAT IMAGE VIEWER WOULD BE AMAZING. IT ALREADY IS THE BEST ONE I HAVE SEEN.
BTW, IF ANYBODY ELSE HAPPENS TO HAVE ANY SCRIPTS FOR IMAGE VIEWERS, PLEASE GIVE A YELL?
OR, LIKE MY ORIGINAL QUESTION, COULD HELP FIGURE OUT HOW TO CODE THIS ONE TO SHOW TITLES AND HEIGHT AND WIDTH?
THANK YOU, SCARLET
|
|
|
|
|
Logged
|
|
|
|
pirate
ZboXian
 
Offline
Posts: 32

TE NAMASTE,SCARLET
|
GARENASIX, LILA:
THANX SO MUCH FOR YOUR HELP. I ALREADY CHANGED THE CODE. I CHANGED THE BGCOLOR, I ADDED SOME TITLES, I CHANGED THE SIZE OF THE THUMBNAILS, HOW MANY PER ROW. I FIGURED OUT THE PARAMETERS THAT WERE THERE AND JUST CHANGED THE NUMBERS.
HOWEVER, RE: ADDING SHOWING THE TITLES AND IMAGE'S HEIGHT AND WIDTH IS A COMMAND THAT IS NOT THERE.
THAT IS WHAT I AM HAVING TROUBLE FINDING FOR I KNOW NOTHING RE: PHP. I JUST TRY TO FIGURE OUT WHAT COMMANDS ARE ALREADY FOR WHAT AND CHANGE ACCORDINGLY BUT I AM UNABLE, DUE TO LACK OF KNOWLEDGE IN THIS AREA, WHAT PHP COMMANDS/CODES ARE.
I HAVE OTHER IMAGE LISTERS THAT SHOW THE TITLES AND SIZES OF THE IMAGES BUT I DON'T KNOW THEM TO BE ABLE TO RECOGNIZE THEM AND RECREATE IN THIS SCRIPT. OTHERWISE I WOULD TRY THAT.
SCARLET
|
|
|
|
|
Logged
|
|
|
|
garenasix
Posting Maniac
    
Offline
Posts: 233

|
n/p wish i could be more help im not really all that big on PHP and CSS and not even javascript anymore
|
|
|
|
|
Logged
|
|
|
|
pirate
ZboXian
 
Offline
Posts: 32

TE NAMASTE,SCARLET
|
GARENASIX, ALL: THANK YOU FOR YOUR INFORMATION FROM BEFORE THAT IS GOOD FOR LEARNING PURPOSES.
RIGHT NOW, THOUGH, I DON'T HAVE TIME TO LEARN PHP BUT....I WOULD LIKE TO PLUG IN SOME CODE.
I FOUND THE NECESSARY CODE FOR -ADDING NAMES -ADDING HEIGHT AND WIDTH
IN AN IMAGE VIEWER.
IT IS IN THIS VIEWER THAT I HAVE:
http://piratevoyager.com/0--JAN07/TEST/1-viewer.php
THIS IS THE NEW VIEWER THAT I WANT TO ADD IT TO:
http://piratevoyager.com/0--JAN07/TEST/1NEWVIEWERfeb07.php
WOULD YOU OR ANYBODY ELSE KNOW WHERE I COULD PLUG IN THE PART THAT SAYS "DISPLAYS NAME" DISPLAYS HEIGHT AND WIDTH"
***IT IS NEAR THE VERY BEGINNING.
I DON'T KNOW IF PHP WORKS IN AN ORDERLY FASHION, IE. THE COMMANDS HAVE TO BE PUT IN A CERTAIN WAY OR IS IT A PROGRAM THAT THE COMMANDS JUST HAVE TO BE THERE BY THE TIME IT IS LOADED?
MEBEEE ANYBODY WHO HAS HAD ANYTHING TO DO WITH PHP COULD TELL ME WHERE TO PUT IT?
(BE NICE...LOLOLOL)
AGAIN THANK YOU
SCARLET
|
|
|
|
|
Logged
|
|
|
|
ZboX
Founder
Administrator
Posting Maniac
    
Offline
Posts: 1491

What 'ya got there??
|
GARENASIX, ALL: THANK YOU FOR YOUR INFORMATION FROM BEFORE THAT IS GOOD FOR LEARNING PURPOSES. RIGHT NOW, THOUGH, I DON'T HAVE TIME TO LEARN PHP BUT....I WOULD LIKE TO PLUG IN SOME CODE. I FOUND THE NECESSARY CODE FOR -ADDING NAMES -ADDING HEIGHT AND WIDTH IN AN IMAGE VIEWER. IT IS IN THIS VIEWER THAT I HAVE: http://piratevoyager.com/0--JAN07/TEST/1-viewer.php THIS IS THE NEW VIEWER THAT I WANT TO ADD IT TO: http://piratevoyager.com/0--JAN07/TEST/1NEWVIEWERfeb07.phpWOULD YOU OR ANYBODY ELSE KNOW WHERE I COULD PLUG IN THE PART THAT SAYS "DISPLAYS NAME" DISPLAYS HEIGHT AND WIDTH" ***IT IS NEAR THE VERY BEGINNING. I DON'T KNOW IF PHP WORKS IN AN ORDERLY FASHION, IE. THE COMMANDS HAVE TO BE PUT IN A CERTAIN WAY OR IS IT A PROGRAM THAT THE COMMANDS JUST HAVE TO BE THERE BY THE TIME IT IS LOADED? MEBEEE ANYBODY WHO HAS HAD ANYTHING TO DO WITH PHP COULD TELL ME WHERE TO PUT IT? (BE NICE...LOLOLOL) AGAIN THANK YOU SCARLET HI SCARLET. YOU KNOW I JUST REMEMBERED THERE IS A WEBTV NEWSGROUP DEDICATED TO PHP. MAYBE THEY COULD BE OF SOME HELP?
~;-)
BERT
|
|
|
|
|
Logged
|
|
|
|
dlilahl
Mega ZboXian
  
Offline
Posts: 99

|
HI SCARLET, LILA, I PLAYED AROUND AND GOOGLED BUT COULDN'T FIGURE OUT HOW TO ADD THE SIZE AND WIDTH UNDER THE IMAGE. I AM NOT PHP SAVY..LOL
LILA, BRAIN?
YOU MAY BE RIGHT. THE SCRIPT MAY HAVE TO BE REWRITTEN...BUT I WOULDN'T KNOW HOW. HOPE YOU MAY BE ABLE FIGURE SOMETHING OUT.
IF ANYONE ELSE KNOWS ANYTHING..PLEASE POST.
...;-) ROX I do have something wrong with my brain. But I am taking meds for it. It's a disease that is called POST trama.  lila
|
|
|
|
|
Logged
|
|
|
|
MisRox
Founder
Administrator
Posting Maniac
    
Offline
Posts: 232

|
I do have something wrong with my brain. But I am taking meds for it. It's a disease that is called POST trama.  lila Lila
That just shows my brain was getting ahead of my fingers! I believe I meant "Brian". LOL
...;-) Rox
|
|
|
|
|
Logged
|
Visit Me at:
|
|
|
pirate
ZboXian
 
Offline
Posts: 32

TE NAMASTE,SCARLET
|

I FOUND SOME MORE CODE FOR ADDING IMAGE SIZES BUT I GUESS YOU FOLKS ANSWERED THE PROVERBIALLY BOTTOM LINE WHICH IS THE CODE HAS TO BE IN A CERTAIN ORDER= REPROGRAMMING THE WHOLE THING.
PHP ? NOT ME...LOL
SPEAKING OF BRAIN BRIAN SOUNDS FREUDIAN? :-)))
IS THAT WHAT KITTY IS FOR? MEEEEEE-OWWWWW!!!!!
WELL, IT'S ON THE BOARD, IF ANY PHP GURU IS BORED,,FEEL LIKE BUILDING AN IMAGE VIEWER WITH THE WORKS,,, TO GO?
STARBUCKS IS ON ME!!!
SCARLET
|
|
|
|
|
Logged
|
|
|
|
Pages: [1]
|
|
|
|
|