Bug 45727 - ppftoppm/pdftocairo should have option for custom JPEG compression
Summary: ppftoppm/pdftocairo should have option for custom JPEG compression
Status: RESOLVED FIXED
Alias: None
Product: poppler
Classification: Unclassified
Component: utils (show other bugs)
Version: unspecified
Hardware: Other All
: medium enhancement
Assignee: poppler-bugs
QA Contact:
URL:
Whiteboard:
Keywords:
: 46659 (view as bug list)
Depends on:
Blocks:
 
Reported: 2012-02-06 21:34 UTC by Jorge Hernández Valiñani
Modified: 2017-08-16 21:32 UTC (History)
2 users (show)

See Also:
i915 platform:
i915 features:


Attachments
pdftocairo: add -jpegopt option (6.33 KB, patch)
2017-07-15 12:01 UTC, Adrian Johnson
Details | Splinter Review
pdftocairo: add -jpegopt option (6.32 KB, patch)
2017-07-16 02:55 UTC, Adrian Johnson
Details | Splinter Review
pdftoppm: add -jpegopt option (6.68 KB, patch)
2017-07-16 02:56 UTC, Adrian Johnson
Details | Splinter Review
pdftoppm: add -jpegopt option v2 (9.68 KB, patch)
2017-08-16 11:15 UTC, Adrian Johnson
Details | Splinter Review

Description Jorge Hernández Valiñani 2012-02-06 21:34:56 UTC
The JPEG compression level of ppftoppm/pdftocairo when using the option -jpeg is pretty severe.

Please, add an option to set the jpg compression level, just as there is one for -tiff.

Tried using
pdftoppm version 0.18.2
poppler @0.18.2 (graphics) (Macports)
Comment 1 Adrian Johnson 2012-02-27 00:36:05 UTC
*** Bug 46659 has been marked as a duplicate of this bug. ***
Comment 2 Denny Reeh 2013-01-21 22:36:31 UTC
i'm using pdftoppm version 0.22.0

are there any news related to the jpg output quality?
Comment 3 Vela 2017-07-12 18:39:12 UTC
Hi! I am using pdftoppm version 0.55.0:
pdftoppm version 0.55.0
Copyright 2005-2017 The Poppler Developers - http://poppler.freedesktop.org
Copyright 1996-2011 Glyph & Cog, LLC

Are there any updates related to this?
Comment 4 Adrian Johnson 2017-07-15 12:01:51 UTC
Created attachment 132698 [details] [review]
pdftocairo: add -jpegopt option

This patch adds support to pdftocairo for setting jpeg compression parameters. I've followed the same pattern as for the -printopt option to allow easily adding more compression parameters if required. Currently only the "quality" and "progressive" parameters are supported by this patch.

If this looks good and can add the same support to pdftoppm.
Comment 5 Adrian Johnson 2017-07-16 02:55:55 UTC
Created attachment 132701 [details] [review]
pdftocairo: add -jpegopt option

fix typo
Comment 6 Adrian Johnson 2017-07-16 02:56:58 UTC
Created attachment 132702 [details] [review]
pdftoppm: add -jpegopt option

Add jpeg compression control to pdftoppm
Comment 7 Albert Astals Cid 2017-07-31 12:30:13 UTC
Not enterily happy about saving the jpeg data in the SplashBitmap, maybe we can pass them in the writeImgFile function as optional parameters? It's not awesome etiher but at least the uglyness is more concentrated in just one function :D

What do you think?
Comment 8 Adrian Johnson 2017-08-15 11:32:57 UTC
I don't like to keep adding parameters to a function where only a subset of the parameters are used for each call. We already have the tiff compression parameter and more parameters may be added in future.

Alternatively how about we use a struct for all optional parameters. eg

struct WriteImgParams
{
  int jpegQuality = -1;
  GBool jpegProgressive = gFalse;
  GooString tiffCompression;
};

SplashError writeImgFile(SplashImageFileFormat format, char *fileName, int hDPI, int vDPI, const WriteImgParams& params);
Comment 9 Albert Astals Cid 2017-08-15 18:11:02 UTC
(In reply to Adrian Johnson from comment #8)
> I don't like to keep adding parameters to a function where only a subset of
> the parameters are used for each call. We already have the tiff compression
> parameter and more parameters may be added in future.
> 
> Alternatively how about we use a struct for all optional parameters. eg
> 
> struct WriteImgParams
> {
>   int jpegQuality = -1;
>   GBool jpegProgressive = gFalse;
>   GooString tiffCompression;
> };
> 
> SplashError writeImgFile(SplashImageFileFormat format, char *fileName, int
> hDPI, int vDPI, const WriteImgParams& params);

That works for me.
Comment 10 Adrian Johnson 2017-08-16 11:15:33 UTC
Created attachment 133544 [details] [review]
pdftoppm: add -jpegopt option v2
Comment 11 Albert Astals Cid 2017-08-16 21:24:10 UTC
this looks better, i don't see anything that would break.

Maybe change the NULL to nullptr?
Comment 12 Adrian Johnson 2017-08-16 21:32:04 UTC
Changed NULL to nullptr and pushed.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.