plist 图集 php 批量提取

源码如下:

 1 <?php
 2//author: nejidev
 3//date: 2019-10-05 21:29 4$src_png = imagecreatefrompng('');
 5 6$width   = 100;
 7$height  = 134;
 8$top     = 0;
 9$left    = 0;
1011for($i=0; $i<5; $i++)
12{
13$left = 0;
14for($j=0; $j<13; $j++)
15    {
16$new_png = imagecreate($width, $height);
17         imagecopy($new_png, $src_png, 0, 0, $left, $top, $width, $height);
18         imagepng($new_png, "$i-$j.png");
19         imagedestroy($new_png);
20$left += $width;
21    }
22$top += $height;
23//top 微调24if(0 == $i) $top += -1;
25if(1 == $i) $top += -1;
26if(2 == $i) $top += 0;
27if(3 == $i) $top += -1;
28}
29 imagedestroy($src_png);

PHP 果然没让失望,几下代码就搞定了,其实核心只有一行 imagecopy() ,要是 java 估计多几倍,python 以前也用过,需要装第三方库。

猜你喜欢

转载自www.cnblogs.com/linchun777/p/11626962.html