firstlookmedia / pdf-redact-tools

a set of tools to help with securely redacting and stripping metadata from documents before publishing
Other
530 stars 50 forks source link

Add a flag to control quality #13

Open micahflee opened 9 years ago

micahflee commented 9 years ago

Right now when pdf-redact-tools explodes a PDF into PNGs, the PNGs are all medium quality in order to make sure the final redacted PDF doesn't end up too big. However sometimes the quality is too low. It would be good to expose a quality option to users as a command-line flag.

masetime commented 7 years ago

Bingo. I just used pdf-redact-tools for the first time and the quality of the output I got was unusable for my needs.

There really needs to be an option to control the quality level.

anaisabel7 commented 7 years ago

So, I added a flag to specify quality in the PR above, however, I don't know much about image quality or compression. I checked the information is sent to the convert command, but I cannot tell whether it makes the expected difference in the PNG files. Also, please, let me know if I need to set limits to the values of quality (besides them being integers).

Maybe @micahflee @masetime have some idea about this since you were commenting on the quality of the PNGs

chaserx commented 7 years ago

I've currently hit the same thing where the loss of image quality is unacceptable.

Since the -quality flag is about compression, maybe we should use the -density flag to increase the density to -density 300. ImageMagick's default is 72. Here, on line 55, it's being set to 128.

A similar plan to what @anaisabel7 has done in #24 could be applied for density.

chaserx commented 7 years ago

I've found that that using ghostscript directly, you retain pretty good PNG resolution from a PDF.

gs -sDEVICE=png16m -dTextAlphaBits=4 -r300 -o foo.png bar.pdf