zoukankan      html  css  js  c++  java
  • php imagick 获取psd图层信息

    php imagick 获取psd图层信息
    <pre>
    <?php
    $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();
    </pre>


    输出数组如下
    width是图片宽度
    height是图片高度
    x和y都是图片相对于容器的位置
    label是图层名字 一般用英文 不会乱码
    <pre>
    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
    )

    )
    </pre>

    <a href="http://newmiracle.cn/test.psd">test.psd文件下载地址</a>

  • 相关阅读:
    登陆界面
    信号和槽
    线程同步
    java script简介
    css粘性定位sticky的使用
    vue中使用qrcodejs2生成二维码
    webpack基本使用
    总结一些h5出现的问题及解决方案
    srcset属性配合w宽度描述符配合sizes属性
    vw实现页面布局
  • 原文地址:https://www.cnblogs.com/newmiracle/p/11871353.html
Copyright © 2011-2022 走看看