Skip to content

Commit 068d35a

Browse files
committed
Use gd_error() instead of zend_error()
Our goal is to have fewer differences from libgd. The change here I'm introducing in error levels in one case is something I now want to put into libgd.
1 parent ca1f13c commit 068d35a

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

ext/gd/libgd/gd_avif.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <math.h>
1010

1111
#include "gd.h"
12+
#include "gd_errors.h"
1213
#include "gdhelpers.h"
1314
#include "gd_intern.h"
1415

@@ -141,7 +142,7 @@ static avifBool isAvifSrgbImage(avifImage *avifIm) {
141142
*/
142143
static avifBool isAvifError(avifResult result, const char *msg) {
143144
if (result != AVIF_RESULT_OK) {
144-
zend_error(E_ERROR, "avif error - %s: %s", msg, avifResultToString(result));
145+
gd_error("avif error - %s: %s", msg, avifResultToString(result));
145146
return AVIF_TRUE;
146147
}
147148

@@ -178,7 +179,7 @@ static avifResult readFromCtx(avifIO *io, uint32_t readFlags, uint64_t offset, s
178179

179180
dataBuf = avifAlloc(size);
180181
if (!dataBuf) {
181-
zend_error(E_ERROR, "avif error - couldn't allocate memory");
182+
gd_error("avif error - couldn't allocate memory");
182183
return AVIF_RESULT_UNKNOWN_ERROR;
183184
}
184185

@@ -343,7 +344,7 @@ gdImagePtr gdImageCreateFromAvifCtx (gdIOCtx *ctx)
343344

344345
io = createAvifIOFromCtx(ctx);
345346
if (!io) {
346-
zend_error(E_ERROR, "avif error - Could not allocate memory");
347+
gd_error("avif error - Could not allocate memory");
347348
goto cleanup;
348349
}
349350

@@ -359,7 +360,7 @@ gdImagePtr gdImageCreateFromAvifCtx (gdIOCtx *ctx)
359360
goto cleanup;
360361

361362
if (!isAvifSrgbImage(decoder->image))
362-
zend_error(E_WARNING, "Image's color profile is not sRGB");
363+
gd_error_ex(GD_NOTICE, "Image's color profile is not sRGB");
363364

364365
// Set up the avifRGBImage, and convert it from YUV to an 8-bit RGB image.
365366
// (While AVIF image pixel depth can be 8, 10, or 12 bits, GD truecolor images are 8-bit.)
@@ -373,7 +374,7 @@ gdImagePtr gdImageCreateFromAvifCtx (gdIOCtx *ctx)
373374

374375
im = gdImageCreateTrueColor(decoder->image->width, decoder->image->height);
375376
if (!im) {
376-
zend_error(E_ERROR, "avif error - Could not create GD truecolor image");
377+
gd_error("avif error - Could not create GD truecolor image");
377378
goto cleanup;
378379
}
379380

@@ -470,17 +471,17 @@ void gdImageAvifCtx(gdImagePtr im, gdIOCtx *outfile, int quality, int speed)
470471
return;
471472

472473
if (!gdImageTrueColor(im)) {
473-
zend_error(E_ERROR, "avif doesn't support palette images");
474+
gd_error("avif error - avif doesn't support palette images");
474475
return;
475476
}
476477

477478
if (!gdImageSX(im) || !gdImageSY(im)) {
478-
zend_error(E_ERROR, "image dimensions must not be zero");
479+
gd_error("avif error - image dimensions must not be zero");
479480
return;
480481
}
481482

482483
if (overflow2(gdImageSX(im), gdImageSY(im))) {
483-
zend_error(E_ERROR, "image dimensions are too large");
484+
gd_error("avif error - image dimensions are too large");
484485
return;
485486
}
486487

0 commit comments

Comments
 (0)