duanmeng3476 2013-07-13 11:55
浏览 260
已采纳

PHP imagejpeg不起作用

Using this logic to resize and print an image:

$image_path="path/to/image.extension";  
$image_path=imagecreatefromjpeg($image_path);  

$width=imagesx($image_path);  
$height=imagesy($image_path);  
$new_image=imagecreatetruecolor($w, $h);  
imagecopyresampled($new_image,$image_path,0,0,0,0,$w,$h,$width,$height);  
header('Content-Type: image/jpeg');  
imagejpeg($new_image,100);
imagedestroy($new_image);

But I am getting image missing icon as output. What is the mistake I do? I have tried printing the variables $width and $height and it prints the dimension of source image. So the path is correct.

What could be the error?

  • 写回答

1条回答 默认 最新

  • duangao7133 2013-07-14 15:51
    关注

    The mistake was in the line imagejpeg($new_image,100);

    It must be imagejpeg($new_image); Quality must not be included in that, if not intended to save.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 51单片机中C语言怎么做到下面类似的功能的函数(相关搜索:c语言)
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序
  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题