【发布时间】:2012-03-28 09:36:03
【问题描述】:
当我尝试在我的网站上为全尺寸图像添加水印时,我在 PHP 中遇到了一个非常烦人的问题。水印可以正常工作数周,但突然开始显示此错误:图像“bla bla”无法显示,因为它包含错误
我检查了一切,一切似乎都运行良好!我被卡住了,我不知道该怎么办。
这是我的水印 php 文件:
需要一次“maincore.php”; if (isset($_GET['photo_id']) && isnum($_GET['photo_id'])) { $result = dbquery("SELECT td.*, tc.* FROM ".DB_PRODUCTS." td LEFT JOIN ".DB_PRODUCT_CATS." tc ON td.product_cat=tc.cat_id WHERE product_id='".$_GET['photo_id'] ."'"); $data = dbarray($result); 定义(“PHOTODIR”,BASEDIR。“下载/图像/”); $parts = explode(".", $data['product_image']); $wm_file1 = $parts[0]."_w1.".$parts[1]; $wm_file2 = $parts[0]."_w2.".$parts[1]; if (!isset($_GET['full'])) { $wm_file = PHOTODIR.$wm_file1; } 别的 { $wm_file = PHOTODIR.$wm_file2; } header("内容类型:图片/jpg"); $img = PHOTODIR.$data['product_image']; $cop = BASEDIR.$settings['photo_watermark_image']; if (preg_match("/.jpg/i", strtolower($img)) || preg_match("/.jpeg/i", strtolower($img))) { $image = imagecreatefromjpeg($img); } else if (preg_match("/.png/i", strtolower($img))) { $image = imagecreatefrompng($img); } else if (preg_match("/.gif/i", strtolower($img))) { $image = imagecreatefromgif($img); $sizeX = imagesx($image); $sizeY = imagesy($image); $image_tmp = imagecreatetruecolor($sizeX, $sizeY); $ica = imagecolorallocate($image_tmp, 255, 255, 255); 图像填充($image_tmp, 0, 0, $ica); if ($settings['thumb_compression'] == "gd2") { imagecopyresampled($image_tmp, $image, 0, 0, 0, 0, $sizeX, $sizeY, $sizeX, $sizeY); } 别的 { imagecopyresized($image_tmp, $image, 0, 0, 0, 0, $sizeX, $sizeY, $sizeX, $sizeY); } $tmp = PHOTODIR.md5(time().$img).'.tmp'; imagejpeg($image_tmp, $tmp); imagedestroy($image_tmp); $image = imagecreatefromjpeg($tmp); 取消链接($tmp); } if (file_exists($cop) && preg_match("/.png/i", strtolower($cop)) && $settings['photo_watermark']) { $image2 = 假; $image_dim_x = imagesx($image); $image_dim_y = imagesy($image); $copyright = imagecreatefrompng($cop); $copyright_dim_x = imagesx($copyright); $copyright_dim_y = imagesy($copyright); $where_x = $image_dim_x - $copyright_dim_x - 5; $where_y = $image_dim_y - $copyright_dim_y - 5; imagecopy ($image, $copyright, $where_x, $where_y, 0, 0, $copyright_dim_x, $copyright_dim_y); $thumb_w = 0; $thumb_h = 0; if (!isset($_GET['full'])) { if ($image_dim_x > $settings['photo_w'] || $image_dim_y > $settings['photo_h']) { 如果($image_dim_x $image_dim_y){ $thumb_w = $settings['photo_w']; $thumb_h = round(($image_dim_y * $settings['photo_w']) / $image_dim_x); } 别的 { $thumb_w = $settings['photo_w']; $thumb_h = $settings['photo_h']; } } 别的 { $thumb_w = $image_dim_x; $thumb_h = $image_dim_y; } $image2 = imagecreatetruecolor($thumb_w, $thumb_h); if ($settings['thumb_compression'] == "gd2") { imagecopyresampled($image2, $image, 0, 0, 0, 0, $thumb_w, $thumb_h, $image_dim_x, $image_dim_y); } 别的 { imagecopyresized($image2, $image, 0, 0, 0, 0, $thumb_w, $thumb_h, $image_dim_x, $image_dim_y); } 图像销毁($图像); } } //创建图像 if ($settings['photo_watermark_save']) { imagejpeg(($image2 ? $image2 : $image), $wm_file); } imagejpeg((isset($image2) && $image2 ? $image2 : $image)); imagedestroy((isset($image2) && $image2 ? $image2 : $image)); if (isset($copyright) && is_resource($copyright)) { ImageDestroy($copyright); } } 别的 { 重定向(“index.php”); }请帮助我!谢谢!
【问题讨论】: