简体   繁体   English

imagerotate()不起作用

[英]imagerotate() doesn't work

i have a problem with the imagerotate() PHP function. 我对imagerotate()PHP函数有问题。 I run the script below, and it successfully creates the new image with imagejpeg(), but the new image is the same as the original, so it doesn't rotate it. 我在下面运行脚本,它使用imagejpeg()成功创建了新图像,但是新图像与原始图像相同,因此不会旋转它。 It shows no error message in the Apache error.log, so i have no idea. 它在Apache error.log中没有显示错误消息,所以我不知道。

$file contains a filename in this form: IMG_8841.JPG $ file包含以下格式的文件名:IMG_8841.JPG

I hope you can help me, thanks. 希望您能帮助我,谢谢。

$filename='./original/'.$file;
$new='./rotated/'.$file;
$original_photo = imagecreatefromjpeg($filename);
imagerotate ($original_photo , 90 , 0 );
imagejpeg($original_photo, $new);
imagedestroy($original_photo);

Try 尝试

$original_photo = imagerotate($original_photo, 90, 0);

Else your object is not modified. 否则您的对象不会被修改。

Or event better: 还是更好的事件:

$new_photo = imagerotate ($original_photo , 90 , 0 );
imagejpeg($new_photo, $new); 
imagedestroy($original_photo);
imagedestroy($new_photo);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM