Commit graph

709 commits

Author SHA1 Message Date
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
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
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
88b603768f imageloadfont: Perform overflow check before calculation
Instead of afterwards...
2019-06-19 15:50:52 +02:00
Christoph M. Becker
3c5bb06536 Add BMP support to PHP info 2019-06-13 13:07:01 +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
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
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
Fabien Villepinte
b6f9ade9f2 Remove unused variables 2019-03-17 23:29:51 +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
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
Zeev Suraski
0cf7de1c70 Remove yearly range from copyright notice 2019-01-30 11:03:12 +02:00
Andreas Treichel
3c9af3095c Preserve aspect ratio for width or height 2019-01-05 13:39:49 +01:00
Christoph M. Becker
8c781c1c20 Resolve imagecropauto() default $mode quirk
The `$mode` parameter of `imagecropauto()` defaults to `-1`.  However,
`-1` is changed to `GD_CROP_DEFAULT` right away, so basically the
default is `GD_CROP_DEFAULT`, which is rather confusing and
unnecessary.

Therefore, we change the default to `IMG_CROP_DEFAULT`, but still allow
an explicit `-1` to be passed for BC reasons, in which case we trigger
a deprecation notice, so we can rid the `-1` support eventually.
2018-12-12 17:25:37 +01:00
Peter Kokot
902d39a3a7 Trim trailing whitespace in source code files 2018-10-13 14:14:50 +02:00
Anatol Belski
9d7c510893 Cleanup unused items 2018-08-02 18:28:56 +02:00
Peter Kokot
8d3f8ca12a Remove unused Git attributes ident
The $Id$ keywords were used in Subversion where they can be substituted
with filename, last revision number change, last changed date, and last
user who changed it.

In Git this functionality is different and can be done with Git attribute
ident. These need to be defined manually for each file in the
.gitattributes file and are afterwards replaced with 40-character
hexadecimal blob object name which is based only on the particular file
contents.

This patch simplifies handling of $Id$ keywords by removing them since
they are not used anymore.
2018-07-25 00:53:25 +02:00
Christoph M. Becker
3cbf594dfd Deprecate image2wbmp()
According to https://wiki.php.net/rfc/image2wbmp, we deprecate
`image2wbmp()`, rename the `$threshold` parameter to `$foreground`, and
remove superfluous code.
2018-06-10 00:33:42 +02:00
Dmitry Stogov
5eb1f92f31 Use zend_string_release_ex() instread of zend_string_release() in places, where we sure about string persistence. 2018-05-28 16:27:12 +03:00
Christoph M. Becker
027dd86107 Dump obsolete EBCDIC support
As already suggested by Thies this code won't compile anymore, because
php3_rqst has been removed in 1999[1].  Since apparently nobody
complained about that, we assume that EBCDIC support isn't required
here, and rid the respective code.

Furthermore, the code appears to be erroneous anyway, since at least
XBM isn't a binary file format.

[1] <3cd0af11ee (diff-1a9cfc6173e3a434387996e46086da56L258)>
2018-05-14 23:26:43 +02:00
Christoph M. Becker
4095f63a90 Merge branch 'PHP-7.2'
* PHP-7.2:
  Fix #73957: signed integer conversion in imagescale()
2018-03-10 00:26:25 +01:00
Christoph M. Becker
d709922979 Merge branch 'PHP-7.1' into PHP-7.2
* PHP-7.1:
  Fix #73957: signed integer conversion in imagescale()
2018-03-10 00:25:11 +01:00
Christoph M. Becker
f1b358c9a9 Fix #73957: signed integer conversion in imagescale()
We must not pass values to `gdImageScale()` which cannot be represented
by an `unsigned int`.  Instead we return FALSE, according to what we
already did for negative integers.
2018-03-10 00:17:09 +01:00
Gabriel Caruso
5f54f48024 [ci skip] Remove space between function name and open parentheses 2018-02-24 11:50:39 +01:00
Christoph M. Becker
3da9fc86d1 Merge branch 'PHP-7.2'
* PHP-7.2:
  Fix imagesetinterpolation arginfo
2018-02-24 11:33:13 +01:00
Christoph M. Becker
8c396e0e88 Merge branch 'PHP-7.1' into PHP-7.2
* PHP-7.1:
  Fix imagesetinterpolation arginfo
2018-02-24 11:32:03 +01:00
Gabriel Caruso
a358211a75 Fix imagesetinterpolation arginfo
imagesetinterpolation only requires one parameter.
2018-02-24 11:30:24 +01:00
Gabriel Caruso
6400264856 Trailing whitespaces
Signed-off-by: Gabriel Caruso <carusogabriel34@gmail.com>
2018-01-03 14:38:00 +01:00
Xinchen Hui
a6519d0514 year++ 2018-01-02 12:57:58 +08:00
Xinchen Hui
7a7ec01a49 year++ 2018-01-02 12:55:14 +08:00
Xinchen Hui
ccd4716ec7 year++ 2018-01-02 12:53:31 +08:00
Dmitry Stogov
9e709e2fa0 Move constants into read-only data segment 2017-12-14 18:43:44 +03:00
Christoph M. Becker
1530d01b7a Merge branch 'PHP-7.2'
* PHP-7.2:
  Fix bug #75437 Wrong reflection on imagewebp
2017-10-25 13:10:33 +02:00
Christoph M. Becker
c78813a6b8 Merge branch 'PHP-7.1' into PHP-7.2
* PHP-7.1:
  Fix bug #75437 Wrong reflection on imagewebp
2017-10-25 13:03:42 +02:00
Christoph M. Becker
9d59beb8ba Merge branch 'PHP-7.0' into PHP-7.1
* PHP-7.0:
  Fix bug #75437 Wrong reflection on imagewebp
2017-10-25 12:56:25 +02:00
Fabien Villepinte
0fbb9f343f Fix bug #75437 Wrong reflection on imagewebp 2017-10-25 12:54:05 +02:00
Xinchen Hui
ff6f41c94e Narrow typeinfos down for zend_parse_paramenters_none 2017-09-12 11:25:21 +08:00
Xinchen Hui
1f327284a4 Fixed signature 2017-09-09 20:40:55 +08:00
Tom Van Looy
da0b5b35c5 Remove redundant checks in ext/gd 2017-09-04 21:30:09 +02:00
Andreas Treichel
e4b9c3744c Replace magic values with constants 2017-08-19 14:28:22 +02:00
Andreas Treichel
47fcd13055 Add support for webp in imagecreatefromstring 2017-07-30 02:50:33 +02:00
Nikita Popov
b2a4af7b58 Merge branch 'PHP-7.1' 2017-02-02 18:15:11 +01:00
Nikita Popov
2d1955796e Merge branch 'PHP-7.0' into PHP-7.1 2017-02-02 18:14:50 +01:00
Matěj Humpál
acda2563ce Fix bug #74031
Fix incorrect parameter count for imagepng function
2017-02-02 18:13:53 +01:00
Sammy Kaye Powers
dac6c639bb Update copyright headers to 2017 2017-01-04 11:23:42 -06:00
Sammy Kaye Powers
478f119ab9 Update copyright headers to 2017 2017-01-04 11:14:55 -06:00
Christoph M. Becker
500b496f8e Implement #69606: Support BMPs (added in GD 2.1.0)
We add PHP bindings for libgd's features to read and write BMP 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.
2017-01-04 14:55:02 +01:00
Sammy Kaye Powers
9e29f841ce Update copyright headers to 2017 2017-01-02 09:30:12 -06:00