summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2018-02-13 13:22:15 +0100
committerTor Andersson <tor.andersson@artifex.com>2018-02-13 13:23:42 +0100
commit4e928c68b1852b860122bac28cc0f3af96c3156e (patch)
tree21b2d23ce9a9eca3e29132cf74c975236c3947c2 /source
parent7085ddc1eb1a4abb6bf7e8e2d6e65ae8bbe2ce3c (diff)
downloadmupdf-4e928c68b1852b860122bac28cc0f3af96c3156e.tar.xz
mutool extract: Don't save raw CMYK jpegs when the -r flag is enabled.
Diffstat (limited to 'source')
-rw-r--r--source/tools/pdfextract.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/source/tools/pdfextract.c b/source/tools/pdfextract.c
index 000210dd..6de26689 100644
--- a/source/tools/pdfextract.c
+++ b/source/tools/pdfextract.c
@@ -73,6 +73,7 @@ writejpeg(fz_context *ctx, const unsigned char *data, size_t len, const char *fi
out = fz_new_output_with_path(ctx, buf, 0);
fz_try(ctx)
{
+ printf("extracting image %s\n", buf);
fz_write_data(ctx, out, data, len);
fz_close_output(ctx, out);
}
@@ -102,23 +103,29 @@ static void saveimage(int num)
cbuf = fz_compressed_image_buffer(ctx, image);
fz_snprintf(buf, sizeof(buf), "img-%04d", num);
type = cbuf == NULL ? FZ_IMAGE_UNKNOWN : cbuf->params.type;
+
if (image->use_colorkey)
type = FZ_IMAGE_UNKNOWN;
if (image->use_decode)
type = FZ_IMAGE_UNKNOWN;
if (image->mask)
type = FZ_IMAGE_UNKNOWN;
- switch (type)
+ if (dorgb)
{
- case FZ_IMAGE_JPEG:
+ enum fz_colorspace_type ctype = fz_colorspace_type(ctx, image->colorspace);
+ if (ctype != FZ_COLORSPACE_RGB && ctype != FZ_COLORSPACE_GRAY)
+ type = FZ_IMAGE_UNKNOWN;
+ }
+
+ if (type == FZ_IMAGE_JPEG)
{
unsigned char *data;
size_t len = fz_buffer_storage(ctx, cbuf->buffer, &data);
- fz_snprintf(buf, sizeof(buf), "img-%04d", num);
writejpeg(ctx, data, len, buf);
break;
}
- default:
+ else
+ {
pix = fz_get_pixmap_from_image(ctx, image, NULL, NULL, 0, 0);
writepixmap(ctx, pix, buf, dorgb);
}