diff options
author | Ken Sharp <ken.sharp@artifex.com> | 2011-02-18 11:32:07 +0000 |
---|---|---|
committer | Ken Sharp <ken.sharp@artifex.com> | 2011-02-18 11:32:07 +0000 |
commit | 10bd675befeca3855f2862a362dae22218d2aa38 (patch) | |
tree | 54121d5e48b7b52da5775c248557d222f73d570f | |
parent | fdf72273089e7c311aea9037237269ec1a6864d5 (diff) |
enhancement (pdfwrite) : Allow duplication image detection to be disabled
pdfwrite tests every (non-inline) image against every other stored image to see if it is
a duplicate, and if so does not embed the duplicate in the output but simply references
the original.
This can be slow for files with many images (each stored image must be checked when a
new image is encountered) and may be of limited benefit.
The new flag DetectDuplicateImages (default true) can be used to enable or disable
this behaviour
No differences expected
git-svn-id: http://svn.ghostscript.com/ghostscript/trunk@12170 a1074d23-0009-0410-80fe-cf8c14f379e6
-rw-r--r-- | gs/base/gdevpdfb.h | 3 | ||||
-rw-r--r-- | gs/base/gdevpdfj.c | 10 | ||||
-rw-r--r-- | gs/base/gdevpdfp.c | 1 | ||||
-rw-r--r-- | gs/base/gdevpdfx.h | 1 | ||||
-rw-r--r-- | gs/doc/Ps2pdf.htm | 3 |
5 files changed, 14 insertions, 4 deletions
diff --git a/gs/base/gdevpdfb.h b/gs/base/gdevpdfb.h index 2049c37b7..061969231 100644 --- a/gs/base/gdevpdfb.h +++ b/gs/base/gdevpdfb.h @@ -253,6 +253,7 @@ const gx_device_pdf PDF_DEVICE_IDENT = 0, /* DoNumCopies */ true, /* PreserveSeparation */ true, /* PreserveDeviceN */ - 0 /* PDFACompatibilityPolicy */ + 0, /* PDFACompatibilityPolicy */ + true /* DetectDuplicateImages */ }; diff --git a/gs/base/gdevpdfj.c b/gs/base/gdevpdfj.c index 7d0cefde3..2e970e20f 100644 --- a/gs/base/gdevpdfj.c +++ b/gs/base/gdevpdfj.c @@ -515,9 +515,13 @@ pdf_end_write_image(gx_device_pdf * pdev, pdf_image_writer * piw) *(cos_object_t *)named = *pco; pres->object = COS_OBJECT(named); } else if (!pres->named) { /* named objects are written at the end */ - code = pdf_substitute_resource(pdev, &piw->pres, resourceXObject, NULL, false); - if (code < 0) - return code; + if (pdev->DetectDuplicateImages) { + code = pdf_substitute_resource(pdev, &piw->pres, resourceXObject, NULL, false); + if (code < 0) + return code; + } else { + pdf_reserve_object_id(pdev, piw->pres, gs_no_id); + } /* Warning : If the substituted image used alternate streams, its space in the pdev->streams.strm file won't be released. */ piw->pres->where_used |= pdev->used_mask; diff --git a/gs/base/gdevpdfp.c b/gs/base/gdevpdfp.c index 4bb825367..4b2e9771a 100644 --- a/gs/base/gdevpdfp.c +++ b/gs/base/gdevpdfp.c @@ -114,6 +114,7 @@ static const gs_param_item_t pdf_param_items[] = { pi("PreserveSeparation", gs_param_type_bool, PreserveSeparation), pi("PreserveDeviceN", gs_param_type_bool, PreserveDeviceN), pi("PDFACompatibilityPolicy", gs_param_type_int, PDFACompatibilityPolicy), + pi("DetectDuplicateImages", gs_param_type_bool, DetectDuplicateImages), #undef pi gs_param_item_end }; diff --git a/gs/base/gdevpdfx.h b/gs/base/gdevpdfx.h index 96113ca93..a2752ded5 100644 --- a/gs/base/gdevpdfx.h +++ b/gs/base/gdevpdfx.h @@ -697,6 +697,7 @@ struct gx_device_pdf_s { bool PreserveSeparation; bool PreserveDeviceN; int PDFACompatibilityPolicy; + bool DetectDuplicateImages; }; #define is_in_page(pdev)\ diff --git a/gs/doc/Ps2pdf.htm b/gs/doc/Ps2pdf.htm index 17a1cc944..b99db0efd 100644 --- a/gs/doc/Ps2pdf.htm +++ b/gs/doc/Ps2pdf.htm @@ -256,6 +256,9 @@ original colour space will be used instead. <dt><code>-dPreserveDeviceN</code> <dd>Behaves as per PreserveSeparation above except that it deals with DeviceN colour spaces. + +<dt><code>-dDetectDuplicateImages</code> +<dd> Takes a Boolean argument, when set to true (the default) pdfwrite will compare all new images with all the images encountered to date (NOT small images which are stored in-line) to see if the new image is a duplicate of an earlier one. If it is a duplicate then instead of writing a new image into the PDF file, the PDF will reuse the reference to the earlier image. This can considerably reduce the size of the output PDF file, but increases the time taken to process the file. This time grows exponentially as more images are added, and on large input files with numerous images can be prohibitively slow. Setting this to false will improve performance at the cost of final file size. </dl> <p> |