Mobile app version of vmapp.org
Login or Join
Lee3735518

: Add padding to multiple images 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

@Lee3735518

Posted in: #Gimp #Resize

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?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Lee3735518

1 Comments

Sorted by latest first Latest Oldest Best

 

@Sent7350415

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 "")
)
)
)
)

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme