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? Link to comment https://forums.phpfreaks.com/topic/101412-solved-trying-to-generate-thumbnail/ 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. Link to comment https://forums.phpfreaks.com/topic/101412-solved-trying-to-generate-thumbnail/#findComment-518683 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 Link to comment https://forums.phpfreaks.com/topic/101412-solved-trying-to-generate-thumbnail/#findComment-518686 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 Link to comment https://forums.phpfreaks.com/topic/101412-solved-trying-to-generate-thumbnail/#findComment-518695 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 Link to comment https://forums.phpfreaks.com/topic/101412-solved-trying-to-generate-thumbnail/#findComment-518721 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. Link to comment https://forums.phpfreaks.com/topic/101412-solved-trying-to-generate-thumbnail/#findComment-518725 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); ?> Link to comment https://forums.phpfreaks.com/topic/101412-solved-trying-to-generate-thumbnail/#findComment-518730 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?? Link to comment https://forums.phpfreaks.com/topic/101412-solved-trying-to-generate-thumbnail/#findComment-518732 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. Link to comment https://forums.phpfreaks.com/topic/101412-solved-trying-to-generate-thumbnail/#findComment-518745 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 Link to comment https://forums.phpfreaks.com/topic/101412-solved-trying-to-generate-thumbnail/#findComment-518753 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); ?> Link to comment https://forums.phpfreaks.com/topic/101412-solved-trying-to-generate-thumbnail/#findComment-518798 Share on other sites More sharing options...
craygo Posted April 16, 2008 Share Posted April 16, 2008 Are the permissions different for the folders?? Link to comment https://forums.phpfreaks.com/topic/101412-solved-trying-to-generate-thumbnail/#findComment-518807 Share on other sites More sharing options...
rondog Posted April 16, 2008 Author Share Posted April 16, 2008 nope they are both 755 Link to comment https://forums.phpfreaks.com/topic/101412-solved-trying-to-generate-thumbnail/#findComment-518816 Share on other sites More sharing options...
rondog Posted April 16, 2008 Author Share Posted April 16, 2008 hmm still no luck ??? Link to comment https://forums.phpfreaks.com/topic/101412-solved-trying-to-generate-thumbnail/#findComment-518877 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 Link to comment https://forums.phpfreaks.com/topic/101412-solved-trying-to-generate-thumbnail/#findComment-518895 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. Link to comment https://forums.phpfreaks.com/topic/101412-solved-trying-to-generate-thumbnail/#findComment-518898 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.