Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 06-02-2003, 05:04 PM   #1 (permalink)
Ilya020
Techno Rat
 
Ilya020's Avatar
 
Join Date: Jan 2003
Location: San Diego
Posts: 559
Ilya020 is on a distinguished road
Send a message via AIM to Ilya020
Question Script Not Working

Hello guys,

I have these two PHP scripts; gen.php and thumbs.php.
This is for an images gallary where gen.php produces the thumbnails and thumbs.php displays them.

I am trying to get this to work but the images keep getting broken. http://sig11.zemos.net/test/thumbs.php

here is the source for gen.php

Code:
<?php 

$t_width = 100; // Thumbnail width 

// get and display jpeg images 
if(stristr($QUERY_STRING,".jpg")){ 
header("Content-type: image/jpeg"); 
$srcimage = imagecreatefromjpeg($QUERY_STRING); 
$width = imageSX($srcimage); 
$height = imageSY($srcimage); 
$newh1= $height / $width; 
$newh2= $newh1 * $t_width; 
$destimage = imagecreate($t_width,$newh2); 
imagecopyresized($destimage,$srcimage,0,0,0,0,$t_width,$newh2,$width,$height); 
ImageJPEG($destimage); 
ImageDestroy($destimage); 
} 


// on a problem geneterate an image with ERROR in it 
/*else { 
$im = imagecreate(100,100); 
$blue = imagecolorallocate($im,0,0,200); 
$red = imagecolorallocate($im,255,0,0); 
imagestring($im,2,2,5,"ERROR",$red); 
imageGIF($im); 
imagedestroy($im); 
} */

?>
Here is thumbs.php

Code:
<?php 
// Set variables 
$default_dir = "./images"; // Relative to current location 


// Directory Scan 
if(!($dp = opendir($default_dir))) die("Cannot open $dir"); 
// Place images into image tag 
while($file = readdir($dp)){ 
    if($file != '.' && $file != '..' && stristr($file,"jpg")) echo "<a 
href=\"$default_dir/$file\"><img 
src=\"./gen.php?$default_dir/$file\"></a>\r\n"; 
} 

closedir($dp); 


?>
Any ideas?

Thank you

Ilya
__________________
> SELECT * FROM users WHERE clue > 0
0 rows returned
Ilya020 is offline   Reply With Quote
Old 06-02-2003, 06:40 PM   #2 (permalink)
saline
I am red.
 
saline's Avatar
 
Join Date: Feb 2003
Location: Cleveland, OH
Posts: 139
saline is on a distinguished road
Here's a question, and keep in mind I know close to nothing about php, but.

There's this little dealy:
Code:
$srcimage = imagecreatefromjpeg($QUERY_STRING);
Now I don't know imagecreatefromjpeg from a hole in the wall, is that built in or did you write it? Either way, what file extention does it use for the final image .jpeg or .jpg ?

because later, when displaying the images, you look only for .jpg

in the thumbs.php here:
Code:
 if($file != '.' && $file != '..' && stristr($file,"jpg"))
Perhaps it's not finding the right pictures because you're looking for the wrong extention (.jpg instead of .jpeg)?

In the same vein when you have an error it seems like you're creating a .gif and then again looking for .jpg?

But then again I could be way off, good luck!
__________________
http://home.cwru.edu/~cak19

It's my homepage with odd little bits of javascript.
saline is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
running a script at designated time tzarin PHP 5 05-12-2004 07:11 PM
login script trevor PHP 21 01-17-2003 06:28 AM
cgi not working on a new script sde PHP 3 05-20-2002 08:29 PM


All times are GMT -8. The time now is 04:44 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting