Jump to content
Sign in to follow this  
vrflyer

Gd Script Issues ?

Recommended Posts

So after couple years of "it" running ok - now it will not work whe creating a THUMB of a pic from any linked URL.

 

>// Start
function getsize($url) {
  global $userdata;
  	// Maximum width and height for inpost images leave one of them as 0 to keep the right dimensions.
  $iWidth = 200;
  $iHeight = 0;

 // JPEG Quality
 $quality = 85;


  $base = basename($url);
  $base_ext = substr($base, 0, -4);
  $id = $userdata['username'] . "_" . $base_ext;

  // broken_link
  $broken_link = $phpbb_root_path . "images/no_pic.jpg";
  if(@!$size = getimagesize($url)) {
  return $broken_link;
  }

  $img_size = getimagesize($url);
  $real_width = $img_size[0];
  $real_height = $img_size[1];

  if($real_width > $iWidth OR $real_height > $iHeight) {

  // Find the height or width if 0 is the value.
  if($iHeight == 0) {
  $percent = $size[1] / $size[0] * 100;
  $iHeight = round($iWidth / 100 * $percent, 0);
  }
  if($iWidth == 0) {
  $percent = $size[0] / $size[1] * 100;
  $iWidth = round($iHeight / 100 * $percent, 0);
  }

  // Look up the extension of the image and use the right functions.
  $cut_url = strlen($url) - 3;
  $ext = substr($url, $cut_url);

  // .jpg
  if($ext == "jpg") {
  $im = imagecreatefromjpeg($url);
 $ow = imagesx( $im );
 $oh = imagesy( $im );
 $wscale = $iWidth / $ow;
 $hscale = $iHeight / $oh;
 $scale = ( $hscale < $wscale ? $hscale : $wscale );
 $nw = round( $ow * $scale, 0 );
 $nh = round( $oh * $scale, 0 );
 $dstim = imagecreatetruecolor( $nw, $nh );
 imagecopyresampled( $dstim, $im, 0, 0, 0, 0, $nw ,$nh ,$ow ,$oh );
 imagejpeg( $dstim, $phpbb_root_path . "images/thumbs/" . $id . ".jpg", $quality);
 imagedestroy( $dstim );
  $thumb = $id . ".jpg";

  // .gif
  } elseif($ext == "gif") {
  $im = imagecreatefromgif($url);
 $ow = imagesx( $im );
 $oh = imagesy( $im );
 $wscale = $iWidth / $ow;
 $hscale = $iHeight / $oh;
 $scale = ( $hscale < $wscale ? $hscale : $wscale );
 $nw = round( $ow * $scale, 0 );
 $nh = round( $oh * $scale, 0 );
 $dstim = imagecreatetruecolor( $nw, $nh );
 imagecopyresampled( $dstim, $im, 0, 0, 0, 0, $nw ,$nh ,$ow ,$oh );
 imagejpeg( $dstim, $phpbb_root_path . "images/thumbs/" . $id . ".gif");
 imagedestroy( $dstim );
  $thumb = $id . ".gif";

  // .png
  } elseif($ext == "png") {
  $im = imagecreatefrompng($url);
 $ow = imagesx( $im );
 $oh = imagesy( $im );
 $wscale = $iWidth / $ow;
 $hscale = $iHeight / $oh;
 $scale = ( $hscale < $wscale ? $hscale : $wscale );
 $nw = round( $ow * $scale, 0 );
 $nh = round( $oh * $scale, 0 );
 $dstim = imagecreatetruecolor( $nw, $nh );
 imagecopyresampled( $dstim, $im, 0, 0, 0, 0, $nw ,$nh ,$ow ,$oh );
 imagepng( $dstim, $phpbb_root_path . "images/thumbs/" . $id . ".png");
 imagedestroy( $dstim );
  $thumb = $id . ".png";

  // Hvis det skulle være .php endelser!
  } elseif($ext == "php") {
  $iUrl = $lang['no_php'];
  return $iUrl;

  // Ellers kan billedet ikke virke!
  } else {
  return $broken_link;
  }
  }


	 $iUrl = "[" . $phpbb_root_path . "images/thumbs/" . $thumb . "]" . $url;
  // Hvis billedet nu ikke er for stort!
  if($real_width < $iWidth && $real_height < $iHeight) {
	 $iUrl = "[" . $url . "]" . $url;
  }
  return $iUrl;
}

 

Any ideas on your end>? :goof:

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

....and out of no where it's started working as of this morning - weird. :goof:

Edited by vrflyer

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...