douhao2153 2015-02-05 13:23
浏览 324
已采纳

调整PNG大小而不会降低质量和透明度

I have to resize images, cause we upload printable high res images and for the preview people dont need a 4000px+ image. Some images using the rgb color space "eci" and others using the color space srgb. The srgb files dont have any problems, but the eci looking a bit colourless than before. And when I upload a transparent image, its not perfect transparent. Is there any solution? When I resize and its a png image, I use following extra function.

private function imagetranstowhite($trans) {
    // Create a new true color image with the same size
    $w = imagesx($trans);
    $h = imagesy($trans);
    $white = imagecreatetruecolor($w, $h);

    // Fill the new image with white background
    $bg = imagecolorallocate($white, 255, 255, 255);
    imagefill($white, 0, 0, $bg);

    // Copy original transparent image onto the new image
    imagecopy($white, $trans, 0, 0, 0, 0, $w, $h);

    return $white;
}

Does anyone have a solution? Imagemagick instead of gdlib is fine too.

  • 写回答

2条回答 默认 最新

  • dozabg1616 2019-03-10 15:54
    关注

    For people with the same problem in the future. I solved it by stopped using imagegd and switched to ImageMagick. All images are still transparent and u can easily convert cmyk images to sRGB with the correct ICC profile

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效