View Full Version : yet another cropping tool


moggie
01-10-2009, 04:05 PM
I recently sent kovid a set of patches which implemented a cropping tool for pdf's for the command line. It was released in yesterdays version Version 0.4.127. Basically you can use it to reduce the page by a set amount or use the output of ghostscript to automatically crop pages.

The usage is :

pdftrim --help
Usage: pdftrim.py [options] file.pdf

Crops a pdf.


Whenever you pass arguments to pdftrim.py that have spaces in them, enclose the arguments in quotation marks.

Options:
--version show program's version number and exit

-h, --help show this help message and exit

--verbose Be verbose, useful for debugging. Can be specified
multiple times for greater verbosity.

-o OUTPUT, --output=OUTPUT
Path to output file. By default a file is created in
the current directory.

-x BOTTOM_LEFT_X, --leftx=BOTTOM_LEFT_X
Number of pixels to crop from the left most x (default
is 10)

-y BOTTOM_LEFT_Y, --lefty=BOTTOM_LEFT_Y
Number of pixels to crop from the left most y (default
is 10)

-v TOP_RIGHT_X, --rightx=TOP_RIGHT_X
Number of pixels to crop from the right most x
(default is 10)

-w TOP_RIGHT_Y, --righty=TOP_RIGHT_Y
Number of pixels to crop from the right most y
(default is 10)

-b BOUNDING, --bounding=BOUNDING
A file generated by ghostscript which allows each page
to be individually cropped [gs -dSAFER -dNOPAUSE
-dBATCH -sDEVICE=bbox > bounding]



Like all of calibre it is free under the gpl. As its part of calibre its not going to get horribly complicated but I hope it will be usefull

alexxxm
01-14-2009, 07:13 AM
Thank you for your useful tool, it arrives at the right time - I need to trim out a "slice" from each page of a book I scanned.

I got the tool from the latest calibre install, so I don't know if the problem comes from the tool itself or from calibre, anyway here is the output:

> pdftrim -x 100 "Marazzini - La rilegatura artigianale e d'arte.pdf"

Traceback (most recent call last):
File "/usr/bin/pdftrim", line 8, in <module>
load_entry_point('calibre==0.4.127', 'console_scripts', 'pdftrim')()
File "build/bdist.linux-i686/egg/calibre/ebooks/pdf/pdftrim.py", line 56, in main
AttributeError: 'NoneType' object has no attribute 'title'


not knowing python, it's hard for me to decode the error...

thanks for any help!

alessandro

moggie
01-14-2009, 01:07 PM
Thank you for your useful tool, it arrives at the right time - I need to trim out a "slice" from each page of a book I scanned.

I got the tool from the latest calibre install, so I don't know if the problem comes from the tool itself or from calibre, anyway here is the output:

> pdftrim -x 100 "Marazzini - La rilegatura artigianale e d'arte.pdf"

not knowing python, it's hard for me to decode the error...

thanks for any help!

I have logged a ticket

alessandro

I know what the problem is, so I will send a patch to kovid tonight and knowing him it will be out in the next patch.

If you can set a title and author on the source pdf that will probably fix the problem now.


http://calibre.kovidgoyal.net/ticket/1617

moggie
01-14-2009, 04:10 PM
I know what the problem is, so I will send a patch to kovid tonight and knowing him it will be out in the next patch.

If you can set a title and author on the source pdf that will probably fix the problem now.

http://calibre.kovidgoyal.net/ticket/1617

I think I have fixed it in the next release, as kovid has commited the patch. If you want me to test it, attach the file to this thread.

alexxxm
01-16-2009, 04:42 AM
Thank you a lot,
it works flawlessly now.

Alessandro