-
Notifications
You must be signed in to change notification settings - Fork 26
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
Switch to php ffi #133
Conversation
call an operation next
next, need to have classes wrapping gobject, vipsobject, vipsoperation and vipsimage
get the ffi handle from a static method
operation call next
just getting a null for result for some reason
or mostly working anyway
writeToFile next
add some tests, finish other methods in image
watermark-text next
next: revise code, add new stuff to test suite
Thanks very much!
I've added |
Ok, basics work now, I can render an image with our "pipeline" But still some issues when I run our testsuite
from eg. https://github.com/libvips/php-vips/blob/switch-to-php-ffi/src/Image.php#L1108 and when I run those tests I have some
reporting (need to check what those tests exactly do, but those logs weren't there before) |
Oop, you're right, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left a few installation comments inline. The whole test suite on the (now elderly) 3.x
branch of the weserv/images project almost passes with this PR. A few unit tests gave these errors:
Jcupitt\Vips\Exception: 1 arguments required, but 4 supplied
I was able to reproduce that on the php-vips test suite by modifying the testVipsWriteToBuffer()
test.
--- a/tests/WriteTest.php
+++ b/tests/WriteTest.php
@@ -52,7 +52,7 @@ class WriteTest extends TestCase
$filename = __DIR__ . '/images/img_0076.jpg';
$image = Vips\Image::newFromFile($filename, ['shrink' => 8]);
- $buffer1 = $image->writeToBuffer('.jpg');
+ $buffer1 = $image->writeToBuffer('.jpg', ['strip' => true, 'Q' => 85, 'optimize_coding' => true]);
$output_filename = $this->tmp('.jpg');
$image->writeToFile($output_filename);
$buffer2 = file_get_contents($output_filename);
It seems that it somehow identifies these optional arguments as required ones.
thanks chregu
I added |
Co-authored-by: Kleis Auke Wolthuizen <github@kleisauke.nl>
…switch-to-php-ffi
The |
thabnks kleis
OK, |
Thanks, too. Looks better now, but still have some segfaults running our tests. Need to look into more carefully and try to make it reproducable. But it seems to be some "heisenbug", depending on which tests I run in which order. And messages like these still happen
I'll try to be more helpful tomorrow |
I've probably got some extra or missing |
Finally could do a self contained script, which reports a Not super short still, but maybe it helps, it's code from all over our codebase If you comment out Used with this image https://chregus.rokka.io/or/a2272e/animated.gif
|
Oh that's great @chregu, thanks very much! I'll see if I can find the issue. |
fixes a crash, phew
Ouch that was painful, but I think I've finally found a fix. Or your program no longer crashes for me at least. |
You probably know, but just in case, you can replace $animated = Vips\Image::arrayjoin($images, ['across' => 1])->copy();
$animated->set('page-height', $images[0]->height);
$animated->set('loop', 0); If you set |
The most painful fixes are usually 4 lines or so ;) Thanks a lot, our tests actually run through now. Without warnings. And also thanks for the arrayjoin hint, will try that |
Great! Let's merge then, and think about the things that still need adding in another PR. Thanks very much for all the testing and code improvements! |
Remaining TODOs: #137 |
this is just great! thank you |
This gets rid of php-vips-ext and reimplements everything with the new php-ffi module instead. It should be simpler to develop and support, and much easier to deploy.
It now requires php 7.4 or later (when php-ffi was merged). I've bumped the version to 2.0 since this feels like a large change. The API is the same.
All tests pass, and it seems stable.
There are some obvious things we should still do, but I think they can wait until after this is merged.