Skip to content

Commit a6bd232

Browse files
committed
Change array to binary string
1 parent 5de1a40 commit a6bd232

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

src/Image.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -933,7 +933,7 @@ public static function newFromArray(
933933
/**
934934
* Wraps an Image around an area of memory containing a C-style array.
935935
*
936-
* @param array $data C-style array.
936+
* @param string $data C-style array.
937937
* @param int $width Image width in pixels.
938938
* @param int $height Image height in pixels.
939939
* @param int $bands Number of bands.
@@ -942,7 +942,7 @@ public static function newFromArray(
942942
* @return Image A new Image.
943943
*/
944944
public static function newFromMemory(
945-
array $data,
945+
string $data,
946946
int $width,
947947
int $height,
948948
int $bands,
@@ -1085,9 +1085,9 @@ public function writeToBuffer(string $suffix, array $options = []): string
10851085
/**
10861086
* Write an image to a large memory array.
10871087
*
1088-
* @return array The memory array.
1088+
* @return string The memory array.
10891089
*/
1090-
public function writeToMemory(): array
1090+
public function writeToMemory(): string
10911091
{
10921092
Utils::debugLog('writeToMemory', [
10931093
'instance' => $this,

tests/NewTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,8 @@ public function testVipsNewInterpolator()
110110

111111
public function testVipsNewFromMemory()
112112
{
113-
$byte_array = array_fill(0, 200, 0);
114-
$image = Vips\Image::newFromMemory($byte_array, 20, 10, 1, Vips\BandFormat::UCHAR);
113+
$binaryStr = pack('C*', ...array_fill(0, 200, 0));
114+
$image = Vips\Image::newFromMemory($binaryStr, 20, 10, 1, Vips\BandFormat::UCHAR);
115115

116116
$this->assertEquals($image->width, 20);
117117
$this->assertEquals($image->height, 10);

tests/WriteTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@ public function testVipsWriteToBuffer()
6262

6363
public function testVipsWriteToMemory()
6464
{
65-
$byte_array = array_fill(0, 200, 0);
66-
$image = Vips\Image::newFromMemory($byte_array, 20, 10, 1, Vips\BandFormat::UCHAR);
67-
$mem_arr = $image->writeToMemory();
65+
$binaryStr = pack('C*', ...array_fill(0, 200, 0));
66+
$image = Vips\Image::newFromMemory($binaryStr, 20, 10, 1, Vips\BandFormat::UCHAR);
67+
$memStr = $image->writeToMemory();
6868

69-
$this->assertEquals($byte_array, $mem_arr);
69+
$this->assertEquals($binaryStr, $memStr);
7070
}
7171
}
7272

0 commit comments

Comments
 (0)