php - 无法使用 PHP 的 imagerotate 旋转图像

标签 php mysql image

尝试从数据库检索图像并旋转它后,我继续收到此错误:

Warning: imagecreatefromstring() [function.imagecreatefromstring]: Data is not in a recognized format

以下是我将 blob 数据转换回图像以进行旋转的调用:

$SQL="SELECT * FROM images WHERE id={$id}";
$rh = mysql_query($SQL);

$image=mysql_result($rh,0,"image");
$source_image=imagecreatefromstring($image);

$rotate_image = imagerotate($source_image, 90, 0);

我是不是漏掉了一步?

最佳答案

这就是我最终为它工作所做的事情:

$SQL="SELECT * FROM images WHERE id={$id}";
$rs = mysql_query($SQL);

//rotate image
$image=mysql_result($rs,0,"image");
$source_image=imagecreatefromstring($image);

$rotate_image = imagerotate($source_image, 270, 0);

ob_start();
imagejpeg($rotate_image, null, 100);
$image_bin = mysql_real_escape_string(ob_get_contents()); data.
ob_end_clean(); 

关于php - 无法使用 PHP 的 imagerotate 旋转图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8221967/

相关文章:

mysql - 如何在查询中将多个表连接在一起

Java 旋转图像

php - 插件在激活期间生成了 N 个字符的意外输出

php - laravel 在插入一行后无法检索 ID

php - 从不同的列值中查找最大列值

c++ - RGB 像素透明度

ios - 在 URLSession.uploadTask :with :fromFile 上设置边界

php - select count() 查询中的 limit 子句未按我的预期工作

c# - DataGridView 中的 BLOB 数据到简单字符串?

mysql - 恢复另一个版本的mysqldump文件