Skip to content

Commit

Permalink
We need both gdImageCreateFromJpeg* and gdImageCreateFromJpeg*Ex
Browse files Browse the repository at this point in the history
The new (Ex) functions are used with the new ignore_warning parameter

The standard functions are used in _php_image_create_from_string,
sent as a function pointer, and call without this optional parameter.
  • Loading branch information
remicollet committed Apr 24, 2013
1 parent 7189cc5 commit dd0399f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 9 deletions.
4 changes: 2 additions & 2 deletions ext/gd/gd.c
Original file line number Diff line number Diff line change
Expand Up @@ -2670,7 +2670,7 @@ static void _php_image_create_from(INTERNAL_FUNCTION_PARAMETERS, int image_type,
case PHP_GDIMG_TYPE_JPG:
ignore_warning = INI_INT("gd.jpeg_ignore_warning");
#ifdef HAVE_GD_BUNDLED
im = gdImageCreateFromJpeg(fp, ignore_warning);
im = gdImageCreateFromJpegEx(fp, ignore_warning);
#else
im = gdImageCreateFromJpeg(fp);
#endif
Expand Down Expand Up @@ -4783,7 +4783,7 @@ static void _php_image_convert(INTERNAL_FUNCTION_PARAMETERS, int image_type )
case PHP_GDIMG_TYPE_JPG:
ignore_warning = INI_INT("gd.jpeg_ignore_warning");
#ifdef HAVE_GD_BUNDLED
im_org = gdImageCreateFromJpeg(org, ignore_warning);
im_org = gdImageCreateFromJpegEx(org, ignore_warning);
#else
im_org = gdImageCreateFromJpeg(org);
#endif
Expand Down
6 changes: 4 additions & 2 deletions ext/gd/libgd/gd.h
Original file line number Diff line number Diff line change
Expand Up @@ -362,8 +362,10 @@ gdImagePtr gdImageCreateFromPng(FILE *fd);
gdImagePtr gdImageCreateFromPngCtx(gdIOCtxPtr in);
gdImagePtr gdImageCreateFromWBMP(FILE *inFile);
gdImagePtr gdImageCreateFromWBMPCtx(gdIOCtx *infile);
gdImagePtr gdImageCreateFromJpeg(FILE *infile, int ignore_warning);
gdImagePtr gdImageCreateFromJpegCtx(gdIOCtx *infile, int ignore_warning);
gdImagePtr gdImageCreateFromJpeg(FILE *infile);
gdImagePtr gdImageCreateFromJpegEx(FILE *infile, int ignore_warning);
gdImagePtr gdImageCreateFromJpegCtx(gdIOCtx *infile);
gdImagePtr gdImageCreateFromJpegCtxEx(gdIOCtx *infile, int ignore_warning);
gdImagePtr gdImageCreateFromWebp(FILE *fd);
gdImagePtr gdImageCreateFromWebpCtx(gdIOCtxPtr in);
gdImagePtr gdImageCreateFromWebpPtr (int size, void *data);
Expand Down
25 changes: 20 additions & 5 deletions ext/gd/libgd/gd_jpeg.c
Original file line number Diff line number Diff line change
Expand Up @@ -269,21 +269,31 @@ void gdImageJpegCtx (gdImagePtr im, gdIOCtx * outfile, int quality)
gdFree (row);
}

gdImagePtr gdImageCreateFromJpeg (FILE * inFile, int ignore_warning)
gdImagePtr gdImageCreateFromJpeg (FILE * inFile)
{
return gdImageCreateFromJpegEx(inFile, 1);
}

gdImagePtr gdImageCreateFromJpegEx (FILE * inFile, int ignore_warning)
{
gdImagePtr im;
gdIOCtx *in = gdNewFileCtx(inFile);
im = gdImageCreateFromJpegCtx(in, ignore_warning);
im = gdImageCreateFromJpegCtxEx(in, ignore_warning);
in->gd_free (in);

return im;
}

gdImagePtr gdImageCreateFromJpegPtr (int size, void *data, int ignore_warning)
gdImagePtr gdImageCreateFromJpegPtr (int size, void *data)
{
return gdImageCreateFromJpegPtrEx(size, data, 1);
}

gdImagePtr gdImageCreateFromJpegPtrEx (int size, void *data, int ignore_warning)
{
gdImagePtr im;
gdIOCtx *in = gdNewDynamicCtxEx(size, data, 0);
im = gdImageCreateFromJpegCtx(in, ignore_warning);
im = gdImageCreateFromJpegCtxEx(in, ignore_warning);
in->gd_free(in);

return im;
Expand All @@ -298,7 +308,12 @@ static int CMYKToRGB(int c, int m, int y, int k, int inverted);
* Create a gd-format image from the JPEG-format INFILE. Returns the
* image, or NULL upon error.
*/
gdImagePtr gdImageCreateFromJpegCtx (gdIOCtx * infile, int ignore_warning)
gdImagePtr gdImageCreateFromJpegCtx (gdIOCtx * infile)
{
return gdImageCreateFromJpegCtxEx(infile, 1);
}

gdImagePtr gdImageCreateFromJpegCtxEx (gdIOCtx * infile, int ignore_warning)
{
struct jpeg_decompress_struct cinfo;
struct jpeg_error_mgr jerr;
Expand Down

0 comments on commit dd0399f

Please sign in to comment.