【问题标题】:PNG to DDS with Imagick missing Set Arguments带有 Imagick 的 PNG 到 DDS 缺少设置参数
【发布时间】:2020-09-19 13:53:05
【问题描述】:

我想像这个例子一样使用 PHP 代码

<?
$img = new Imagick('test.png'); //Load the uploaded image
$img->setformat('dds'); //Set the format to dds
$img->setImageCompression(Imagick::COMPRESSION_DXT5); //Set compression method
$img->writeimage('test.dds'); //Write/save the dds texture
?>

但我找不到 Cluster-fit true|false 和 Mipmaps = X 的缺失集参数 所以我坚持使用 php exec,这迫使我首先保存 png,以便 exec() 可以访问它以将其转换为 dds。

exec("convert -format dds -define dds:compression=dxt5 -define dds:mipmaps=6 -define dds:cluster-fit=true ".$ziptempDir.$fileName." ".$ziptempDir.$fileNameDDS."");

我在 php.net 上找不到参数,所以它们不适用于 php imagick,如果是这样,有人知道如何获取/翻译它们以像第一个示例中那样使用它吗?

谢谢

【问题讨论】:

  • 试试$imagick-&gt;setOption("dds:mipmaps", 6);
  • 哇,它有效......我之前尝试过,但我敢打赌我有一个错字。非常感谢!
  • 酷!由于您有工作且经过测试的代码,因此您可以编写代码供其他人查看并通过接受您自己的答案来获取分数。

标签: php imagemagick imagick mipmaps


【解决方案1】:

这里是 mipmaps x 和 cluster-fit true|false 的 setOptions 的工作代码,php.net 上没有描述

    $imgSkinFull->setImageCompression(Imagick::COMPRESSION_DXT5);
    $imgSkinFull->setOption("dds:mipmaps", 6);
    $imgSkinFull->setOption("dds:cluster-fit", true);
    $imgSkinFull->setformat('dds');
    $imgSkinFull->writeimage($ziptempDir.$fileNameDDS);
    $imgSkinFull->destroy();

【讨论】:

  • 酷,感谢您与 SO 社区的分享。
猜你喜欢
  • 2013-05-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-07-09
  • 2012-12-11
  • 1970-01-01
相关资源
最近更新 更多