dongshi3061 2019-08-07 21:58
浏览 126

使用imagecreatetruecolor和imagecreatefromjpeg不是真正的颜色

Hy there,

I use this code to resize my images to improve size...

<?php
    // File
    $filename = 'ok.jpg';
    list($width, $height) = getimagesize($filename);
    $ratio = ($width >= $height) ? 683 : 1152;
    $percent = $ratio / $height;

    // New sizes
    $new_width = $width * $percent;
    $new_height = $height * $percent;

    // Apply new sizes
    $image_p = imagecreatetruecolor($new_width, $new_height);
    $image = imagecreatefromjpeg($filename);
    imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);

    // Save
    imagejpeg($image_p, 'tes.jpg', 80);
    imagedestroy($image);
    imagedestroy($image_p);

But I saw a problem with the colors quality... image looks more grey than original.

Original picture : original

And after resizing : original

What can I do to keep same colors ? Thanks

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
    • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
    • ¥20 有关区间dp的问题求解
    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置
    • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
    • ¥15 ubuntu子系统密码忘记
    • ¥15 保护模式-系统加载-段寄存器
    • ¥15 电脑桌面设定一个区域禁止鼠标操作
    • ¥15 求NPF226060磁芯的详细资料