拿到一张图片,就是想把它大卸八块,一个像素一个像素给分离开,看看图片到底包含了哪些颜色值。这个php类从牛哥眼前飘过!


<?php
/**
*
*
*/
header("Content-type: text/html; charset=utf-8");
include "pixpic.class.php";
$px = new Pixpic();
$img = "./niuge_weixi.png";
//你需要设置一个图片路径
$px->setImage($img);
//你需要初始化需要展示的像素大小
$pro = $px->getProperty();
if (!$px->error()) {
$palete = $px->image2palete();
echo "<p>Attributes Image:</p>";
echo "<p>Width:" . $pro[0] . "</p><p><span>立即学习</span>“<a href="https://pan.quark.cn/s/7fc7563c4182" style="text-decoration: underline !important; color: blue; font-weight: bolder;" rel="nofollow" target="_blank">PHP免费学习笔记(深入)</a>”;</p>
<div class="aritcle_card">
<a class="aritcle_card_img" href="/ai/778">
<img src="https://img.php.cn/upload/ai_manual/001/503/042/68b6da1a6d59a334.png" alt="Bardeen AI">
</a>
<div class="aritcle_card_info">
<a href="/ai/778">Bardeen AI</a>
<p>使用AI自动执行人工任务</p>
<div class="">
<img src="/static/images/card_xiazai.png" alt="Bardeen AI">
<span>165</span>
</div>
</div>
<a href="/ai/778" class="aritcle_card_btn">
<span>查看详情</span>
<img src="/static/images/cardxiayige-3.png" alt="Bardeen AI">
</a>
</div>
";
echo "<p>Height:" . $pro[1] . "</p>";
echo "<p>Bits:" . $pro["bits"] . "</p>";
echo "<p>Type:" . $pro["mime"] . "</p>";
echo "<h1>图片中包含的像素</h1>";
foreach ($palete as $color)
echo "<div style='background-color:#" . $color . ";width:20px;height:20px;float:left;margin-left:3px;margin-bottom:3px;border:1px solid'></div>";
} else {
echo $px->error();
}
<?php
/**
*
*
*/
include "pixpic.class.php";
$px=new Pixpic();
$img="./niuge_weixi.png";
//你需要设置一个图片路径
$px->setImage($img);
//你需要初始化需要展示的像素大小
$px->zoom=3;
$px->span=2;
if(!$px->error()){
echo $px->image2div();
}else{
echo $px->error();
}
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号