Sharpen PDF file
-
- Posts: 8
- Joined: 2017-09-12T07:00:23-07:00
- Authentication code: 1151
Sharpen PDF file
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!
Thanks in advance!
Re: Sharpen PDF file
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.
If you want to save it as a jpg, png etc. Imagemagick can do that.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Sharpen PDF file
First, you can extract the raster images with pdfimages. Then sharpen those with IM and, if you want, put those in a PDF file.brighthero wrote:I have a PDF file with multiple pages only containing scanned images.
snibgo's IM pages: im.snibgo.com
-
- Posts: 8
- Joined: 2017-09-12T07:00:23-07:00
- Authentication code: 1151
Re: Sharpen PDF file
Why woudn't "convert -density 300" work just the same way?
Re: Sharpen PDF file
What does this mean?Why woudn't "convert -density 300" work just the same way?
Did you read what snibgo and I said about raster files?
-
- Posts: 8
- Joined: 2017-09-12T07:00:23-07:00
- Authentication code: 1151
Re: Sharpen PDF file
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.
This command seems to be doing the same thing, or am I mistaken? It seems to use Ghostscript under the hood.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Sharpen PDF file
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.
-
- Posts: 8
- Joined: 2017-09-12T07:00:23-07:00
- Authentication code: 1151
Re: Sharpen PDF file
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.
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.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Sharpen PDF file
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
Be sure your viewer is showing the result at a good density/resolution.
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
-
- Posts: 8
- Joined: 2017-09-12T07:00:23-07:00
- Authentication code: 1151
Re: Sharpen PDF file
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?
What's the best way to get back to much smaller file sizes?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Sharpen PDF file
Does this help?
Code: Select all
convert -density 150 "ImageMagick Example.pdf" -resize 50% -unsharp 0x1 test2.pdf
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Sharpen PDF file
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.
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.
snibgo's IM pages: im.snibgo.com
-
- Posts: 8
- Joined: 2017-09-12T07:00:23-07:00
- Authentication code: 1151
Re: Sharpen PDF file
What parameters do I have to modify to make the sharpening even more intense?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
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Sharpen PDF file
See http://www.imagemagick.org/script/comma ... hp#unsharp . Use a larger gain, eg 1.5 or 5.0 or 20.
snibgo's IM pages: im.snibgo.com