Re: [poppler] [PATCH] Add -jpegopt optimize option support to utils

2018-07-20 Thread Martin (gzlist)
On 20 July 2018 at 22:43, Albert Astals Cid  wrote:
>
> Pushed, I removed the changes to the man pages that were not related to this 
> specific change, we can discuss them in a different thread if you think makes 
> sense (I kind of agree your definition of progressive was probably better, 
> but I didn't want to have "unrelated" changes in the commit)

Thanks! Yes, fair enough, probably better to do a pass over the
manpage wording as a separate change.

Martin
___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler


Re: [poppler] [PATCH] Add -jpegopt optimize option support to utils

2018-07-20 Thread Albert Astals Cid
El dimecres, 4 de juliol de 2018, a les 20:07:10 CEST, Martin (gzlist) va 
escriure:
> On 24 June 2018 at 23:12, Martin (gzlist)  wrote:
> >
> > I've changed the print ones in pdftocairo, see amended patch also with
> > other wording tweaks attached.
> 
> Is there anything else I can do to help you review this patch?
> 
> Am happy to do another pass over the documentation as a separate
> change if that would help.

Pushed, I removed the changes to the man pages that were not related to this 
specific change, we can discuss them in a different thread if you think makes 
sense (I kind of agree your definition of progressive was probably better, but 
I didn't want to have "unrelated" changes in the commit)

Cheers,
  Albert

> 
> Martin
> ___
> poppler mailing list
> poppler@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/poppler
> 




___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler


Re: [poppler] [PATCH] Add -jpegopt optimize option support to utils

2018-07-04 Thread Martin (gzlist)
On 24 June 2018 at 23:12, Martin (gzlist)  wrote:
>
> I've changed the print ones in pdftocairo, see amended patch also with
> other wording tweaks attached.

Is there anything else I can do to help you review this patch?

Am happy to do another pass over the documentation as a separate
change if that would help.

Martin
___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler


Re: [poppler] [PATCH] Add -jpegopt optimize option support to utils

2018-06-24 Thread Martin (gzlist)
On 24/06/2018, Albert Astals Cid  wrote:
>
> Not an English native speaker myself, but are you sure of the
> Selects vs Select change?

Struggling to find a documentation style guide that actually states
it, but think in general imperative is preferred over simple present.
See for instance `man grep` -w and -x (and in fact the whole file).
The pdftoppm man page is not consistent, both tenses are used, compare
-x/-y -opw/-upw or -png -jpeg.

> So if Select is the correct one should we change that one too?

Probably. I don't want to rewrite the whole manpage as part of this
change, it seems unrelated.

I've changed the print ones in pdftocairo, see amended patch also with
other wording tweaks attached.

Martin
Add -jpegopt optimize option support to utils

New option 'optimize=y' for utils that take a -jpegopt param,
pdftocairo and pdftoppm. This corresponds to the cjpeg -optimize
flag, and slightly reduces the size of the output jpeg but uses
additional cpu and memory.

New jpegOptimize boolean in splash/SplashBitmap WriteImgParams.

New setOptimize method on goo/JpegWriter taking a boolean.

Update manpages for new option.

Signed-off-by: Martin Packman 
---
 goo/JpegWriter.cc  | 11 +++
 goo/JpegWriter.h   |  1 +
 splash/SplashBitmap.cc |  1 +
 splash/SplashBitmap.h  |  1 +
 utils/pdftocairo.1 | 17 -
 utils/pdftocairo.cc| 10 ++
 utils/pdftoppm.1   | 13 ++---
 utils/pdftoppm.cc  | 10 ++
 8 files changed, 56 insertions(+), 8 deletions(-)

diff --git a/goo/JpegWriter.cc b/goo/JpegWriter.cc
index 37c15c2a..9ac9b63b 100644
--- a/goo/JpegWriter.cc
+++ b/goo/JpegWriter.cc
@@ -25,6 +25,7 @@ extern "C" {
 
 struct JpegWriterPrivate {
   bool progressive;
+  bool optimize;
   int quality;
   JpegWriter::Format format;
   struct jpeg_compress_struct cinfo;
@@ -46,6 +47,7 @@ JpegWriter::JpegWriter(int q, bool p, Format formatA)
 {
   priv = new JpegWriterPrivate;
   priv->progressive = p;
+  priv->optimize = false;
   priv->quality = q;
   priv->format = formatA;
 }
@@ -54,6 +56,7 @@ JpegWriter::JpegWriter(Format formatA)
 {
   priv = new JpegWriterPrivate;
   priv->progressive = false;
+  priv->optimize = false;
   priv->quality = -1;
   priv->format = formatA;
 }
@@ -75,6 +78,11 @@ void JpegWriter::setProgressive(bool progressive)
   priv->progressive = progressive;
 }
 
+void JpegWriter::setOptimize(bool optimize)
+{
+  priv->optimize = optimize;
+}
+
 bool JpegWriter::init(FILE *f, int width, int height, int hDPI, int vDPI)
 {
   // Setup error handler
@@ -137,6 +145,9 @@ bool JpegWriter::init(FILE *f, int width, int height, int hDPI, int vDPI)
 jpeg_simple_progression(>cinfo);
   }
 
+  // Set whether to compute optimal Huffman coding tables
+  priv->cinfo.optimize_coding = priv->optimize;
+
   // Get ready for data
   jpeg_start_compress(>cinfo, TRUE);
 
diff --git a/goo/JpegWriter.h b/goo/JpegWriter.h
index 9a68bcc9..bb87b949 100644
--- a/goo/JpegWriter.h
+++ b/goo/JpegWriter.h
@@ -41,6 +41,7 @@ public:
 
   void setQuality(int quality);
   void setProgressive(bool progressive);
+  void setOptimize(bool optimize);
   bool init(FILE *f, int width, int height, int hDPI, int vDPI) override;
 
   bool writePointers(unsigned char **rowPointers, int rowCount) override;
diff --git a/splash/SplashBitmap.cc b/splash/SplashBitmap.cc
index 2bec9f93..6f5e4cf8 100644
--- a/splash/SplashBitmap.cc
+++ b/splash/SplashBitmap.cc
@@ -356,6 +356,7 @@ void SplashBitmap::setJpegParams(ImgWriter *writer, WriteImgParams* params)
 #ifdef ENABLE_LIBJPEG
   if (params) {
 static_cast(writer)->setProgressive(params->jpegProgressive);
+static_cast(writer)->setOptimize(params->jpegOptimize);
 if (params->jpegQuality >= 0)
   static_cast(writer)->setQuality(params->jpegQuality);
   }
diff --git a/splash/SplashBitmap.h b/splash/SplashBitmap.h
index 092bd4cf..9756164f 100644
--- a/splash/SplashBitmap.h
+++ b/splash/SplashBitmap.h
@@ -81,6 +81,7 @@ public:
 int jpegQuality = -1;
 GBool jpegProgressive = gFalse;
 GooString tiffCompression;
+GBool jpegOptimize = gFalse;
   };
 
   SplashError writeImgFile(SplashImageFileFormat format, char *fileName, int hDPI, int vDPI, WriteImgParams* params = nullptr);
diff --git a/utils/pdftocairo.1 b/utils/pdftocairo.1
index 3a60b73e..6be3c410 100644
--- a/utils/pdftocairo.1
+++ b/utils/pdftocairo.1
@@ -305,21 +305,28 @@ When JPEG output is specified, the \-jpegopt option can be used to control the J
 It takes a string of the form "=[,=]". Currently the available options are:
 .TP
 .BI quality
-Selects the JPEG quality value. The value must be an integer between 0 and 100.
+Select the JPEG quality. The value must be an integer between 0 and 100.
 .TP
 .BI progressive
-Select progressive JPEG output. The possible values are "y", "n",
-indicating progressive (yes) or non-progressive (no), respectively.
+Select whether to write the JPEG as multiple scans of increasing quality. The
+value must be "y" or 

Re: [poppler] [PATCH] Add -jpegopt optimize option support to utils

2018-06-24 Thread Albert Astals Cid
El dijous, 14 de juny de 2018, a les 0:27:32 CEST, Martin (gzlist) va 
escriure:
> On 13/06/2018, Albert Astals Cid  wrote:
> > You probably need to update the manpages of both utils to include that?
> 
> Done, see amended patch attached. Also updated the wording of the
> other options a little, with reference to the jpeg-turbo documentation
> on the options.
> 
> I note the copyright on AUTHOR below seems a little outdated, but left
> that alone.

Not an English native speaker myself, but are you sure of the 
Selects vs Select change?

Also below we have
   .BI source
  Selects the source paper ...

So if Select is the correct one should we change that one too?

Cheers,
  Albert

> 
> Martin




___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler


Re: [poppler] [PATCH] Add -jpegopt optimize option support to utils

2018-06-13 Thread Martin (gzlist)
On 13/06/2018, Albert Astals Cid  wrote:
> You probably need to update the manpages of both utils to include that?

Done, see amended patch attached. Also updated the wording of the
other options a little, with reference to the jpeg-turbo documentation
on the options.

I note the copyright on AUTHOR below seems a little outdated, but left
that alone.

Martin
diff --git a/goo/JpegWriter.cc b/goo/JpegWriter.cc
index 37c15c2a..9ac9b63b 100644
--- a/goo/JpegWriter.cc
+++ b/goo/JpegWriter.cc
@@ -25,6 +25,7 @@ extern "C" {
 
 struct JpegWriterPrivate {
   bool progressive;
+  bool optimize;
   int quality;
   JpegWriter::Format format;
   struct jpeg_compress_struct cinfo;
@@ -46,6 +47,7 @@ JpegWriter::JpegWriter(int q, bool p, Format formatA)
 {
   priv = new JpegWriterPrivate;
   priv->progressive = p;
+  priv->optimize = false;
   priv->quality = q;
   priv->format = formatA;
 }
@@ -54,6 +56,7 @@ JpegWriter::JpegWriter(Format formatA)
 {
   priv = new JpegWriterPrivate;
   priv->progressive = false;
+  priv->optimize = false;
   priv->quality = -1;
   priv->format = formatA;
 }
@@ -75,6 +78,11 @@ void JpegWriter::setProgressive(bool progressive)
   priv->progressive = progressive;
 }
 
+void JpegWriter::setOptimize(bool optimize)
+{
+  priv->optimize = optimize;
+}
+
 bool JpegWriter::init(FILE *f, int width, int height, int hDPI, int vDPI)
 {
   // Setup error handler
@@ -137,6 +145,9 @@ bool JpegWriter::init(FILE *f, int width, int height, int hDPI, int vDPI)
 jpeg_simple_progression(>cinfo);
   }
 
+  // Set whether to compute optimal Huffman coding tables
+  priv->cinfo.optimize_coding = priv->optimize;
+
   // Get ready for data
   jpeg_start_compress(>cinfo, TRUE);
 
diff --git a/goo/JpegWriter.h b/goo/JpegWriter.h
index 9a68bcc9..bb87b949 100644
--- a/goo/JpegWriter.h
+++ b/goo/JpegWriter.h
@@ -41,6 +41,7 @@ public:
 
   void setQuality(int quality);
   void setProgressive(bool progressive);
+  void setOptimize(bool optimize);
   bool init(FILE *f, int width, int height, int hDPI, int vDPI) override;
 
   bool writePointers(unsigned char **rowPointers, int rowCount) override;
diff --git a/splash/SplashBitmap.cc b/splash/SplashBitmap.cc
index 2bec9f93..6f5e4cf8 100644
--- a/splash/SplashBitmap.cc
+++ b/splash/SplashBitmap.cc
@@ -356,6 +356,7 @@ void SplashBitmap::setJpegParams(ImgWriter *writer, WriteImgParams* params)
 #ifdef ENABLE_LIBJPEG
   if (params) {
 static_cast(writer)->setProgressive(params->jpegProgressive);
+static_cast(writer)->setOptimize(params->jpegOptimize);
 if (params->jpegQuality >= 0)
   static_cast(writer)->setQuality(params->jpegQuality);
   }
diff --git a/splash/SplashBitmap.h b/splash/SplashBitmap.h
index 092bd4cf..9756164f 100644
--- a/splash/SplashBitmap.h
+++ b/splash/SplashBitmap.h
@@ -81,6 +81,7 @@ public:
 int jpegQuality = -1;
 GBool jpegProgressive = gFalse;
 GooString tiffCompression;
+GBool jpegOptimize = gFalse;
   };
 
   SplashError writeImgFile(SplashImageFileFormat format, char *fileName, int hDPI, int vDPI, WriteImgParams* params = nullptr);
diff --git a/utils/pdftocairo.1 b/utils/pdftocairo.1
index 3a60b73e..4c32f920 100644
--- a/utils/pdftocairo.1
+++ b/utils/pdftocairo.1
@@ -305,11 +305,18 @@ When JPEG output is specified, the \-jpegopt option can be used to control the J
 It takes a string of the form "=[,=]". Currently the available options are:
 .TP
 .BI quality
-Selects the JPEG quality value. The value must be an integer between 0 and 100.
+Select the JPEG quality. The value must be an integer between 0 and 100.
 .TP
 .BI progressive
-Select progressive JPEG output. The possible values are "y", "n",
-indicating progressive (yes) or non-progressive (no), respectively.
+Select whether to write the JPEG as multiple scans of increasing quality. The
+value must be "y" or "n", with "y" indicating a progressive image, otherwise a
+single-scan image is created.
+.TP
+.BI optimize
+Set whether to compute optimal Huffman coding tables for the JPEG output,
+which creates smaller files but requires and extra pass over the data. The
+value must be "y" or "n", with "y" performing optimization, otherwise the
+default Huffman tables are used.
 .SH WINDOWS PRINTER OPTIONS
 In Windows, you can use the \-print option to print directly to a system printer. Additionally, you can use the \-printopt 
 option to configure the printer. It takes a string of the form "=[,=]". Currently the available options are:
diff --git a/utils/pdftocairo.cc b/utils/pdftocairo.cc
index 05ceaa3b..e5e49a19 100644
--- a/utils/pdftocairo.cc
+++ b/utils/pdftocairo.cc
@@ -129,6 +129,7 @@ static GBool printHelp = gFalse;
 static GooString jpegOpt;
 static int jpegQuality = -1;
 static bool jpegProgressive = false;
+static bool jpegOptimize = false;
 
 static GooString printer;
 static GooString printOpt;
@@ -369,6 +370,14 @@ static GBool parseJpegOptions()
 	fprintf(stderr, "jpeg progressive option must be \"y\" or \"n\"\n");
 	return gFalse;
   }
+} else 

Re: [poppler] [PATCH] Add -jpegopt optimize option support to utils

2018-06-13 Thread Albert Astals Cid
You probably need to update the manpages of both utils to include that?

Cheers,
  Albert

El dissabte, 9 de juny de 2018, a les 19:36:47 CEST, Martin (gzlist) va 
escriure:
> New option 'optimize=y' for utils that take a -jpegopt param,
> pdftocairo and pdftoppm. This corresponds to the cjpeg -optimize
> flag, and slightly reduces the size of the output jpeg but uses
> additional cpu and memory.
> 
> New jpegOptimize boolean in splash/SplashBitmap WriteImgParams.
> 
> New setOptimize method on goo/JpegWriter taking a boolean.
> 
> Signed-off-by: Martin Packman 
> ---
>  goo/JpegWriter.cc  | 11 +++
>  goo/JpegWriter.h   |  1 +
>  splash/SplashBitmap.cc |  1 +
>  splash/SplashBitmap.h  |  1 +
>  utils/pdftocairo.cc| 10 ++
>  utils/pdftoppm.cc  | 10 ++
>  6 files changed, 34 insertions(+)




___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler