-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathmeta.php
82 lines (64 loc) · 1.99 KB
/
meta.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
<?php
use Jcupitt\Vips;
class VipsMetaTest extends PHPUnit_Framework_TestCase
{
protected function setUp()
{
$filename = dirname(__FILE__) . "/images/img_0076.jpg";
$this->image = Vips\Image::newFromFile($filename);
$png_filename = dirname(__FILE__) . "/images/PNG_transparency_demonstration_1.png";
$this->png_image = Vips\Image::newFromFile($png_filename);
}
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
*/