-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Add PHP bindings for setting and getting the image resolution #2135
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
Conversation
Not knowing anything about GD conventions, might it be preferable to have a imageresolution() instead of imageresolution{x,y}()? The function could, for example, return an (array) pair. |
@nikic AFAIK, the only precendence for getting a horizontal/vertical pair in GD is imagesx()/imagesy(). However, there is imagecolorsforindex() which returns an associative array of channel values. It seems, we're free to choose. :-) Thinking about it, I tend to prefer a single function now – it'll be probably not often used, anyway. At least currently libgd doesn't do anything with the image resolution except for saving and loading it for PNG and JPEG images, so being able to set the resolution is presumably more important. |
@cmb69 Can we get an update on your intentions here please ? |
@krakjoe Thanks for the reminder! I'll update the PR today or tomorrow. |
We expose the image resolution related GD functionality to userland by introducing `imageresolution()` as getter/setter. Given only the image argument, it returns the current resolution as indexed array. Given only a second argument, it sets the horizontal and vertical resolution to this value. Given three arguments, it sets the horizontal and vertical resolution to the given arguments, respectively.
5fd808e
to
209d422
Compare
I've rewritten the PR to use a single function |
Set and get image resolution of PNG images | ||
--SKIPIF-- | ||
<?php | ||
if (!extension_loaded('gd')) die('skip gd extension not available'); |
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.
The first test has a skip for supported image type, this one doesn't. Is there a reason for that ?
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.
PNG is always supported; JPEG only when requested during build time.
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.
Ah, that's perfectly sensible. I wasn't sure, and did look for other tests checking for png, did find only one. Must be anomalous (maybe fix that when you have a moment).
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.
Fixed with 371f412.
* master: (24 commits) Turn IS_TYPE_COLLECTABLE zval flag into GC_COLLECTABLE zend_refcounted flag. This simplifies checks and allows reset this flag for "acyclic" arrays and objects. Fixed bug #73360 Unable to work in root with unicode chars Add tests for PDO::getAvailableDrivers Remove DBDO-specific field Save some more calls to strlen() on the CURLFile helper methods Revert "Fix test, this is kinda ugly, but at least for me on Windows there seems to be some messed up line endings" Save a call to strlen(), since we can figure out the length of this constant value with sizeof() at compile time Fix test, this is kinda ugly, but at least for me on Windows there seems to be some messed up line endings Fix bug #71241: array_replace_recursive mutates ref params Do not overwrite config.nice.bat if --with-config-profile is used on Windows Update UPGRADING wrt. imageresolution() Fixed test to accept MYSQLI_OPT_READ_TIMEOUT remove redundant includes fix Windows compilation Add php_random_int internal API Fix compiler warnings, always cast to zend_long from sqlite3_int64 when converting to a zval Ignore the return value of sqlite3->busyTimeout() if their "API Armor" is not enabled. news entry for pr php#2135 news entry for pr php#2152 news entry for #pr 2152 ...
We expose the image resolution related GD functionality to userland
by introducing
imagesetresolution()
,imageresolutionx()
andimageresolutiony()
as simple wrappers.