Gd Script Issues ?

liunx

Guest
So after couple years of "it" running ok - now it will not work whe creating a THUMB of a pic from any linked URL.<br /><br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->// Start<br />function getsize($url) {<br />   global $userdata;<br />       // Maximum width and height for inpost images leave one of them as 0 to keep the right dimensions.<br />   $iWidth = 200;<br />   $iHeight = 0;<br /><br />     // JPEG Quality<br />     $quality = 85;<br /><br /><br />   $base = basename($url);<br />   $base_ext = substr($base, 0, -4);<br />   $id = $userdata['username'] . "_" . $base_ext;<br /><br />   // broken_link<br />   $broken_link = $phpbb_root_path . "images/no_pic.jpg";<br />   if(@!$size = getimagesize($url)) {<br />   return $broken_link;<br />   }<br /><br />   $img_size = getimagesize($url);<br />   $real_width = $img_size[0];<br />   $real_height = $img_size[1];<br /><br />   if($real_width > $iWidth OR $real_height > $iHeight) {<br /><br />   // Find the height or width if 0 is the value.<br />   if($iHeight == 0) {<br />   $percent = $size[1] / $size[0] * 100;<br />   $iHeight = round($iWidth / 100 * $percent, 0);<br />   }<br />   if($iWidth == 0) {<br />   $percent = $size[0] / $size[1] * 100;<br />   $iWidth = round($iHeight / 100 * $percent, 0);<br />   }<br /><br />   // Look up the extension of the image and use the right functions.<br />   $cut_url = strlen($url) - 3;<br />   $ext = substr($url, $cut_url);<br /><br />   // .jpg<br />   if($ext == "jpg") {<br />   $im = imagecreatefromjpeg($url);<br />     $ow = imagesx( $im );<br />     $oh = imagesy( $im );<br />     $wscale = $iWidth / $ow;<br />     $hscale = $iHeight / $oh;<br />     $scale = ( $hscale < $wscale ? $hscale : $wscale );<br />     $nw = round( $ow * $scale, 0 );<br />     $nh = round( $oh * $scale, 0 );<br />     $dstim = imagecreatetruecolor( $nw, $nh );<br />     imagecopyresampled( $dstim, $im, 0, 0, 0, 0, $nw ,$nh ,$ow ,$oh );<br />     imagejpeg( $dstim, $phpbb_root_path . "images/thumbs/" . $id . ".jpg", $quality);<br />     imagedestroy( $dstim );<br />   $thumb = $id . ".jpg";<br /><br />   // .gif<br />   } elseif($ext == "gif") {<br />   $im = imagecreatefromgif($url);<br />     $ow = imagesx( $im );<br />     $oh = imagesy( $im );<br />     $wscale = $iWidth / $ow;<br />     $hscale = $iHeight / $oh;<br />     $scale = ( $hscale < $wscale ? $hscale : $wscale );<br />     $nw = round( $ow * $scale, 0 );<br />     $nh = round( $oh * $scale, 0 );<br />     $dstim = imagecreatetruecolor( $nw, $nh );<br />     imagecopyresampled( $dstim, $im, 0, 0, 0, 0, $nw ,$nh ,$ow ,$oh );<br />     imagejpeg( $dstim, $phpbb_root_path . "images/thumbs/" . $id . ".gif");<br />     imagedestroy( $dstim );<br />   $thumb = $id . ".gif";<br /><br />   // .png<br />   } elseif($ext == "png") {<br />   $im = imagecreatefrompng($url);<br />     $ow = imagesx( $im );<br />     $oh = imagesy( $im );<br />     $wscale = $iWidth / $ow;<br />     $hscale = $iHeight / $oh;<br />     $scale = ( $hscale < $wscale ? $hscale : $wscale );<br />     $nw = round( $ow * $scale, 0 );<br />     $nh = round( $oh * $scale, 0 );<br />     $dstim = imagecreatetruecolor( $nw, $nh );<br />     imagecopyresampled( $dstim, $im, 0, 0, 0, 0, $nw ,$nh ,$ow ,$oh );<br />     imagepng( $dstim, $phpbb_root_path . "images/thumbs/" . $id . ".png");<br />     imagedestroy( $dstim );<br />   $thumb = $id . ".png";<br /><br />   // Hvis det skulle v閹焑 .php endelser!<br />   } elseif($ext == "php") {<br />   $iUrl = $lang['no_php'];<br />   return $iUrl;<br /><br />   // Ellers kan billedet ikke virke!<br />   } else {<br />   return $broken_link;<br />   }<br />   }<br /><br /><br />         $iUrl = "[" . $phpbb_root_path . "images/thumbs/" . $thumb . "]" . $url;<br />   // Hvis billedet nu ikke er for stort!<br />   if($real_width < $iWidth && $real_height < $iHeight) {<br />         $iUrl = "[" . $url . "]" . $url;<br />   }<br />      return $iUrl;<br />}<!--c2--></div><!--ec2--><br /><br />Any ideas on your end>? <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/blink.gif" style="vertical-align:middle" emoid=":blink:" border="0" alt="blink.gif" /><!--content-->
If you have done no changes to the script and it's no longer working please open a ticket with the help desk and ask the techs to investigate. Link at top of page or in my signature.<!--content-->
....and out of no where it's started working as of this morning - weird. <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/huh.gif" style="vertical-align:middle" emoid=":huh:" border="0" alt="huh.gif" /><!--content-->
Glad its working again!<br /><br />JimE<!--content-->
 
Back
Top