Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP调整脚本大小在新服务器/域上不起作用_Php_Wordpress_Image Resizing - Fatal编程技术网

PHP调整脚本大小在新服务器/域上不起作用

PHP调整脚本大小在新服务器/域上不起作用,php,wordpress,image-resizing,Php,Wordpress,Image Resizing,我让resize.php脚本在我以前的服务器/域上运行,当您转到它时,您可以看到除法为零的错误。但是如果你在新的域/服务器上使用同一个脚本,那将是一个没有错误的空白页,这让我相信有些事情并没有发生。我学得很快,但有点像个PHP高手。任何关于简单调整php图像数组大小并显示它们的建议,我都将非常感谢您的帮助 <?php session_start();header("Pragma: public");header("Cache-Control: max-age = 604800"); hea

我让resize.php脚本在我以前的服务器/域上运行,当您转到它时,您可以看到除法为零的错误。但是如果你在新的域/服务器上使用同一个脚本,那将是一个没有错误的空白页,这让我相信有些事情并没有发生。我学得很快,但有点像个PHP高手。任何关于简单调整php图像数组大小并显示它们的建议,我都将非常感谢您的帮助

<?php session_start();header("Pragma: public");header("Cache-Control: max-age = 604800");
header("Expires: ".gmdate("D, d M Y H:i:s", time() + 604800)." GMT");

function thumbnail($image, $width, $height) {

    if($image[0] != "/") { // Decide where to look for the image if a full path is not given
        if(!isset($_SERVER["HTTP_REFERER"])) { // Try to find image if accessed directly from this script in a browser
            $image = $_SERVER["DOCUMENT_ROOT"].implode("/", (explode('/', $_SERVER["PHP_SELF"], -1)))."/".$image;
        } else {
            $image = implode("/", (explode('/', $_SERVER["HTTP_REFERER"], -1)))."/".$image;
        }
    } else {
        $image = $_SERVER["DOCUMENT_ROOT"].$image;
    }
    $image_properties = getimagesize($image);
    $image_width = $image_properties[0];
    $image_height = $image_properties[1];
    $image_ratio = $image_width / $image_height;
    $type = $image_properties["mime"];

    if(!$width && !$height) {
        $width = $image_width;
        $height = $image_height;
    }
    if(!$width) {
        $width = round($height * $image_ratio);
    }
    if(!$height) {
        $height = round($width / $image_ratio);
    }

    if($type == "image/jpeg") {
        header('Content-type: image/jpeg');
        $thumb = imagecreatefromjpeg($image);
    } elseif($type == "image/png") {
        header('Content-type: image/png');
        $thumb = imagecreatefrompng($image);
    } else {
        return false;
    }

    $temp_image = imagecreatetruecolor($width, $height);
    imagecopyresampled($temp_image, $thumb, 0, 0, 0, 0, $width, $height, $image_width, $image_height);
    $thumbnail = imagecreatetruecolor($width, $height);
    imagecopyresampled($thumbnail, $temp_image, 0, 0, 0, 0, $width, $height, $width, $height);

    if($type == "image/jpeg") {
        imagejpeg($thumbnail);
    } else {
        imagepng($thumbnail);
    }

    imagedestroy($temp_image);
    imagedestroy($thumbnail);

}

if(isset($_GET["h"])) { $h = $_GET["h"]; } else { $h = 0; }
if(isset($_GET["w"])) { $w = $_GET["w"]; } else { $w = 0; }

thumbnail($_GET["img"], $w, $h);

?>


我将确保为调试打开错误,检查是否使用phpinfo()启用GD库,并确保创建拇指的目录可写。

我将确保为调试打开错误,检查是否使用phpinfo()启用GD库,并确保创建拇指的目录是可写的。

我将确保打开调试错误,检查是否使用phpinfo()启用GD库,并确保创建拇指的目录是可写的。啊!几乎所有的一切都让我无法忍受。GD图书馆?我很抱歉,哈哈,我说我是个笨蛋!我猜就是这样。我在信息日志中根本看不到gd库。我将如何安装它?了解如何安装它。请将您的评论作为答案发布,以便我批准!:)再次感谢!我会确保调试时打开了错误,检查是否使用phpinfo()启用了GD库,并确保创建拇指的目录是可写的。啊!几乎所有的一切都让我无法忍受。GD图书馆?我很抱歉,哈哈,我说我是个笨蛋!我猜就是这样。我在信息日志中根本看不到gd库。我将如何安装它?了解如何安装它。请将您的评论作为答案发布,以便我批准!:)再次感谢!已安装GD库,但仍存在一些问题。我发布了另一个问题,如果你想去那里,我希望能得到一些帮助来解决这个问题!现在我认为它应该起作用了,我得到了这个错误
警告:无法修改标题信息-标题已经由发送(输出从/home/go3de/public_html/wp content/themes/Explorable/resize.php:1开始)第35行的/home/go3de/public_html/wp content/themes/Explorable/resize.php中出现致命错误:第36行的/home/go3de/public_html/wp content/themes/Explorable/resize.php中允许的内存大小为134217728字节(试图分配32768字节)安装了GD库,但仍存在一些问题。我发布了另一个问题,如果你想去那里,我希望能得到一些帮助来解决这个问题!现在我认为它应该起作用了,我得到了这个错误
警告:无法修改标题信息-标题已经由发送(输出从/home/go3de/public_html/wp content/themes/Explorable/resize.php:1开始)第35行的/home/go3de/public_html/wp content/themes/Explorable/resize.php中出现致命错误:第36行的/home/go3de/public_html/wp content/themes/Explorable/resize.php中允许的内存大小为134217728字节(试图分配32768字节)