Thread Rating:
  • 2 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
sharpen up a pdf ?
#1
I just downloaded a sewing machine manual pdf and it is very faint.

 Is there some smart little app which will enable gimp to run through all 35 pages of it and automatically raise the contrast or darken up the lines, somehow make it more legible?

I'll attach a sample page


Attached Files
.pdf   elna3003sewingmachine-Page14.pdf (Size: 291.53 KB / Downloads: 395)
Reply
#2
Trying to find something with a GUI and multi-layer provision.

Assuming that the single page PDF is representative of the whole 35 pages. It is an image wrapped up in a PDF, extracting the image (linux pdfimages) it comes out at about 2400 x 1600 pix A reasonable size but otherwise not great quality.

One way: 

1. Import the 35 pages setting the ppi to 300
2. Crop the page down, might save a bit of file size. Make sure 'Delete cropped pixels is ON

   

This using the Gimp g'mic plugin which can adjust all the layers. Get from http://www.gmic.eu

3. In the repair section "Repair Scanned Documents" to clean up the background a little. Set Smoothness = 1 / white level to 100 / black level to 0  Input set to All and Output in place or new image.  Apply that.
4. Another gmic filter in the Details section, Sharpen(deblur)  Just use the default settings and Input = All Output inplace (or new image)

   

Export that to a PDF. Warning Gimp makes big PDF's It is the way the image data is compressed. Nothing you can do about it.
This a comparison in a PDF viewer between the original and the Gimp PDF.

   
Reply
#3
(04-09-2021, 01:17 PM)rich2005 Wrote: Trying to find something with a GUI and multi-layer provision.

Assuming that the single page PDF is representative of the whole 35 pages. It is an image wrapped up in a PDF, extracting the image (linux pdfimages) it comes out at about 2400 x 1600 pix A reasonable size but otherwise not great quality.

One way: 

1. Import the 35 pages setting the ppi to 300
2. Crop the page down, might save a bit of file size. Make sure 'Delete cropped pixels is ON



This using the Gimp g'mic plugin which can adjust all the layers. Get from http://www.gmic.eu

3. In the repair section "Repair Scanned Documents" to clean up the background a little. Set Smoothness = 1 / white level to 100 / black level to 0  Input set to All and Output in place or new image.  Apply that.
4. Another gmic filter in the Details section, Sharpen(deblur)  Just use the default settings and Input = All Output inplace (or new image)



Export that to a PDF. Warning Gimp makes big PDF's It is the way the image data is compressed. Nothing you can do about it.
This a comparison in a PDF viewer between the original and the Gimp PDF.

I've found that using the Erode filter to widen the lines improves the image a lot. Is there a GMIC equivalent?
Reply
#4
(04-09-2021, 04:41 PM)Ofnuts Wrote: I've found that using the Erode filter to widen the lines improves the image a lot. Is there a GMIC equivalent?

Not that I can find. (well there is, one of alfre's but it does not work with multiple layers - produces a black image)
Unless you can provide a bespoke plugin, an alternative for us scripting-deficient mortals is maybe each page as a separate image, then a BIMP batch process. Then assemble the adjusted images into a PDF.

edit: or as I would probably do: use erode manually on each layer, only 35 layers, not a big deal, ctrl-f to repeat last filter.
Reply
#5
(04-09-2021, 04:53 PM)rich2005 Wrote:
(04-09-2021, 04:41 PM)Ofnuts Wrote: I've found that using the Erode filter to widen the lines improves the image a lot. Is there a GMIC equivalent?

Not that I can find. (well there is, one of alfre's but it does not work with multiple layers - produces a black image)
Unless you can provide a bespoke plugin, an alternative for us scripting-deficient mortals is maybe each page as a separate image, then a BIMP batch process. Then assemble the adjusted images into a PDF.

edit: or as I would probably do: use erode manually on each layer, only 35 layers, not a big deal, ctrl-f to repeat last filter.

Can be done a bit more easily in the Python console:

Code:
image=gimp.image_list()[0]
for layer in image.layers: pdb.plug_in_erode(image, layer, 1, 0, 1., 15,0, 255)

Notes:
  • There must be a single image opened in Gimp, otherwise the first line may catch the wrong one
  • After the second line, strike [enter] until you are back to the > > > prompt
  • Don't ask me what the parameters represent Smile
Reply
#6
I've got all 35 into the latest version of gimp.

cropped one. couldn't find how to crop all simultaneously.

I do have a 'batch image manipulation' menu choice there but I was unable to figure out how to use it to do these things.

can I ask for another prompting?
Reply
#7
(04-09-2021, 04:53 PM)rich2005 Wrote:
(04-09-2021, 04:41 PM)Ofnuts Wrote: I've found that using the Erode filter to widen the lines improves the image a lot. Is there a GMIC equivalent?
edit: or as I would probably do: use erode manually on each layer, only 35 layers, not a big deal, ctrl-f to repeat last filter.

Using PgUp/PgDn(*), Ctr-F, 70 keystrokes, so 35 less than entering the Python code...

(*) Using the mouse to switch layers would be very innefficient
Reply
#8
Quote:I've got all 35 into the latest version of gimp. ...cropped one. couldn't find how to crop all simultaneously.

Are the 35 loaded as layers ? If they are, the crop tool will crop the whole image. Make sure the crop tool options Current layer only is OFF and Delete cropped pixels is ON.

Quote:I do have a 'batch image manipulation' menu choice there but I was unable to figure out how to use it to do these things.

You have BIMP plugin? Too much time on my hands today Wink  IMHO it is faster to edit each layer (or image) by hand, however, as an example.

Open the PDF (I found a single PDF for that manual) one way or another, as layers. Make sure ppi is 300.
Crop the image.
Export the cropped image layers as individual images. There are plugins for this, if you do not already have one try Ofnuts plugin https://sourceforge.net/projects/gimp-to...p/download

In BIMP
Open the 35 images. BIMP does not open / save PDF hence the above process.
Add three procedures
1. color correction with brightness about 0.2 and contrast 0.04
2. other gimp procedure - gimp-level-auto
3. other gimp procedure - erode with  settings 1 0 1 15 255 0
Set up an output folder and apply BIMP.

For a new PDF.
Open the corrected images in GIMP 'Open as layers'
Export as a PDF with 'Layers As Pages' enabled

As a video example, 6 minutes of tedium.  https://youtu.be/Y5KAB822M9s





Remember I remarked that Gimp makes big PDF's - This one no different. 33 MB file size. However using LibreOffice and assembling the images in separate pages, got one down to 11 MB.  https://www.dropbox.com/s/u749veg1bz7q7r...l.pdf?dl=0

All it takes is much perseverance and practice.
Reply
#9
(04-10-2021, 01:05 PM)rich2005 Wrote: Remember I remarked that Gimp makes big PDF's - This one no different. 33 MB file size. However using LibreOffice and assembling the images in separate pages, got one down to 11 MB.

Had a similar problem recently, making a PDF from scans (one PDF, 3 JPEGs, around 380K each). Exporting a 4-layers, 150PPI A4 doc to PDF from  Gimp yielded a 5MB PDF.

Using ImageMagick with:

Code:
convert *.jpeg *.pdf Out.pdf

Created a 1.3MB PDF.
Reply


Forum Jump: