mbaeuerle / Briss-2.0

Briss 2.0 is intended to be a GUI Update for the Briss PDF cropping tool.
GNU General Public License v3.0
484 stars 48 forks source link

Save some cropping settings to use in command line #74

Open Hudsone opened 1 year ago

Hudsone commented 1 year ago

Hello, I have been using this tool to batch cropping some ebay labels. However, because of the recent changes from ebay, Briss failed to detect correct regions and my batch command can never work now.

It would be good to have a custom region setting and use it in each batching job.

The command may be something as:

briss -s some.pdf -d cropped.pdf -c config.txt

Thanks.

Hudsone commented 1 year ago

By the way, after some researches, I found that the original auto cropping algorithm uses standard deviations to detect the region border.

It's useful to remove noises for the scanned documents. However, it also easily gets incorrect result for well outputted documents.

I tried to implement a way to use absolute thresholds to detect the borders and it works well for my condition. Relative easy. If anyone also needs this function, maybe we can create a pull request for it. 👍

jos-eph commented 1 year ago

@Hudsone I have implemented this feature to do PDF crops via the command line in a fork, https://github.com/jos-eph/Briss-2.0-command-line-crop . My first attempt at open source contribution. The readme isn't updated, but you can see the operation from the source. A command like

java -jar ./build/libs/briss-command-crop.jar -s /Users/me/Downloads/cropthis.pdf -d $HOME/Desktop/testcrop.pdf --odd-rects 147.0,154.0,460.0,643.0 --even-rects 148.0,301.0,458.0,643.0 . You can also use the --rects option if the cropping for odds and evens is identical. If you want to leave some pages out, use the --exclude-pages option with a comma-separated list of page numbers (e.g., 4,5,10). Ranges are currently not supported for the CLI.

If you run a Crop or a Preview from the GUI, it will output the command-line options that you can use to replicate the crop to the console.

Note that Briss supports cropping multiple regions on a single page, but the feature I wrote simplifies this down to one big region per page. There's also no option for rects for the exclude-pages.

cc: @cleydyr , @mbaeuerle

Hudsone commented 1 year ago

Oops, cool. It would be quite useful! I think a single region should be enough for most cases lol.