php生成图像的时间太长

php生成图像的时间太长,php,Php,我有这个密码 $filename = 'http://4.bp.blogspot.com/-Da3HqoaO2yU/T62i43Bgm5I/AAAAAAAARzI/B4Ggaq_cUJc/s400/dotsgreendistressedBackgroundFairy2.jpg'; // Get new dimensions list($width, $height) = getimagesize($filename); $new_widt

我有这个密码

$filename = 'http://4.bp.blogspot.com/-Da3HqoaO2yU/T62i43Bgm5I/AAAAAAAARzI/B4Ggaq_cUJc/s400/dotsgreendistressedBackgroundFairy2.jpg';   


        // Get new dimensions
        list($width, $height) = getimagesize($filename);
        $new_width = $width * $percent;
        $new_height = $height * $percent;

        // Resample
        $image_p = imagecreatetruecolor(400, 200);
        $image = imagecreatefromjpeg($filename);
        imagecopyresampled($image_p, $image, 0, 0, 0, 0, 400, 200, $width, $height);


        // texts
        $width = 400;
        $height = 150;
        $im = imagecreatefromjpeg($filename);
        $x = imagesx($image_p) - $width ;
        $y = imagesy($image_p) - $height;
        $backgroundColor = imagecolorallocate ($image_p, 255, 255, 255);
        $textColor = imagecolorallocate ($image_p, 0, 0,0);

        imagestring ($image_p, 45, 30, 10, 'a ', $textColor);
        imagestring ($image_p, 45, 30, 30, 'b ', $textColor);
        imagestring ($image_p, 45, 30, 50, 'c', $textColor);
        imagestring ($image_p, 45, 30, 70, 'd', $textColor);
        imagestring ($image_p, 45, 30, 90, 'e', $textColor);
        imagestring ($image_p, 45, 30, 110, 'f', $textColor);


        // Output
        imagejpeg($image_p, null, 100);
        header('Content-type: image/jpeg');

这是一个非常简单的图像,但生成大约需要5秒钟,哪里会有问题?

使用php生成图像不是一个快速的过程。您应该缓存该图像,以便只需生成一次。预先存在的图像将加载得更快。如果可能,在不需要用户等待的时候生成图像

事实上,您正在下载图像来制作和生成它,这不是一个快速的过程。缓存我朋友下载的图像。