Commit Graph

1237 Commits (master)

Author SHA1 Message Date
Maryam Ebrahimzadeh e8eeb8dde5
trigger the github actions 2021-08-24 11:46:07 +04:30
Pierre Joye 86a9e24510 Add ENABLE_CPP_API 2021-08-23 22:55:56 +07:00
Pierre Joye 1a04cda56a remove annotate from windows builds 2021-08-23 21:18:29 +07:00
Pierre Joye 8864a3086f remove from .c too 2021-08-23 21:05:17 +07:00
Pierre Joye 3dc1ea0d5f +NOT 2021-08-23 20:57:30 +07:00
Pierre Joye 18324c72c2 tried, remove it from windows build, will need portable codes elsewhere 2021-08-23 20:27:40 +07:00
Pierre Joye 5a34892fe2 move and fix opt* extern declaration, windows MSC only 2021-08-23 19:38:15 +07:00
Pierre Joye 05e0b65895 move and fix opt* extern declaration, windows MSC only 2021-08-23 19:29:11 +07:00
Pierre Joye d8e894030e webpng mkstemp, windows MSC only 2021-08-23 19:08:34 +07:00
Pierre Joye e19f011737 webpng mkstemp 2021-08-23 19:05:30 +07:00
Pierre Joye 6be94bf3ea opt* are extern, missed optarg 2021-08-23 18:52:13 +07:00
Pierre Joye b3d1627998 opt* are extern 2021-08-23 18:41:13 +07:00
Pierre Joye ca1c63050d that should solve all ssize_t issue w/VC 2021-08-23 18:24:48 +07:00
Pierre Joye d2a4d180f2 syntax fix 2021-08-23 18:17:15 +07:00
Pierre Joye 6ede9b45e8 syntax fix 2021-08-23 17:46:11 +07:00
Pierre Joye 02a14bc7dc syntax fix 2021-08-23 17:40:10 +07:00
Pierre Joye 1c18f158a0 syntax fix 2021-08-23 17:33:37 +07:00
Pierre Joye d4d9975b05 recent VC has stdint 2021-08-23 17:15:15 +07:00
Pierre Joye 0143009716 let define ssize_t here on windows 2021-08-23 17:05:36 +07:00
Pierre Joye c425bc494c this header should not be included on windows 2021-08-23 16:56:01 +07:00
Pierre Joye c7ee15f81d Fix #733, silent warning for infile 2021-08-23 15:59:06 +07:00
Pierre Joye b5c494bc87 Fix #733, use of undeclared identifier 'size': ARG_NOT_USED(size) 2021-08-23 14:00:19 +07:00
Pierre Joye 4cf3715a9a add option to enable/disable CPP API 2021-08-22 11:50:59 +07:00
Pierre Joye 05c39aafb2 enable these interpolations 2021-08-20 14:45:13 +07:00
Pierre Joye 73ccc1d7e5 refactor and cleanup 2021-08-20 14:39:41 +07:00
Pierre Joye e087ea0e38 mark as private 2021-08-20 07:20:09 +07:00
Pierre Joye 2d7db2d7fa silent fall trhough warning, that comment is read by gcc 2021-08-17 10:46:07 +07:00
Pierre Joye 9af6d1254f heif_ctx not used 2021-08-16 17:14:12 +07:00
Pierre Joye 98c6a27429 silent warning/unused args when codecs not enabled 2021-08-16 17:03:52 +07:00
Pierre Joye f49d0aef3b little more close to IM/GM/Lepto and co 2021-08-16 17:02:51 +07:00
Pierre Joye 672475e540 refactor/cleanup scaling 2 passes 2021-08-16 13:53:49 +07:00
Pierre Joye c483535fc9 revert that part, should be test side only 2021-08-16 06:54:00 +07:00
Pierre Joye 9cb2d1dcf5 Fix #725, Gif Anim API, adding frame leak from tmp image, test already in place (gcc ASAN detects it) 2021-08-13 21:53:37 +07:00
Pierre Joye bd72a7da40 WebP: Fix memory leak in test and avoid possible memory leak if size is not correct (ie. passing 0 size will leak). Min size is the WebP sign (3x32bits) 2021-08-13 21:14:36 +07:00
Pierre Joye dfe1ecb8a9 cleanup, clamping is not neeeded at all. Fix signed/unsigned comparison 2021-08-13 20:53:53 +07:00
Ben Morss f9c995b55c
Disable strict pixi requirement for libavif >= 0.9.1 (#723)
Some AVIF image generators didn't include the PixelInformationProperty (pixi),
even though strictly speaking they should. In v0.9.2, libavif began requiring this.
Let's disable it so we can read those images too.
2021-08-03 23:07:48 -04:00
Christoph M. Becker 8accfa98a7
Merge pull request #698 from adamsilverstein/webp-lossless
Support writing lossless WebP
2021-07-23 23:30:27 +02:00
Pierre Joye c380ba2b78 Revert "Merge pull request #712 from me22bee/gdImageGdPtr"
This reverts commit bfc90ac2a6, reversing
changes made to edaf39fe6f.
2021-07-20 09:50:57 +07:00
maryam ebrahimzadeh e95059590f gdImageGd2Ptr memory leak 2021-07-19 18:52:50 +04:30
maryam ebrahimzadeh a9328b0125 gdImageGdPtr memory leak 2021-07-19 12:05:17 +04:30
maryam ebrahimzadeh 8b111b2b4a fix read out-of-bands in reading tga header file 2021-07-19 10:07:13 +04:30
Mike Frysinger bf36fa539b use https://libgd.org 2021-07-05 23:59:35 -04:00
Mike Frysinger 19c7a5d651 use gdIOCtxPtr more consistently
We have gdIOCtxPtr for gdIOCtx*, so switch the public headers to it
consistently.
2021-05-28 21:19:20 -04:00
Mike Frysinger df8f989825 use malloc compiler attribute if available
This informs the compiler that these functions return allocated
memory.  That allows it to make some optimization decisions which
can produce better code.
2021-05-28 15:47:37 -04:00
Mike Frysinger 968ba1132d gd_strtok: constify delimiter 2021-05-28 15:45:06 -04:00
Ben Morss 5c55da917d avifMalloc => avifAlloc 2021-05-26 22:19:31 -04:00
Mike Frysinger d6baf4c5c9 gdft: fix image pointer types
These are equiv, but switch them over for clarity & consistency.
2021-05-26 20:12:50 -04:00
Ben Morss 255e7bd97e Downgrade WARNING error to NOTICE
I hadn't realized that gd_error() output a LOG_WARNING. I don't think this error is as significant as the errors that occur when we can't process the user's request at all.
2021-05-26 11:25:56 -04:00
Ben Morss cba26d7fc6 Fix memory leak
libavif will use this function as a callback.
Using libavif's memory allocators gives libavif a chance to release this memory when it's finished with it.
2021-05-26 11:21:46 -04:00
Adam Silverstein a2b3ba08ef Merge branch 'master' into webp-lossless
# Conflicts:
#	tests/webp/.gitignore
#	tests/webp/CMakeLists.txt
#	tests/webp/Makemodule.am
2021-05-05 09:30:02 -06:00
Adam Silverstein 3826c44e52 Set gdWebpLossless as threshold at 101. 2021-05-05 09:16:55 -06:00
Mike Frysinger 82d2609505 merge duplicate COPYING files
The toplevel COPYING had one small bit missing that src/COPYING had,
so move that over and delete the duplicate.
2021-04-24 23:58:06 -04:00
willson-chen 8df65487ff drop support for VMS #453 2021-04-24 23:30:42 -04:00
Mike Frysinger b4eb70cf74 drop support for freetype <2.1.3
The configure script has already been requiring freetype-2.1.10+, so
this isn't really dropping old support.  Even then, 2.1.3 was released
in 2002, so users have had plenty of time to upgrade.
2021-04-24 23:27:45 -04:00
Mike Frysinger b2769ffe40 stop installing entities.h 2021-04-24 23:26:48 -04:00
Mike Frysinger d89be11633 open up 2.4.0 development for major(ish) changes 2021-04-24 23:21:42 -04:00
Khem Raj 93e53a7b80 replace uint32 with uint32_t and uint16 with uint16_6
uint16 and uint32 are now deprecated in libtiff and suggestion is to use
standard C99 types

Signed-off-by: Khem Raj <raj.khem@gmail.com>
2021-04-23 02:13:46 -04:00
Ben Morss f6a111c632
Fix for libavif v0.8.2 (#680)
Don't return AVIF_RESULT_TRUNCATED_DATA, as this is normal for libavif <= 0.8.2. In our tests,
this makes tests pass with libavif 0.8.2.

Plus, we did a few things to stop compiler warnings - and added a newline to error output.

thanks @wantehchang for the collaboration here!

This fixes #677.
2021-03-16 12:26:17 -04:00
Ben Morss a29904a688
Set default AVIF encoding speed to 6 (#683)
Turns out that, in many cases, AVIF's default encoding speed (AVIF_SPEED_DEFAULT)
would be 0, the slowest possible speed.

The team's been working on making speed 6 a great compromise.
We should make this our default as well.
2021-03-16 12:19:06 -04:00
Martin Reboredo f7d12c91fa
Permit compilation with libheif version 1.7.0 (#686)
libheif versions that came before 1.9.0 don't support changing the output image chroma.
I did not notice that and it resulted with tests failures across other OSes that don't have
a much newer libheif.

See #678. Supersedes #685.
2021-03-16 11:53:16 -04:00
Mike Frysinger 2e40f55bfb release 2.3.2 2021-03-06 14:16:01 -05:00
Mike Frysinger 122799495c avif: fix build warnings in new code 2021-03-04 21:34:16 -05:00
Ben Morss f2aa2836ed
AVIF support (#671)
Demand for AVIF support on the web is growing, as the word gets out
about this new file format which allows higher-quality encoding at
smaller sizes.  Core contributors to major open-source CMSs are
interested in auto-generating AVIF images! They've been simply
waiting for support to appear in libgd.

This PR aims to meet the growing demand, and to help bring smaller,
more beautiful images to more of the web - to sites created by
experienced developers and CMS users alike.

This PR adds support by incorporating libavif in addition to the
existing libheif support.  It's generally felt that libavif has
more complete support for the AVIF format. libavif is also used
by the Chromium project and squoosh.app.

In this PR, I've endeavored to incorporate the latest research into
best practices for AVIF encoding - not just for default quantizer
values, but also an algorithm for determining the number of
horizontal tiles, vertical tiles, and threads.

Fixes #557.
2021-03-03 21:35:56 -05:00
az6667 fc38677e80
Allow GIFs missing both Global and Local Colormaps to still decode (#494)
Ensure that a GIF without any Global or Local color tables is still
decoded by libgd.

GIF89a spec indicates conforming image files need not have
Global or Local color tables at all.

Spec recommends creating custom color map in that situation, and
that at least Black+White as first two entries, to ensure B&W images
are decoded.

Some commonly used single-pixel GIFs found around the web are
undecoded by libgd otherwise. Test case has been included.

References:
https://www.w3.org/Graphics/GIF/spec-gif89a.txt
http://probablyprogramming.com/2009/03/15/the-tiniest-gif-ever
2021-03-03 02:17:51 -05:00
Mike Frysinger a9a5b45983 drop redundant strcasecmp define
The common gd.h already provides this.
2021-03-03 02:08:46 -05:00
Martin Reboredo 39c4644fa0
HEIF support through libheif (#670)
With the adoption of AVIF by Firefox and Chromium based browsers (still
in experimental phase), the newer incorporation of HEIF by Canon and Sony 
in their cameras and the newer support of both of them in modern software 
like ImageMagick, GIMP and Krita, `gd` haven't seen any endorsement for
the formats up until this PR.

Reading and writing is done by `libheif`, with functionality for chroma 
subsampling (for now `4:2:0`, `4:2:2` and `4:4:4`), quality (with new
`200` for lossless) and compression (whether `HEVC` or `AV1`) selection. 

This was tested with `libheif` version `1.11.0` in my Solus machine.

Also, fixes both #395 and #557.
2021-03-02 12:32:03 -05:00
Mike Frysinger d6e3413f7f drop unused snprintf fallback
This was added ages ago with code that has since been deleted.
2021-02-21 12:48:22 -05:00
Mike Frysinger 34048f3dac regen config.h.cmake to include new symbols 2021-02-20 03:08:39 -05:00
Mike Frysinger c0a55d9d00 add missing gd_intern.h include
I removed the local MIN/MAX macros, but missed adding the gd_intern.h
include when doing so.
2021-02-08 18:44:32 -05:00
Mike Frysinger e1f02d2833 gd_intern: unify the min/max/clamp macros some more 2021-02-05 22:47:13 -05:00
Mike Frysinger f538eedc7c gd_filename: constify & localize more
Mark the data structures & functions as const & static when possible,
and punt the unused FType enum.
2021-02-05 00:45:55 -05:00
WilliamHeaven 4dd5f43bc6 Fix copyright format problem 2021-02-01 22:39:33 -05:00
wilson chen 75ef79c9b0
release-2.3.1 (#668) 2021-01-30 15:16:05 +08:00
Mike Frysinger 82b08997c1 gd_io: replace internal Putchar with gdPutC
Most code is already using gdPutC instead of Putchar -- only the bmp
module is using Putchar.  It's unclear why we have this other form as
they should be equivalent: gdPutC takes an unsigned char (8-bits) and
then calls ctx->putC while Putchar takes a signed int, masks it with
0xff, and then calls ctx->putC.

The history of these funcs goes back to when it's initially imported
as part of the 1.5.0 release, and there doesn't seem to be any notes
as to why.

So change bmp to use gdPutC so we can delete Putchar entirely.  The
function isn't exported so no one should even notice.  Our tests are
still passing, so hopefully that provide good coverage.
2021-01-11 19:15:17 -05:00
Mike Frysinger 8d63967a52 gd_io: trim unused Putword function 2021-01-11 18:53:50 -05:00
Christoph M. Becker 9ed642764c Fix potential integer overflow detected by oss-fuzz 2020-08-24 17:03:07 +02:00
Remi Collet 0be6aec0fe Fix #615 using libraqm
and avoid unneeded free
2020-07-15 09:45:07 +02:00
wilson chen 28ecfe77c8
fix #303: gdlib.pc: use Requires instead of Libs (#537) 2020-06-18 14:55:32 +08:00
Marek Skalický 4abc26cca6
Compute average in gdGuessBackgroundColorFromCorners properly (#483) 2020-05-13 19:19:08 +08:00
willson-chen bfb3139110 Move src/gd_color_map_test.c to tests
And improve it more like a test case.
2020-05-06 15:01:17 +08:00
Christoph M. Becker 3dd0e308cb
Fix #615: gdImageStringFT() fails for empty strings as of libgd 2.3.0 (#633)
We change the return type of `textLayout()` to `ssize_t`, and signal
failure by returning `-1`, so that laying out an empty string is no
longer handled as failure.  We make sure that no overflow occurs,
assuming that all `int` values can be fully represented as `ssize_t`.
2020-05-05 18:02:45 +08:00
Remi Collet d3185dcfb6 fix typo but preserve BC 2020-04-15 09:11:01 +02:00
wilson chen da50dce3ba
src/config.h.cmake: replace #cmakedefine01 with #define in macro ENABLE_GD_FOORMATS (#622)
Although we have a document describ the avaiable options
are ENABLE_XXX=1/0, there must some one are familar with
ENABLE_XXX=ON/OF.  If ENABLE_GD_FORMATS=ON is used, it will
result that GD formats is not enabled actually.
2020-04-14 23:30:18 +08:00
willson-chen ce00fbff0e Move initial declaration out of `for` loop
'for' loop initial declarations are only allowed in C99 mode.
2020-03-25 11:41:44 +08:00
Benjamin Kramer 3d2bd757f0
Make gd_nnquant.c less likely to introduce duplicate definitions (#601)
This file contains some accidentally global symbols with generic names.
Give them internal linkage (or remove if unused) to avoid conflicts when
linking another library that happens to use the same generic names.
2020-03-23 23:25:24 +08:00
willson-chen 3b38ad28fd src/gd.h: Update version 2020-03-22 21:40:02 +08:00
Kleber Tarcísio 954f427ea9 gdcache: fix main function error
First argument of ‘main’ should be ‘int’.
2020-03-21 21:31:48 +08:00
wilson chen 3f50ffaefd
Fixed #596: gdTransformAffineCopy run error
And add test case for it.
2020-03-21 15:31:40 +08:00
wilson chen 04bb9a08b3
Fix #301: brect bounds
According to the result, the extra one pixel is unnessary. Deleting the related code block makes
the image looks fine.
2020-02-25 23:40:27 +08:00
wilson chen ace7fd88dc
Fixed #169: update var type to hold bigger w&h for ellipse (#565)
Update var type to hold bigger w&h for ellipse. And add corresponding test cases.
2020-02-09 22:13:26 +08:00
Christoph M. Becker a702897fb2 Revert accidential changes to config.h.cmake
These happened with commit 9088591eae.
2020-01-06 09:45:37 +01:00
Christoph M. Becker a9e66268f9 Fix #586: gdTransformAffineCopy() segfaults on palette images
We have to properly distinguish between truecolor and palette images.
2020-01-05 00:21:08 +01:00
Christoph M. Becker 9088591eae Fix #585: gdTransformAffineCopy() changes interpolation method
We have to properly initialize `interpolation_id_bak`.
2020-01-04 23:43:47 +01:00
Christoph M. Becker 6d21d30429 Fix #584: gdImageSetInterpolationMethod(im, GD_DEFAULT) inconsistent
We have to avoid the unintended fall through.
2020-01-04 19:06:51 +01:00
Christoph M. Becker 7a06c1669c Fix #583: gdTransformAffineCopy() may use unitialized values
We have to check the return value of `gdAffineInvert()`, and on failure
let `gdTransformAffineCopy()` fail as well.
2020-01-04 19:06:51 +01:00
wilson chen 13705fe80f
gdcache: improve gdcache test compile cmd 2019-12-22 23:04:29 +08:00
Fábio Cabral Pacheco a93eac0e84 Fix potential NULL pointer dereference in gdImageClone() 2019-12-20 17:19:54 +01:00
wilson chen 2e886046f8
Fix #497: gdImageColorMatch Out Of Bounds Write on Heap (CVE-2019-6977)
Fixed CVE-2019-6977 and add corresponding testcase.

Original patch by Christoph M. Bechker <cmbecker69@gmx.de>
https://gist.github.com/cmb69/1f36d285eb297ed326f5c821d7aafced
2019-12-20 10:12:04 +08:00
willson-chen 4b0f372402 Fixed #369: fix new_a init error in gdImageConvolution() 2019-12-13 10:54:25 +01:00
Christoph M. Becker 48ffba3f1b Fix GD build with -D SIGNED_COMPARE_SLOW
Apparently, this has not been tested for a long time, and might be a
refactoring relict.  Anyhow, we have to pass the context to
`GIFNextPixel` as well.

This issue has been reported by Kleber Tarcísio.
2019-11-21 20:07:20 -05:00