8000 Merge branch 'master' into add-array-access · libvips/php-vips@4cf0578 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4cf0578

Browse files
committed
Merge branch 'master' into add-array-access
2 parents 909a632 + 0eed148 commit 4cf0578

File tree

4 files changed

+91
-4
lines changed

4 files changed

+91
-4
lines changed

CHANGELOG.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,25 @@
11
# Changelog
22
All notable changes to `:vips` will be documented in this file.
33

4-
## 1.0.2 - 2017-06-06
4+
## 1.0.3-dev - 2017-06-06
55

66
### Added
7+
- add Image::newInterpolator() [Kleis Auke Wolthuizen]
78
- implement array access interface [John Cupitt]
89

9-
## 1.0.1 - 2017-04-29
10+
### Deprecated
11+
- Nothing
12+
13+
### Fixed
14+
- Nothing
15+
16+
### Remove
17+
- Nothing
18+
19+
### Security
20+
- Nothing
21+
22+
## 1.0.2 - 2017-04-29
1023

1124
### Added
1225
- fix minor formatting issues reported by phpcs [John Cupitt]

src/Image.php

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,45 @@
411411
* If you want to avoid the copies, you'll need to call drawing operations
412412
* yourself.
413413
*
414+
* # Thumbnailing
415+
*
416+
* The thumbnailing functionality is implemented by `Vips\Image::thumbnail` and
417+
* `Vips\Image::thumbnail_buffer` (which thumbnails an image held as a string).
418+
*
419+
* You could write:
420+
*
421+
* ```php
422+
* $filename = 'image.jpg';
423+
* $image = Vips\Image::thumbnail($filename, 200, ['height' => 200]);
424+
* $image->writeToFile('my-thumbnail.jpg');
425+
* ```
426+
*
427+
* # Resample
428+
*
429+
* There are three types of operation in this section.
430+
*
431+
* First, `->affine()` applies an affine transform to an image.
432+
* This is any sort of 2D transform which preserves straight lines;
433+
* so any combination of stretch, sheer, rotate and translate.
434+
* You supply an interpolator for it to use to generate pixels
435+
* (@see Image::newInterpolator()). It will not produce good results for
436+
* very large shrinks: you'll see aliasing.
437+
*
438+
* `->reduce()` is like `->affine()`, but it can only shrink images,
439+
* it can't enlarge, rotate, or skew.
440+
* It's very fast and uses an adaptive kernel (@see Kernel for possible values)
441+
* for interpolation. It will be slow for very large shrink factors.
442+
*
443+
* `->shrink()` is a fast block shrinker. It can quickly reduce images by large
444+
* integer factors. It will give poor results for small size reductions:
445+
* again, you'll see aliasing.
446+
*
447+
* Next, `->resize()` specialises in the common task of image reduce and enlarge.
448+
* It strings together combinations of `->shrink()`, `->reduce()`, `->affine()`
449+
* and others to implement a general, high-quality image resizer.
450+
*
451+
* Finally, `->mapim()` can apply arbitrary 2D image transforms to an image.
452+
*
414453
* # Expansions
415454
*
416455
* Some vips operators take an enum to select an action, for example
@@ -742,7 +781,7 @@ public static function newFromFile(
742781
}
743782

744783
/**
745-
* Find the name of the load oepration vips will use to load a file, for
784+
* Find the name of the load operation vips will use to load a file, for
746785
* example "VipsForeignLoadJpegFile". You can use this to work out what
747786
* options to pass to newFromFile().
748787
*
@@ -794,7 +833,7 @@ public static function newFromBuffer(
794833
}
795834

796835
/**
797-
* Find the name of the load oepration vips will use to load a buffer, for
836+
* Find the name of the load operation vips will use to load a buffer, for
798837
* example 'VipsForeignLoadJpegBuffer'. You can use this to work out what
799838
* options to pass to newFromBuffer().
800839
*
@@ -850,6 +889,26 @@ public static function newFromArray(
850889
return self::wrapResult($result);
851890
}
852891

892+
/**
893+
* Make an interpolator from a name.
894+
*
895+
* @param string $name Name of the interpolator.
896+
* Possible interpolators are:
897+
* - `'nearest'`: Use nearest neighbour interpolation.
898+
* - `'bicubic'`: Use bicubic interpolation.
899+
* - `'bilinear'`: Use bilinear interpolation (the default).
900+
* - `'nohalo'`: Use Nohalo interpolation.
901+
* - `'lbb'`: Use LBB interpolation.
902+
* - `'vsqbs'`: Use the VSQBS interpolation.
903+
*
904+
* @return resource|null The interpolator, or null on error.
905+
*/
906+
public static function newInterpolator(string $name)
907+
{
908+
// added in 1.0.7 of the binary module
909+
return vips_interpolate_new($name);
910+
}
911+
853912
/**
854913
* Create a new image from a constant.
855914
*

src/Size.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,5 @@ abstract class Size
5252
const BOTH = 'both';
5353
const UP = 'up';
5454
const DOWN = 'down';
55+
const FORCE = 'force';
5556
}

tests/new.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,20 @@ public function testVipsCopyMemory()
9191
$this->assertEquals($image1->avg(), $image2->avg());
9292
}
9393

94+
public function testVipsNewInterpolator()
95+
{
96+
$filename = dirname(__FILE__) . '/images/img_0076.jpg';
97+
$image1 = Vips\Image::newFromFile($filename);
98+
$interp = Vips\Image::newInterpolator('bicubic');
99+
$image2 = $image1->affine([2, 0, 0, 2], ['interpolate' => $interp]);
100+
101+
$widthInput = $image1->width;
102+
$widthOutput = $image2->width;
103+
104+
$this->assertNotNull($interp);
105+
$this->assertEquals($widthInput * 2, $widthOutput);
106+
}
107+
94108
}
95109

96110
/*

0 commit comments

Comments
 (0)
0