0

I scanned a couple pages and edited them a little so the look neat. But as I wanted to reprint them I noticed that I cropped the border from these images so that the printer won't print the whole content.

I'm on Linux and have a Brother printer which has Linux drivers but somehow the scaling option does not work. So I thought to scale the PDF (in which I have converted these scans) but the printer driver scales them back to fit the page. (If I disable the scale-to-fit option it becomes garbage)

So I thought that I could do some script-fu to resize these images with a couple of lines and add some padding for the printer. But I have no clue how to do this.

Here's my first attempt:

(define (resize-image filename-in filename-out )
  (let* ((image    (car (gimp-file-load RUN-NONINTERACTIVE filename-in "")))
         (drawable (car (gimp-image-active-drawable image)))
        )
     (gimp-image-resize image 2728 3819 124 173) 
     (gimp-file-save   RUN-NONINTERACTIVE image drawable filename-out "")
  )
)

This does not work. The image simply remains unchanged.

My page is A4 with 2480x3472, so I thought to add 10% to the width so it becomes 2728x3819 and set the offset to 5% so the content is centered (with offset values 124 and 173).

How do I do this properly? Is GIMP a good method? Are there Linux tools that could do this better?

2
  • Are you sure the problem is with the print driver, or is the problem with the print dialog in GIMP? Do you really need to use GIMP to print the document? Have you tried inserting the image in a word processor document, like in LibreOffice?
    – Billy Kerr
    Commented Jul 20, 2017 at 10:59
  • I converted the imaged into a PDF and printed the PDF using the pdfviewer...
    – Martin B.
    Commented Jul 20, 2017 at 11:30

1 Answer 1

0

I originally asked this over at StackOverflow and someone there helped me.
Let me share with you:

This worked for me:

(define (resize-image filename-in filename-out )
  (let* ((image    (car (gimp-file-load RUN-NONINTERACTIVE filename-in "")))
         (drawable (car (gimp-image-active-drawable image)))
        )
    (gimp-image-resize image 2728 3819 124 173) 

    (let* ((layer (car (gimp-layer-new image 2728 3819 0 "Base" 100 0)))
          )
      (gimp-image-insert-layer image layer 0 1)
      (gimp-drawable-fill layer 2)
      (let* ((newlayer (car (gimp-image-flatten image)))
            )
        (gimp-file-save   RUN-NONINTERACTIVE image newlayer filename-out "")
      )
    )
  )
)
3
  • To explain why the code works: gimp-file-save saves a layer (in the original code this layer remain unchanged when the canavs is resized by the gimp-image-resize). So the code above resize the canvas, add a layer a the bottom, fills it with white, and merge the original layer on it. So now we have a layer that has the new size and the original contents.
    – xenoid
    Commented Aug 18, 2017 at 20:13
  • Martin perhaps you could accept your own answer then? If you're still there?
    – Luciano
    Commented Sep 18, 2017 at 9:11
  • Yeah, sorry. One can't accept the own answer right away, so I forgot about the question...
    – Martin B.
    Commented Sep 18, 2017 at 19:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.