The command line option trim
used together with convert
, or mogrify
lets you trim borders of the identical color as the corners of an image.
Usage:
convert input.png -trim output.png
The additional options -fuzz
(which takes a percentage as an argument, e.g. -fuzz 10%
) also removes colors near the corner colors. Use the option +repage
to remove a canvas (if applicable).
ImageMagick Batch Trim (find)
Above command for ImageMagick Trim can also be used to batch processing images while combined with find
command:
find ./ -name "pattern" -exec convert {} -trim outputfolder/{} \;
will trim all images that fits pattern
part of command and save them in new folder named outputfolder
.
Assuming that images are PNGs, then command will look like this:
find ./ -name "*.png" -exec convert {} -trim outputfolder/{} \;
ImageMagick Batch Trim (mogrify)
While find
allows for much greater control where output files will be placed, it is also possible to do the same with ImageMagick's mogrify
:
mogrify -trim *.png
and if you want to crop colors near the corner colors (adjust the percentage based on the results you are observing):
mogrify -trim -fuzz 10% *.png
Please note that unlike convert
and batch operation with find
and convert
mogrify overwrites all files. To keep the originals use the -path
option or do a backup copy of all images in the directory before proceeding with mogrify command.
Side note: mogrify
can be used to execute most (if not all) convert
operations in batch, while overwriting original files.
As Trevor noted in the comments, you can -path option to output converted files to a new directory without overwriting original files:
mogrify -trim -path trimmed_folder/ *.png
IrfanView
IrfanView runs quite nicely with Wine. Be sure to check the output of Irfanview carefully, as it sometimes breaks images when used with Wine.
I had time to have a go at @Rinzwind's mentioned ooopy
- to install it, download the latest version from here, then extract it and run the setup.py
as mentioned here - or just run these commands to install the currently latest version 1.11:
wget http://downloads.sourceforge.net/project/ooopy/ooopy/1.11/OOoPy-1.11.tar.gz
tar -xf OOoPy-1.11.tar.gz
cd OOoPy-1.11/
sudo python ./setup.py install
You can then use it like this:
ooo_cat file1.odt file2.odt file3.odt > file123.odt
this may also work:
ooo_cat file1.odt file2.odt file3.odt -o file123.odt
I have only tried it with three ODTs with small amounts of text.
Best Answer
generalizing from an answer answer from this forum:
or
where
0x8
definesradiusxsigma
from the imagemagick documentation: