【问题标题】:get the first pixel from the image using php使用 php 从图像中获取第一个像素
【发布时间】:2012-12-20 03:12:16
【问题描述】:

我正在尝试获取图像的第一个像素。最好是左上角或右上角的一个像素。 我看到了这个问题,它的答案与我的问题最接近:Get image color

但是,答案仅向您展示如何获得平均颜色。我不想获得平均颜色,我想从任何一侧获得第一个像素!有人知道怎么做吗?

【问题讨论】:

标签: php


【解决方案1】:

试试这个,它得到左上角像素(0,0)的颜色:

<?php
    $im = imagecreatefrompng("image.png");
    $rgb = imagecolorat($im, 0, 0);

    $colors = imagecolorsforindex($im, $rgb);

    var_dump($colors);
?>

更多信息:http://php.net/manual/en/function.imagecolorat.php

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-01-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-23
    • 2016-03-24
    相关资源
    最近更新 更多