Skip to content

Commit

Permalink
Fixing pymupdf#2348
Browse files Browse the repository at this point in the history
We were returning arbitrary image type codes when reading the image binary from the PDF, e.g. "flate", even though they never would correspond to a meaningful image file extension.
This fix catches type codes not corresponding to known image file extensions and cause such images to be converted to PNG images (via an intermediate Pixmap).
  • Loading branch information
JorjMcKie authored and julian-smith-artifex-com committed Apr 18, 2023
1 parent 0f28efd commit ad668ae
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion fitz/fitz.i
Original file line number Diff line number Diff line change
Expand Up @@ -2863,7 +2863,10 @@ if len(pyliste) == 0 or min(pyliste) not in range(len(self)) or max(pyliste) not
res = NULL;
img = pdf_load_image(gctx, pdf, obj);
cbuf = fz_compressed_image_buffer(gctx, img);
if (cbuf) {
if (cbuf && cbuf->params.type != FZ_IMAGE_RAW &&
cbuf->params.type != FZ_IMAGE_FLATE &&
cbuf->params.type != FZ_IMAGE_LZW &&
cbuf->params.type != FZ_IMAGE_RLD) {
img_type = cbuf->params.type;
ext = JM_image_extension(img_type);
res = cbuf->buffer;
Expand Down

0 comments on commit ad668ae

Please sign in to comment.