-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathMetaTest.php
100 lines (79 loc) · 2.25 KB
/
MetaTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<?php
namespace Jcupitt\Vips\Test;
use Jcupitt\Vips;
use PHPUnit\Framework\TestCase;
class MetaTest extends TestCase
{
/**
* @var Vips\Image
*/
private $image;
/**
* @var Vips\Image
*/
private $png_image;
protected function setUp(): void
{
$filename = __DIR__ . '/images/img_0076.jpg';
$this->image = Vips\Image::newFromFile($filename);
$png_filename = __DIR__ . '/images/PNG_transparency_demonstration_1.png';
$this->png_image = Vips\Image::newFromFile($png_filename);
}
protected function tearDown(): void
{
unset($this->image);
unset($this->png_image);
}
public function testVipsSetGet()
{
$this->image->poop = 'banana';
$value = $this->image->poop;
$this->assertEquals($value, 'banana');
}
public function testVipsGetExifData()
{
$name = 'exif-data';
$exif = $this->image->$name;
# 9724 bytes of exif attached ... this should work even without libexif
$this->assertEquals(strlen($exif), 9724);
}
public function testVipsGetThumbnail()
{
$thumbnail_data = $this->image->get('jpeg-thumbnail-data');
$thumb = Vips\Image::newFromBuffer($thumbnail_data);
$this->assertEquals($thumb->width, 160);
}
public function testVipsGetTypeof()
{
$gint = $this->image->typeof('width');
// should always be the same, I think
$this->assertEquals($gint, 24);
}
public function testVipsRemove()
{
$image = $this->image->copy();
$exif = $image->get('exif-data');
$this->assertEquals(strlen($exif), 9724);
$image->remove('exif-data');
$this->expectException(Vips\Exception::class);
$exif = $image->get('exif-data');
}
public function testVipsEnumString()
{
$x = $this->image->interpretation;
$this->assertEquals($x, 'srgb');
}
public function testVipsHasAlpha()
{
$this->assertEquals($this->image->hasAlpha(), false);
$this->assertEquals($this->png_image->hasAlpha(), true);
}
}
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: expandtab sw=4 ts=4 fdm=marker
* vim<600: expandtab sw=4 ts=4
*/