php 将字节数组转换为图像

php convert byte array to image

我有一个数组,下面是它的一部分(超过 3000 项),我需要将字节数据转换为图像 (jpg) 有什么办法吗?

谢谢。

[0] => 255
    [1] => 216
    [2] => 255
    [3] => 224
    [4] => 0
    [5] => 16
    [6] => 74
    [7] => 70
    [8] => 73
    [9] => 70
    [10] => 0
    [11] => 1
    [12] => 1
    [13] => 1
    [14] => 0
    [15] => 96
    [16] => 0
    [17] => 96
    [18] => 0
    [19] => 0
    [20] => 255

这应该有效

$fp = fopen("image.jpg", "wb");

$len = count($array);

for ($i = 0; $i < $len; $i++) {
    $data = pack("C*",$array[$i]);
    fwrite($fp, $data);
}
fclose($fp);

采纳自here