【问题标题】:PHP GD - imagerotate for a jpeg image is not workingPHP GD - jpeg 图像的 imagerotate 不起作用
【发布时间】:2012-08-15 18:04:00
【问题描述】:

标题说 JPEG。但我尝试了PNG。它没有用。 GD支持imagerotate功能。

 if (function_exists('imagerotate')) { 
     echo "test";
 }

它输出单词test。所以我假设我有 imagerotate 功能。

$im = imagecreatetruecolor($width + 10, $height + 10);
...

我做了一些图像处理。我可以毫无问题地看到处理后的图像。但我想旋转最终图像。所以我做了以下事情。

 imagerotate($im,180,0);
 imagepng($im,$png,9);
 imagedestroy($im);

但我仍然得到没有旋转的图像。 我什至只是尝试在不做任何处理的情况下旋转图像。也没有用。

【问题讨论】:

  • $png 有一些名字。我正在尝试使用以下名称 Output.png
  • 您 100% 确定正在写入文件?您比较了文件的“最后修改”时间,并且它存储的是未旋转的图像?
  • 是的。我检查了不同的名字。

标签: php image-rotation php-gd


【解决方案1】:

在创建 png 之前,您需要将旋转后的图像分配给另一个变量。

$rotatedImage = imagerotate($im,180,0);
 imagepng($rotatedImage,$png,9);
 imagedestroy($rotatedImage);

【讨论】:

    猜你喜欢
    • 2014-11-10
    • 2013-04-04
    • 1970-01-01
    • 1970-01-01
    • 2014-06-12
    • 2017-02-06
    • 1970-01-01
    • 2014-08-03
    • 2010-12-01
    相关资源
    最近更新 更多