-
Notifications
You must be signed in to change notification settings - Fork 28
Switch to php ffi #133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Switch to php ffi #133
Changes from all commits
Commits
Show all changes
60 commits
Select commit
Hold shift + click to select a range
f4ad0fc
start an ffi experiment
jcupitt f38fb69
fix syntax errors
jcupitt 2dccec1
do the rest of introspection
jcupitt 7284eee
oop typo
jcupitt 4ae4cb5
add the rest of call operation
jcupitt d6a9f65
start movinf ffi into php-vips
jcupitt 3fecf05
start pasting in startup code
jcupitt 5503608
more pasting in
jcupitt 2ebad55
more hacking
jcupitt a2e3698
update README
jcupitt 6f4a0bd
new_from_file etc.
jcupitt e495a75
more fixes
jcupitt fea3f81
try to get it to init again
jcupitt 3951af8
make init into a singleton class
jcupitt 096cc4e
move the singleton to a static member
jcupitt d06e82f
fixed up init
jcupitt 0990d62
hack hack hack
jcupitt 151b3f2
introspect working
jcupitt 36710a2
almost there
jcupitt f220389
working ... gvalue missing cases next
jcupitt a460710
start fleshing out get/set
jcupitt bf56100
small bugfixes
jcupitt f8be77f
now executes a test program!
jcupitt da5cb08
runs the watermark-image example successfully
jcupitt 8c18365
fix optional args on newFromFile
jcupitt 3f6516d
add the rest of GValue get()
jcupitt a0df283
can't get callStatic working from methods
jcupitt 4b3e2b6
watermark-test works!
jcupitt 389c7d4
start fixing tests
jcupitt b4b9d6b
Allowed for psr/log 2.0 and 3.0 to be installed as well
boris-glumpler 0fbb9e7
start adding constant imagazation
jcupitt 82f3b65
down to 13 failures
jcupitt 70538f0
9 errors left
jcupitt 5c21316
nail a coupl;e more small errors
jcupitt 548e1e4
down to 3 test suite fails
jcupitt fefe62f
down to two fails
jcupitt 7bd9c99
two errors left
jcupitt be90a10
all tests pass
jcupitt 401c80e
fix phpcs warnings
jcupitt 6869216
start soak testing
jcupitt 7073b6e
fix a segv
jcupitt 692dbc5
revise string handling
jcupitt 05327a9
revise startup
jcupitt 8537cba
more init into config
jcupitt 44ad854
start fixing up tests again
jcupitt 9c0bcce
all tests pass cleanly
jcupitt 01e4e9f
use new_from_memory_copy for now
jcupitt 249d7fa
revise docs
jcupitt ed25bc9
final checks
jcupitt 162d0ce
Merge branch 'master' into switch-to-php-ffi
jcupitt 998ca6d
add findLoad and findLoadBuffer
jcupitt 156a772
add writeToArray()
jcupitt ff75115
Update src/Config.php
jcupitt 2b0cfc8
incorporate review comments
jcupitt 4640d83
Merge branch 'switch-to-php-ffi' of github.com:libvips/php-vips into …
jcupitt 47d9fbb
fix testVipsWriteToBuffer with options
jcupitt 387f4c1
try to improve shared library finding
jcupitt 009411d
make debugLog less chatty
jcupitt 8b30c9f
revise library name generation again
jcupitt c202836
add __clone()
jcupitt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"require": { | ||
"jcupitt/vips": "2.0.0" | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/usr/bin/env php | ||
<?php | ||
|
||
require __DIR__ . '/vendor/autoload.php'; | ||
use Jcupitt\Vips; | ||
|
||
Vips\Config::setLogger(new Vips\DebugLogger()); | ||
|
||
if (count($argv) != 4) { | ||
echo("usage: ./watermark.php input-image output-image watermark-image\n"); | ||
exit(1); | ||
} | ||
|
||
// we can stream the main image | ||
$image = Vips\Image::newFromFile($argv[1], ['access' => 'sequential']); | ||
|
||
// we'll read the watermark image many times, so we need random access for this | ||
$watermark = Vips\Image::newFromFile($argv[3]); | ||
|
||
// the watermark image needs to have an alpha channel | ||
if (!$watermark->hasAlpha() || $watermark->bands != 4) { | ||
echo("watermark image is not RGBA\n"); | ||
exit(1); | ||
} | ||
|
||
// make the watermark semi-transparent | ||
$watermark = $watermark->multiply([1, 1, 1, 0.3])->cast("uchar"); | ||
|
||
// repeat the watermark to the size of the image | ||
$watermark = $watermark->replicate( | ||
1 + $image->width / $watermark->width, | ||
1 + $image->height / $watermark->height | ||
); | ||
$watermark = $watermark->crop(0, 0, $image->width, $image->height); | ||
|
||
// composite the watermark over the main image | ||
$image = $image->composite2($watermark, 'over'); | ||
|
||
$image->writeToFile($argv[2]); | ||
|
||
$image = null; | ||
$watermark = null; | ||
|
||
Vips\Config::shutDown(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?php | ||
|
||
/** | ||
* PHP version 7 | ||
* | ||
* LICENSE: | ||
* | ||
* Copyright (c) 2016 John Cupitt | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining | ||
* a copy of this software and associated documentation files (the | ||
* "Software"), to deal in the Software without restriction, including | ||
* without limitation the rights to use, copy, modify, merge, publish, | ||
* distribute, sublicense, and/or sell copies of the Software, and to | ||
* permit persons to whom the Software is furnished to do so, subject to | ||
* the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be | ||
* included in all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
* | ||
* @category Images | ||
* @package Jcupitt\Vips | ||
* @author John Cupitt <jcupitt@gmail.com> | ||
* @copyright 2016 John Cupitt | ||
* @license https://opensource.org/licenses/MIT MIT | ||
* @link https://github.com/jcupitt/php-vips | ||
*/ | ||
|
||
namespace Jcupitt\Vips; | ||
|
||
/** | ||
* The ArgumentFlags enum. | ||
* @category Images | ||
* @package Jcupitt\Vips | ||
* @author John Cupitt <jcupitt@gmail.com> | ||
* @copyright 2016 John Cupitt | ||
* @license https://opensource.org/licenses/MIT MIT | ||
* @link https://github.com/jcupitt/php-vips | ||
*/ | ||
abstract class ArgumentFlags | ||
{ | ||
const REQUIRED = 1; | ||
const CONSTRUCT = 2; | ||
const SET_ONCE = 4; | ||
const SET_ALWAYS = 8; | ||
const INPUT = 16; | ||
const OUTPUT = 32; | ||
const DEPRECATED = 64; | ||
const MODIFY = 128; | ||
|
||
const NAMES = [ | ||
"REQUIRED" => self::REQUIRED, | ||
"CONSTRUCT" => self::CONSTRUCT, | ||
"SET_ONCE" => self::SET_ONCE, | ||
"SET_ALWAYS" => self::SET_ALWAYS, | ||
"INPUT" => self::INPUT, | ||
"OUTPUT" => self::OUTPUT, | ||
"DEPRECATED" => self::DEPRECATED, | ||
"MODIFY" => self::MODIFY, | ||
]; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.