rondog Posted April 16, 2008 Share Posted April 16, 2008 Hi I am calling a php file in my img src tag to generate a thumbnail, but it doesnt seem to be working:\ the img src tag: <img src=createphotothumb.php?source=photos/".$row['filename']."> createphotothumb.php <?php header("Content-type: image/jpeg"); $photofile = $_GET['source']; $img = imagecreatefromjpeg( $photofile ); $width = imagesx( $img ); $height = imagesy( $img ); $new_width = 150; $new_height = floor( $height * ( $thumbWidth / $width ) ); $tmp_img = imagecreatetruecolor( $new_width, $new_height ); imagecopyresized( $tmp_img, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height ); imagejpeg( $tmp_img, $mkThumbFile,40 ); imagedestroy($tmp_img); ?> When I right click where the image is suppose to be, the properties say its: http://dopserv1.com/hosted/army/createphotothumb.php?source=photos/img_2602.jpg so it is reading from the DB..any ideas? Quote Link to comment Share on other sites More sharing options...
haku Posted April 16, 2008 Share Posted April 16, 2008 .$row['filename']. Try taking away that second period. Quote Link to comment Share on other sites More sharing options...
rondog Posted April 16, 2008 Author Share Posted April 16, 2008 .$row['filename']. Try taking away that second period. nope that broke my script when I did that :-/ I notice if you go directly to http://dopserv1.com/hosted/army/createphotothumb.php?source=photos/img_2602.jpg it outputs text rather than an image. So their is something wrong with my createphotothumb.php file Quote Link to comment Share on other sites More sharing options...
haku Posted April 16, 2008 Share Posted April 16, 2008 I noticed you also left a quotation mark off after src Quote Link to comment Share on other sites More sharing options...
rondog Posted April 16, 2008 Author Share Posted April 16, 2008 oh good find man..the problem is still their though. Its my createphotothumb.php file not working Quote Link to comment Share on other sites More sharing options...
haku Posted April 16, 2008 Share Posted April 16, 2008 Your php script looks fine as far as I can tell (its late here though, so that may not be very far). I think the problem is in your tag. Can you post some code from before (and including) the image tag? Something is strange there. Quote Link to comment Share on other sites More sharing options...
rondog Posted April 16, 2008 Author Share Posted April 16, 2008 Well this is the whole line that is suppose to output the image: <?php echo "<td><div id=\"$row[id]-$row[name]\"><a href=\"?gid=$gid&sid=$sid&segid=$row[segment_id]&pic=$row[id]\"><img src=\"createphotothumb.php?source=photos/".$row['filename']."\"></a></div></td>\n"; ?> and then the createphotothumb.php file: <?php header("Content-type: image/jpeg"); $photofile = $_GET['source']; $img = imagecreatefromjpeg( $photofile ); $width = imagesx( $img ); $height = imagesy( $img ); $new_width = 150; $new_height = floor( $height * ( $thumbWidth / $width ) ); $tmp_img = imagecreatetruecolor( $new_width, $new_height ); imagecopyresized( $tmp_img, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height ); imagejpeg( $tmp_img, $mkThumbFile,40 ); imagedestroy($tmp_img); ?> Quote Link to comment Share on other sites More sharing options...
craygo Posted April 16, 2008 Share Posted April 16, 2008 Is the photo directory in the army folder?? Quote Link to comment Share on other sites More sharing options...
rondog Posted April 16, 2008 Author Share Posted April 16, 2008 yes the paths are correct. I am positive. Quote Link to comment Share on other sites More sharing options...
craygo Posted April 16, 2008 Share Posted April 16, 2008 Another guy on the forums was having the exact same problem. I took his code and put it on my box and it worked fine. Might be an operating system problem or a webserver problem. I am using Windows XP Pro with IIS and php 5.1.2. try just outputting the image instaed of saving it which is what you look like your doing imagejpeg($tmp_img); Ray Quote Link to comment Share on other sites More sharing options...
rondog Posted April 16, 2008 Author Share Posted April 16, 2008 ok I tried that and same thing. I dont think its a server thing because I have another createthumb.php file converting an FLV to a jpg and it works fine. I am doing the same exact process basically. http://dopserv1.com/hosted/army/createthumb.php?source=videos/1207354947a3-t9-001.flv see how that works?? thats using this code: <?php header("Content-type: image/jpeg"); $moviefile = $_GET['source']; $mov = new ffmpeg_movie($moviefile,false); $img = $mov->getFrame(50); $showImg = $img->toGDImage(); $mkNewImg = new ffmpeg_frame($showImg); $maxWid = 150; $oldWid = $mkNewImg->getWidth(); $oldHgt = $mkNewImg->getHeight(); $movRatio = $oldWid/$oldHgt; if($oldWid > $maxWid) { $newWid = $maxWid; } $newHgt = $newWid / $movRatio; $mkNewImg->resize($newWid,$newHgt); $newImg = $mkNewImg->toGDImage(); imagejpeg($newImg,$mkThumbFile,40); imagedestroy($newImg); ?> Quote Link to comment Share on other sites More sharing options...
craygo Posted April 16, 2008 Share Posted April 16, 2008 Are the permissions different for the folders?? Quote Link to comment Share on other sites More sharing options...
rondog Posted April 16, 2008 Author Share Posted April 16, 2008 nope they are both 755 Quote Link to comment Share on other sites More sharing options...
rondog Posted April 16, 2008 Author Share Posted April 16, 2008 hmm still no luck ??? Quote Link to comment Share on other sites More sharing options...
rondog Posted April 16, 2008 Author Share Posted April 16, 2008 I am getting the same result on a completely different server. Their is something wrong with my file but cant figure it out Quote Link to comment Share on other sites More sharing options...
rondog Posted April 16, 2008 Author Share Posted April 16, 2008 Ok I managed to figure it out!! I changed: <?php $new_height = floor($height * ($thumbWidth / $width)); to $new_height = floor($height * ($new_width / $width)); ?> I didnt realized $thumbWidth was undefined. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.