getNumberImages()”;接着获取所有参数;最后导出图层到单独的png文件即可。"/> getNumberImages()”;接着获取所有参数;最后导出图层到单独的png文件即可。">

PHP中怎么使用Imagick操作PSD文件

PHPz
Release: 2020-09-05 13:42:36
Original
1602 people have browsed it

PHP中怎么使用Imagick操作PSD文件

PHP中怎么使用Imagick操作PSD文件?

PHP中使用Imagick操作PSD文件实例

参考资料:

http://www.php.net/manual/zh/book.imagick.php
Copy after login

前提

代码如下:

$im = new Imagick("test.psd");
Copy after login

获取图层数目

代码如下:

$num_layers = $im->getNumberImages();
Copy after login

获取所有参数:

代码如下:

for ($i = 0, $num_layers = $im->getNumberImages(); $i < $num_layers; ++$i) {
$im->setImageIndex($i); //this
$im->setIteratorIndex($i); //or this is kinda redundant
$pagedata=$im->getImagePage();
//print("x,y: " + $pagedata["x"].", ".$pagedata["y"]."
\n");
//print("w,h: " + $pagedata["width"].", ".$pagedata["height"]."
\n");
foreach($im->getImageProperties("*") as $k => $v) print("$k: $v
\n");
//export layer
//$im->writeImage('layer_' . $i . '.png'); //导出所有图层到单独的png文件
}
Copy after login

更多相关知识,请访问PHP中文网

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!