Commit graph

848 commits

Author SHA1 Message Date
Mark
06a3dd536d Warnings to errors in imagecrop(auto) 2019-09-04 15:12:04 +02:00
Mark
d1f9ab11b3 Warnings to errors imageconvolution 2019-09-04 12:42:17 +02:00
Mark
34865f54e7 Warnings become errors for imagepolygon et al 2019-09-04 12:35:48 +02:00
Mark
87dbb32246 Negative checks for gamma 2019-09-04 12:31:01 +02:00
Mark
af8ecb39ae Warnings for image colour range check now throw exceptions 2019-09-04 12:27:08 +02:00
Mark
6c6c109e24 Warnings to errors for imagecreatefromgd2part
We also delete tests which were duplicates of a completely unrelated
test.
2019-09-04 12:22:27 +02:00
Mark
6a05e42459 Warnings to Errors imagetruecolortopalette 2019-09-04 12:14:34 +02:00
Mark
fde52e8a2c Warnings to Errors imagecreate(truecolor)
We also add a test helper which we will be using for other GD functions
as well.
2019-09-04 12:09:07 +02:00
Christoph M. Becker
4281b1378e Don't explicitly set return value on ZPP/ZFR failure
Failing `zend_parse_parameters()` and `zend_fetch_resource()` throw as
of PHP 8.0.0, so explicitly setting a return value is useless, and also
slightly confusing.
2019-08-12 14:42:26 +02:00
Nikita Popov
429378d78d Remove some misleading RETURN_FALSE
These functions throw, so they can't return false.

This is just a subset...
2019-08-12 10:05:36 +02:00
Christoph M. Becker
f30501b172 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix parameter order
2019-08-11 16:18:44 +02:00
Christoph M. Becker
9818f863c3 Fix parameter order
`imagecopymerge()` and `imagecopymergegray()` expect the destination
image first, not the other way round.
2019-08-11 16:16:39 +02:00
Christoph M. Becker
f273204011 Merge branch 'PHP-7.4'
* PHP-7.4:
  Extend color component range checks
2019-08-11 15:23:23 +02:00
Christoph M. Becker
092571c1cb Extend color component range checks
We also check for alpha components to be within range, and we add yet
missing range checks for other functions as well.
2019-08-11 15:21:05 +02:00
Christoph M. Becker
c90a27387e Add GD function stubs 2019-08-11 13:17:24 +02:00
Nikita Popov
a1e2c8870e Merge branch 'PHP-7.4' 2019-07-22 17:26:01 +02:00
Nikita Popov
d59aac58b3 Report errors from stream read and write operations
The php_stream_read() and php_stream_write() functions now return
an ssize_t value, with negative results indicating failure. Functions
like fread() and fwrite() will return false in that case.

As a special case, EWOULDBLOCK and EAGAIN on non-blocking streams
should not be regarded as error conditions, and be reported as
successful zero-length reads/writes instead. The handling of EINTR
remains unclear and is internally inconsistent (e.g. some code-paths
will automatically retry on EINTR, while some won't).

I'm landing this now to make sure the stream wrapper ops API changes
make it into 7.4 -- however, if the user-facing changes turn out to
be problematic we have the option of clamping negative returns to
zero in php_stream_read() and php_stream_write() to restore the
old behavior in a relatively non-intrusive manner.
2019-07-22 17:17:28 +02:00
Remi Collet
92d6720dcf Merge branch 'PHP-7.4'
* PHP-7.4:
  cleanup gd build with system libgd - drop need to use libpng with system libgd - drop need to use libjpeg with system libgd - drop need to use libXpm with system libgd - drop need to use libfreetype with system libgd - improve configure comments
2019-07-22 16:14:36 +02:00
Remi Collet
31d85b8417 cleanup gd build with system libgd - drop need to use libpng with system libgd - drop need to use libjpeg with system libgd - drop need to use libXpm with system libgd - drop need to use libfreetype with system libgd - improve configure comments 2019-07-22 16:14:19 +02:00
Christoph M. Becker
ebe91a0066 Merge branch 'PHP-7.4'
* PHP-7.4:
  Drop superfluous ENABLE_GD_TTF
2019-07-22 12:01:58 +02:00
Christoph M. Becker
d3d3404db7 Drop superfluous ENABLE_GD_TTF
If we `HAVE_LIBFREETYPE`, we define `ENABLE_GD_TTF` if it is not
defined.  Therefore we can check for `HAVE_LIBFREETYPE` in the first
place.
2019-07-22 12:01:24 +02:00
Nikita Popov
e36118a5c5 Merge branch 'PHP-7.4' 2019-07-16 12:20:21 +02:00
Nikita Popov
290e520c03 Use ZEND_HASH_FOREACH APIs in a few more places 2019-07-16 12:20:16 +02:00
Christoph M. Becker
611c57eaf7 Merge branch 'PHP-7.4'
* PHP-7.4:
  Properly shut down font cache mutex
2019-06-21 16:01:28 +02:00
Christoph M. Becker
eec5d2a25f Properly shut down font cache mutex
Since the font cache mutex in set up in MINIT, we have to shut it down
in MSHUTDOWN.
2019-06-21 16:00:47 +02:00
Christoph M. Becker
7469d572f2 Merge branch 'PHP-7.4'
* PHP-7.4:
  Support TGA reading
2019-06-20 23:41:23 +02:00
Christoph M. Becker
81fd113506 Support TGA reading
We add PHP bindings for libgd's features to read TGA files, which are
available as of libgd 2.1.0.

As PHP's bundled libgd doesn't yet include the respective features of the
external libgd, we add these.

Since TGA has no easily recognizable file signature, we don't add TGA
support for imagecreatefromstring() or getimagesize() and friends.
2019-06-20 23:40:51 +02:00
Nikita Popov
681136212f Merge branch 'PHP-7.4' 2019-06-20 10:16:31 +02:00
Nikita Popov
4488475a3e imagecolorallocate(): Check that RGB components are in-range
Instead of letting them bleed over into other components.
2019-06-20 10:09:54 +02:00
Nikita Popov
6ae9c10534 Merge branch 'PHP-7.4' 2019-06-19 16:36:29 +02:00
Nikita Popov
88b603768f imageloadfont: Perform overflow check before calculation
Instead of afterwards...
2019-06-19 15:50:52 +02:00
Christoph M. Becker
692673f6a4 Merge branch 'PHP-7.4'
* PHP-7.4:
  Add BMP support to PHP info
2019-06-13 13:07:30 +02:00
Christoph M. Becker
3c5bb06536 Add BMP support to PHP info 2019-06-13 13:07:01 +02:00
twosee
63171d88f2 Add do...while(0) for RETURN_* and ZVAL_* APIs
Closes GH-4255.
2019-06-12 16:17:16 +02:00
Nikita Popov
a31f46421d Allow exceptions in __toString()
RFC: https://wiki.php.net/rfc/tostring_exceptions

And convert some object to string conversion related recoverable
fatal errors into Error exceptions.

Improve exception safety of internal code performing string
conversions.
2019-06-05 14:25:07 +02:00
Kalle Sommer Nielsen
569e338104 Merge branch 'PHP-7.4'
* PHP-7.4:
  Implemented the gdScatter filter I wrote almost 10 years ago
2019-05-10 02:24:01 +03:00
Kalle Sommer Nielsen
bcd11a1dfb Implemented the gdScatter filter I wrote almost 10 years ago
This filter is available as of libgd 2.1.0 which is our bare minimum for
external compilation of ext/gd.

The scatter filter works by iterating over all pixels in the image and
shifting them randomly based on two modifier (`plus` and `sub`) values:

dest_x = (int)(x + ((rand() % (plus - sub)) + sub));
dest_y = (int)(y + ((rand() % (plus - sub)) + sub));

Additionally the scatter filter also supports by only shifting pixels where
the current pixel being iterated is one or more colors, allowing the scatter
filter to only effect solid colors in part of an image.

Note, due to the nature of randomness and implementation, pixels who were
shifted ahead of iteration will be shifted once more and therefore the
bottom right of an image may contain a slight scatter effect due to this.
2019-05-10 02:23:40 +03:00
Christoph M. Becker
f70a89318e Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix #77943: imageantialias($image, false); does not work
2019-04-29 16:19:21 +02:00
Christoph M. Becker
85cf1cb077 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix #77943: imageantialias($image, false); does not work
2019-04-29 16:18:54 +02:00
Christoph M. Becker
3fc1bdc81c Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2:
  Fix #77943: imageantialias($image, false); does not work
2019-04-29 16:18:27 +02:00
Christoph M. Becker
cd94cf60a2 Fix #77943: imageantialias($image, false); does not work
Firstly, we must not call `gdImageSetAntiAliased()` (which sets the
color to anti-alias), but rather modify the `gdImage.AA` flag.
Furthermore, we have to actually use the supplied boolean value.

We also make sure that we don't attempt to enable anti-aliasing for
palette images.
2019-04-29 16:16:46 +02:00
Christoph M. Becker
7ad6e1d7de Merge branch 'PHP-7.4'
* PHP-7.4:
  Remove unused variables
2019-03-17 23:32:53 +01:00
Fabien Villepinte
b6f9ade9f2 Remove unused variables 2019-03-17 23:29:51 +01:00
Christoph M. Becker
ebefb95fda Merge branch 'PHP-7.4'
* PHP-7.4:
  Remove dead code
2019-02-28 13:18:49 +01:00
Christoph M. Becker
345a75f541 Remove dead code
`_php_image_output()` is only ever called for `PHP_GDIMG_CONVERT_WBM`,
`PHP_GDIMG_TYPE_GD` and `PHP_GDIMG_TYPE_GD2`.  All other image types
solely use the more flexible `_php_image_output_ctx()`.
2019-02-28 13:11:41 +01:00
Nikita Popov
4be8208ef7 Use zpp string argument in imagecreatefromstring()
Instead of accepting a zval and casting it.
2019-02-28 12:07:34 +01:00
Peter Kokot
623911f993 Merge branch 'PHP-7.4'
* PHP-7.4:
  Remove local variables
2019-02-03 21:23:18 +01:00
Peter Kokot
92ac598aab Remove local variables
This patch removes the so called local variables defined per
file basis for certain editors to properly show tab width, and
similar settings. These are mainly used by Vim and Emacs editors
yet with recent changes the once working definitions don't work
anymore in Vim without custom plugins or additional configuration.
Neither are these settings synced across the PHP code base.

A simpler and better approach is EditorConfig and fixing code
using some code style fixing tools in the future instead.

This patch also removes the so called modelines for Vim. Modelines
allow Vim editor specifically to set some editor configuration such as
syntax highlighting, indentation style and tab width to be set in the
first line or the last 5 lines per file basis. Since the php test
files have syntax highlighting already set in most editors properly and
EditorConfig takes care of the indentation settings, this patch removes
these as well for the Vim 6.0 and newer versions.

With the removal of local variables for certain editors such as
Emacs and Vim, the footer is also probably not needed anymore when
creating extensions using ext_skel.php script.

Additionally, Vim modelines for setting php syntax and some editor
settings has been removed from some *.phpt files.  All these are
mostly not relevant for phpt files neither work properly in the
middle of the file.
2019-02-03 21:03:00 +01:00
Nikita Popov
e18fde1a02 Remove -1 crop mode 2019-01-30 16:46:36 +01:00
Zeev Suraski
0cf7de1c70 Remove yearly range from copyright notice 2019-01-30 11:03:12 +02:00