View Single Post
Old 07-13-2009, 12:07 PM   #1
frediz began at the beginning.
Posts: 14
Karma: 10
Join Date: Mar 2009
Device: prs 505
Smile New tool : Comic Processing Utility


a few month ago I spent much time trying different tools to convert
comics so that I can read them on my prs505.
I especially liked pdflrf and papercrop.
I also lost much time testing many other tools that read some format
and not others, that output some formats and not others, which
makes converting a real pain.
Pdflrf had licensing issues, we don't have the sources and it seems not
developed anymore. It was nice though because it has simple but usefull
and efficient features.
Papercrop is nice too and has very smart algorithms that I tweaked and
I used it for comics but in a
way it introduces too much intelligence in the process so that sometimes
you can't process a whole comic at once without checking each page etc and you can not change settings for particular pages etc
It's also connected to a gui which is not what I prefer and needs work to run on linux.
I got a bit bored and tried to code something on my own.
My idea was to write something :
- not dependant on ereaders formats, try to separate this notion, I didn't want
to produce lrf, pdf etc. This is the job of other softwares that will do it
far better than what I would. So the tool should work on simple jpg
- without gui, because ergonomy is another job I didn't want to work on ;)
and I like command line tools for batch, for power focus on the job
not on gui, buttons etc I like to separate things. I try to focus on the engine not on other things, it could be connected to a gui later on I guess,
if I extract the code in a library
- short and simple to understand, use and maintain even if it's not super fast to
process pictures : I usually don't convert thousand of comics at once.
- multiplatform
- opensource ? :)

So I coded what I called CPU : Comic Processing Utility
I wanted to work more on it but didn't have time too and before I
completely forget it on my hard drive I wanted to contribute it here, in
case someone find it useful.
Here is the help from cpu -h :
Usage: cpu [options] pictures

cpu 0.1 - Comic Processing Utility by frediz

cpu takes a list of pictures and process them through a list of filters that
are applied one after the other on the picture list. Some filters can produce
one picture from several successive pictures or produce several pictures from
one, in both case, inserting them in the list at the place of the source ones.
Often a filter just modifies an picture and outputs a single picture.

Example :

cpu -o output -f mhs,autocrop,grayscale orig01.jpg orig02.jpg orig03.jpg

original : [ o1.jpg o2.jpg o3.jpg ]
mhs : [ m1_1.jpg m1_2.jpg m2_1.jpg m3_1.jpg m3_2.jpg m0_3.jpg ]
autocrop : [ a1_1.jpg a1_2.jpg a2_1.jpg a3_1.jpg a3_2.jpg a3_3.jpg ]
grayscale : [ g1_1.jpg g1_2.jpg g2_1.jpg g3_1.jpg g3_2.jpg g3_3.jpg ]

mhs filter autosplits a picture at horizontal lines.
m1_1.jpg m1_2.jpg are outputed from o1.jpg after splitting it.
Here o2 won't be split and o3 will be in 3 sub-pictures.
autocrop and grayscale filters output a single picture both.
a1_1.jpg being outputed from m1_1.jpg after this one has been autocropped
and a1_2.jpg from m1_2.jpg etc...

The finale result will be output001.jpg, output002.jpg... output006.jpg

-h, --help show this help message and exit
-f FILTERS, --filters=FILTERS
List of filters to apply on pictures: FILTER=<filter1[
=parameter1:parameter2:...],filter2,...> where filterN
can be one of : autocrop|a, autocontrast|c,
equalize|e, fitpage|f, gather, grayscale|g, sharpen|h,
align|l, rotate|r, mhsplit|mhs, splitpages|s,
transpose|t. Use filterN=h|help to get more details on
the filter and its parameters
Output prefix for output files
-i, --infos Show infos
-v, --version Show version

At the moment I only provide a .exe file but I'll provide the source code
as soon as I have clean some stuff and choose a license for it. None
were injured in making this :)
I wrote a small .bat file so that you can drag and drop images onto it and
have cpu process your files.

The main features atm are autocrop, autocontrast, equalize, fitpage, gather, grayscale, sharpen, align, rotate, mhsplit, splitpages, transpose.
Most a self explanatory.
I advise to use : cpu -f FILTER=help to get full help on each.
I don't remember my best combinations :) but you can do stuff like :
autosplitting each page horizontally, in multiple pictures, autocrop them, autorotate them is the scan was not aligned, gather them if many fit on
the screen display, put them in grayscale, rotate them to read in landscape.
All these filters can be combined they will be applied on your list of
pictures, these list will evolve after each filter is applied, it can grow and
diminish if subimages are generated and others are gathered.
It's hard to find good settings so that a whole comic is processed as
you want it but I tried to make many parameters available to tweak each filter.
The output will be all the pictures generated after all filters have been applied in the order found on the command line.
Then you just need to transform all of them in you preferred format.
I wrote a very simple lrf maker with no processing at all for this (processing is the job of CPU in my mind) and I'll release it too.

CPU should have bugs I guess, but I used it already a few times, and it
should work at least a bit :) . I don't know if I'll have time to fix things you might
find, but will try and source code will be here for that too.

Here is v0.1 :
frediz is offline   Reply With Quote