Page 1 of 1
Sharpen PDF file
Posted: 2017-09-19T12:53:13-07:00
by brighthero
I have a PDF file with multiple pages only containing scanned images. What's the quickest way to sharpen the PDFs using imagemagick? Or do I have to convert the file into images first using another tool?
Thanks in advance!
Re: Sharpen PDF file
Posted: 2017-09-19T12:58:23-07:00
by Bonzo
Imagemagick will convert the pdf to a raster file so if you want to save it to a pdf you may better off using a dedicated pdf program.
If you want to save it as a jpg, png etc. Imagemagick can do that.
Re: Sharpen PDF file
Posted: 2017-09-19T13:01:56-07:00
by snibgo
brighthero wrote:I have a PDF file with multiple pages only containing scanned images.
First, you can extract the raster images with pdfimages. Then sharpen those with IM and, if you want, put those in a PDF file.
Re: Sharpen PDF file
Posted: 2017-09-19T13:02:54-07:00
by brighthero
Why woudn't "convert -density 300" work just the same way?
Re: Sharpen PDF file
Posted: 2017-09-19T13:14:11-07:00
by Bonzo
Why woudn't "convert -density 300" work just the same way?
What does this mean?
Did you read what snibgo and I said about raster files?
Re: Sharpen PDF file
Posted: 2017-09-19T13:15:38-07:00
by brighthero
convert -density 300 input.pdf -sharpen 0x1 output.pdf
This command seems to be doing the same thing, or am I mistaken? It seems to use Ghostscript under the hood.
Re: Sharpen PDF file
Posted: 2017-09-19T14:54:26-07:00
by fmw42
You can get sharper results by increasing the density and then resizing. But saving as PDF will only put a vector shell around the rasterized pdf.
Re: Sharpen PDF file
Posted: 2017-09-20T08:30:55-07:00
by brighthero
Example:
https://drive.google.com/file/d/0B1LWck ... sp=sharing
What would be an example script to do the sharpening the right way using the resizing?
The file size should be about the same as it was before.
Re: Sharpen PDF file
Posted: 2017-09-20T09:26:24-07:00
by fmw42
Your PDF is not simply vector, but is a raster image contained in a vector shell. But PDF files have no size until you provide a density for viewing.
Have you tried either
Code: Select all
convert -density 150 "ImageMagick Example.pdf" test1.pdf
Code: Select all
convert -density 150 "ImageMagick Example.pdf" -unsharp 0x1 test2.pdf
Be sure your viewer is showing the result at a good density/resolution.
Re: Sharpen PDF file
Posted: 2017-09-20T11:04:01-07:00
by brighthero
Wow, that's works great, but now my file sizes are huge.
What's the best way to get back to much smaller file sizes?
Re: Sharpen PDF file
Posted: 2017-09-20T11:48:13-07:00
by fmw42
Does this help?
Code: Select all
convert -density 150 "ImageMagick Example.pdf" -resize 50% -unsharp 0x1 test2.pdf
Re: Sharpen PDF file
Posted: 2017-09-20T11:57:34-07:00
by snibgo
IM commands will rasterize each PDF page at whatever density you decide.
But your PDF file contains two JPEG images, with no vector data. pdfimages can extract the images, as JPEG files, without worrying about density. You can then sharpen these, or do whatever you want.
Re: Sharpen PDF file
Posted: 2017-09-21T07:29:24-07:00
by brighthero
fmw42 wrote: ↑2017-09-20T11:48:13-07:00
Does this help?
Code: Select all
convert -density 150 "ImageMagick Example.pdf" -resize 50% -unsharp 0x1 test2.pdf
What parameters do I have to modify to make the sharpening even more intense?
Re: Sharpen PDF file
Posted: 2017-09-21T09:04:24-07:00
by snibgo