1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > php imagick 取得psd缩略图 php imagick 获取psd图层信息

php imagick 取得psd缩略图 php imagick 获取psd图层信息

时间:2020-07-06 07:10:03

相关推荐

php imagick 取得psd缩略图 php imagick 获取psd图层信息

php imagick 获取psd图层信息

$projectname = 'test';

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

$num_layers = $im->getNumberImages();

for ($i = 1, $num_layers = $im->getNumberImages(); $i < $num_layers; ++$i) {

$im->setImageIndex($i); //this

$im->setIteratorIndex($i); //or this is kinda redundant

$pagedata = $im->getImagePage();

$pagedata['label'] = $im->getImageProperties("*")['label'];

$allinfo[] =$pagedata;

$im->writeImage($pagedata['label'] . '.png'); //导出所有图层到单独的png文件

}

print_r($allinfo);

exit();

输出数组如下

width是图片宽度

height是图片高度

x和y都是图片相对于容器的位置

label是图层名字 一般用英文 不会乱码

Array

(

[0] => Array

(

[width] => 750

[height] => 1206

[x] => 0

[y] => 0

[label] => bg

)

[1] => Array

(

[width] => 346

[height] => 260

[x] => 292

[y] => 472

[label] => wef1

)

[2] => Array

(

[width] => 269

[height] => 221

[x] => 49

[y] => 40

[label] => wef

)

)

test.psd文件下载地址

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。