gpt4 book ai didi

php - ImageMagick PHP 需要高质量的缩略图生成

转载 作者:行者123 更新时间:2023-12-04 06:25:01 25 4
gpt4 key购买 nike

我正在使用 php imagemagick 生成缩略图。

  • 如果我给 bestfit true 并且大小为 50x50,它会生成 36x50 大小的图像(质量好)
  • 如果我给出 bestfit false 并且大小为 50x50,它会生成 50x50 大小的图像(质量差)

  • 我需要一个解决方案,无论我给的图像大小(最小我将上传 200X200)
    它需要在 ImageMAgick 中提供具有良好质量和技术的 50x50 图像?

    最佳答案

    看看PHP Thumb (麻省理工学院许可证)。

    支持自适应调整大小 .

    它所做的是调整图像的大小以尽可能接近所需的尺寸,然后将图像从中心裁剪到合适的尺寸。

    require_once '/path/to/ThumbLib.inc.php';  

    $thumb = PhpThumbFactory::create('test.jpg');
    $thumb->adaptiveResize(50, 50)->save('/path/to/new_thumb.jpg');

    PHP Thumb is a light-weight image manipulation library aimed at thumbnail generation. It features the ability to resize by width, height, and percentage, create custom crops, or square crops from the center, and rotate the image.



    PHP Thumb Github WIKI

    关于php - ImageMagick PHP 需要高质量的缩略图生成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6148126/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com