开发者

PHP: Get the position (x, y) of the layer of PSD file

开发者 https://www.devze.com 2023-03-22 16:10 出处:网络
I am using Imagemagick with PHP and want to get the position of the layer (x,y) but dont know how. I read the PSD file in PHP and read every 开发者_开发百科layer in it like this:

I am using Imagemagick with PHP and want to get the position of the layer (x,y) but dont know how.

I read the PSD file in PHP and read every 开发者_开发百科layer in it like this:

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


<?php

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"]."<br />\n");
    print("w,h: " . $pagedata["width"].", ".$pagedata["height"]."<br />\n");

    //export layer
    //$im->writeImage('layer_' . $i . '.png');
}

?>
0

精彩评论

暂无评论...
验证码 换一张
取 消