doudi2833 2012-02-15 15:15
浏览 11
已采纳

裁剪图像,保存[关闭]

    $filename = '/home/hey/Desktop/images/oldImage.jpg';
    $percent = 0.5;

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

    // Resample
    $image_p = imagecreatetruecolor($new_width, $new_height);
    $image = imagecreatefromjpeg($filename);
    imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
    file_put_contents("/home/hey/Desktop/images/oldImage.jpg", imagejpeg($image_p));

I just want to crop oldImage a little bit and save it again. What's wrong? Thanks.

edit: Image is just not created. It creates empty image.

  • 写回答

1条回答 默认 最新

  • dongshang6790 2012-02-15 15:21
    关注

    Why not use the simpler:

    // Save the image as 'simpletext.jpg'
    imagejpeg($image_p, 'simpletext.jpg');
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度