"Export" php_gd_libgdimageptr_from_zval_p()#5830
Conversation
Todo: check why FFMPEG_PHP_FETCH_IMAGE_RESOURCE is still used in PHP 8
There was a problem hiding this comment.
In file included from main/internal_functions_cli.c:45:
/home/vsts/work/1/s/ext/gd/php_gd.h:80:10: fatal error: gd.h: No such file or directory
I think having an include at this position means we need to pollute the global include path with the gd incdir, rather than just for the gd extension.
There was a problem hiding this comment.
I don't think we actually need to export php_gd_image_object and php_gd_exgdimage_from_zobj_p though. Just php_gd_libgdimageptr_from_zval_p as a non-inline function should be enough. If you change the return value to struct gdImageStruct * we don't need the gd.h include either.
There was a problem hiding this comment.
I'm afraid all this is necessary, so we can get the offsetof of the std member in a portable way. :(
There was a problem hiding this comment.
To be clear, what I means is: If the implementation is part of the .c file and only exported via PHP_GD_API, why do we need to expose the offset?
There was a problem hiding this comment.
Ah, understood now. Thanks! Will update the PR this evening.
Some extension may need to retrieve the `gdImagePtr` from an `GdImage` object; thus, we export the respective function. To not being forced to include gd.h in php_gd.h, we use the opaque `struct gdImageStruct *` as return type.
305d373 to
037e8d5
Compare
|
I applied your adjusted patch to PHP 8.0.0 alpha 2 and removed the imported lines https://github.com/Jan-E/php7-ffmpeg/blob/c7d3316e7c8792348a476434ff557bd0da1abc6c/ffmpeg_frame.c#L65-L93 Then I did a complete recompile of PHP with all the extensions. Result for php_ffmpeg: Is there something extra that I have to do to use the PHP_GD_API function php_gd_libgdimageptr_from_zval_p? |
|
I tried including php_gd.h in my config.w32 but that did not help either: |
|
I could tweak config.w32 to link php_gd2.lib, but this certainly could not be the desired solution: |
|
and php_gd2.lib is not added to the link statement. |
|
@cmb69 @nikic I did not check if the same problems arise in a *nix environment. |
|
Sorry, the patch is incomplete. And indeed, there is an additional issue regarding the name of the extension being "gd", but the .dll being named "php_gd2.dll" (that prevents |
|
Fine with me. I am not in a hurry and happy to test. There was a remarkable difference between the linked php_gd2.lib and the copied lines. The linked php_gd2.lib version gave a warning: Line 370 is the one at https://github.com/Jan-E/php7-ffmpeg/blob/5187bd090602c5a6741c2f0a9c54836647969e53/ffmpeg_frame.c#L370 The warning should not be ignored in this case, because the toGDimage() failed once again. I reverted my last commit. |
This warning is likely the result of |
There's not really much point in giving the DLL a version number, since there is no php_gd.dll for years (if there ever has been). Renaming, on the hand, matches the name on other systems (gd.so), and allows to actually use `ADD_EXTENSION_DEP()`.
|
The missing support code for importing should now be in place. I have also added a commit which renames php_gd2.dll to php_gd.dll. https://gist.github.com/cmb69/048d3a2a60fe0b5417ff70fc1af0b18b has the code I used for testing this PR. |
|
Looking good. Jan-E/php7-ffmpeg@89afa67 and Jan-E/php7-ffmpeg@36be7d4 |
|
Thanks! Applied as 340e2ea. |
Some extension may need to retrieve the
gdImagePtrfrom anGdImageobject; thus, we move the respective function and the supporting code
to php_gd.h.