GithubHelp home page GithubHelp logo

avalonv / recbz Goto Github PK

View Code? Open in Web Editor NEW
77.0 77.0 6.0 247 KB

Utility for converting and optimizing comics for e-readers & mobile devices

License: GNU General Public License v3.0

Python 100.00%
cbz cli comics compression converter ebooks epub ereader kindle manga zip

recbz's People

Contributors

avalonv avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

recbz's Issues

Support .gif

Obviously no animated gif support, but they're pretty common and it's quite possible some comics use them.

Allow writing AZW3/MOBI

Amazon's "transition" to EPUB in favor of AZW3/MOBI is clever:

First they enforce a proprietary format, in favor of the open standard. MOBI is the child of Mobipocket which they acquired in the 2005. AZW3 is essentially a fancy MOBI. They published scant information over how these formats function internally, expecting you to use Kindle specific tools to generate them, but which have since been deprecated, and you can't read the documentation anymore. Said format falls out of use in favor of EPUB, which works everywhere else. They realize this, switch to it in a haphazard way, and officially deprecate MOBI (it still works, but it might not tomorrow). But the EPUB implementation is so half-assed it requires using the Mail to Kindle service. It almost seems designed to ensure people are gonna continue buying books from their walled garden instead of independent publishers which support it, while avoiding antitrust accusations, because other formats are "technically" supported — and it's doubly clever because it can also shut up people who have been begging them to support it for the past decade.

Complaining about what a evil, shitty monopolistic company they are doesn't change the fact that people still expect to be able to just transfer their files over USB. So it would be nice to support it.

Use EbookLib to read EPUBs

Might be useful as a more reliable way to avoid issues with extra cover pages (eaa2541) and to ensure files are ordered.

Syntax:

book = epub.read_epub('file.epub')
images = book.get_items_of_type(ebooklib.ITEM_IMAGE)

Allow reading from CB7 & CBR files

Writing won't be supported (because RAR is a shitty proprietary format!) but reading should be possible (low priority for now though).

Don't assume that device has height > width

When --size is supplied if image is landscape it is resized not to width x height but to height x width. This losses sense if someone would provide to --size arguments such that width > height.

Rename files only

Some cbz archives has badly named files, which result in wrong order when reading on e-reader.
For example :
1.jpg, 10.jpg, 11.jpg should be renamed as 0001.jpg, 0010.jpg, 0011.jpg.
But without recompressing the files, only by renaming them.

Add a means to concatenate files

Haley requested this, and it would in fact be very useful if you could join two CBZ files, representing a volume or a chapter, into a single one.

Some work would be needed to restructure how the end file is organized, and it might be useful to add each individual section to the table of contents when converting to EPUB.

Investigate dual spread properties on Kobo

The official KEPUB documentation by Ratuken suggests the <meta property="rendition:spread">auto</meta> tag for dual spread (landscape) images.

It might be worth investigating as currently I'm pretty sure images are just stretched and it might look bad.

Fixed layout EPUBs

Add profiles supporting fixed layouts for specific devices, so pages always fill 100% of the screen.

Wish there was a standard, universal way of achieving this :(

To many files open error

I;m getting this error, on mac. i tried diffrent size archives. same error,

Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.11/bin/recbz", line 8, in
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/reCBZ/main.py", line 392, in main
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/shutil.py", line 728, in rmtree
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/shutil.py", line 725, in rmtree
OSError: [Errno 24] Too many open files: '/var/folders/bd/trf4b_ld6xz0xg2nq_00g51r0000gn/T/reCBZCACHE_f82012de722e44459cbd9ec343aef307'

Allow preserving aspect ratio

images are resized to the exact output resolution without keeping their correct aspect ratio. ive attempted to fix this. ive tested with both up- and downscaling and it worked perfectly for me, but please test it for yourself first too. (i commented out the old method)
archive.py starting at line 131:

    # downscaling
    if (width > n_width and height > n_height
        and not options['nodown']):
        #img = img.resize((new_size), config.RESAMPLE_TYPE)
        img.thumbnail((new_size), config.RESAMPLE_TYPE)

    # upscaling
    elif not options['noup']:
        #img = img.resize((new_size), config.RESAMPLE_TYPE)
        width_ratio = (n_width/float(width))
        height_corrected = int((float(height)*float(width_ratio)))
        img = img.resize((n_width,height_corrected), config.RESAMPLE_TYPE)
        if img.size[0] > n_width or img.size[1] > n_height:
            img.thumbnail((new_size), config.RESAMPLE_TYPE)

Support -1 for height/width

For --resize, it would be convenient to be able to specifiy just one or the other dimension and have the other one be automatically set to preserve aspect ratio, like ffmpeg does for video.

Maybe this would interact negatively with how the software interprets landscape images?

Repeatedly receiving a "OSError: cannot write mode CMYK as PNG" error

                 ┬─┐┌─┐┌─┐┌┐ ┌─┐ ┌─┐┬ ┬
                 ├┬┘├┤ │  ├┴┐┌─┘ ├─┘└┬┘
                 ┴└─└─┘└─┘└─┘└─┘o┴   ┴

multiprocessing.pool.RemoteTraceback: eroes_077.webp
"""
Traceback (most recent call last):
File "C:\Program Files\Python312\Lib\site-packages\PIL\PngImagePlugin.py", line 1289, in _save
rawmode, mode = _OUTMODES[mode]
~~~~~~~~~^^^^^^
KeyError: 'CMYK'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "C:\Program Files\Python312\Lib\multiprocessing\pool.py", line 125, in worker
result = (True, func(*args, **kwds))
^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python312\Lib\multiprocessing\pool.py", line 48, in mapstar
return list(map(*args))
^^^^^^^^^^^^^^^^
File "C:\Program Files\Python312\Lib\site-packages\reCBZ\util.py", line 95, in wrapper
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python312\Lib\site-packages\reCBZ\archive.py", line 149, in convert_page_worker
page.save(new_fp)
File "C:\Program Files\Python312\Lib\site-packages\reCBZ\archive.py", line 227, in save
self.fmt.save(self.img, dest)
File "C:\Program Files\Python312\Lib\site-packages\reCBZ\formats.py", line 58, in save
img.save(dest, format='PNG', optimize=True, compress_level=9)
File "C:\Program Files\Python312\Lib\site-packages\PIL\Image.py", line 2459, in save
save_handler(self, fp, filename)
File "C:\Program Files\Python312\Lib\site-packages\PIL\PngImagePlugin.py", line 1292, in _save
raise OSError(msg) from e
OSError: cannot write mode CMYK as PNG
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "", line 198, in run_module_as_main
File "", line 88, in run_code
File "C:\Program Files\Python312\Scripts\recbz.exe_main
.py", line 7, in
File "C:\Program Files\Python312\Lib\site-packages\reCBZ_main
.py", line 378, in main
wrappers.auto_repack_archive(filename)
File "C:\Program Files\Python312\Lib\site-packages\reCBZ\wrappers.py", line 201, in auto_repack_archive
results = compare_fmts_archive(fp, quiet=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python312\Lib\site-packages\reCBZ\wrappers.py", line 111, in compare_fmts_archive
results = ComicArchive(fp).compute_fmt_sizes()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python312\Lib\site-packages\reCBZ\archive.py", line 382, in compute_fmt_sizes
results = map_workers(worker, config.allowed_page_formats(), multithread=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python312\Lib\site-packages\reCBZ\util.py", line 114, in map_workers
return Tpool.map(func, tasks)
^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python312\Lib\multiprocessing\pool.py", line 367, in map
return self._map_async(func, iterable, mapstar, chunksize).get()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python312\Lib\multiprocessing\pool.py", line 774, in get
raise self._value
File "C:\Program Files\Python312\Lib\multiprocessing\pool.py", line 125, in worker
result = (True, func(*args, **kwds))
^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python312\Lib\multiprocessing\pool.py", line 48, in mapstar
return list(map(*args))
^^^^^^^^^^^^^^^^
File "C:\Program Files\Python312\Lib\site-packages\reCBZ\archive.py", line 362, in compute_single_fmt
results = map_workers(worker, sample_pages)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python312\Lib\site-packages\reCBZ\util.py", line 122, in map_workers
return MPpool.map(func, tasks)
^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python312\Lib\multiprocessing\pool.py", line 367, in map
return self._map_async(func, iterable, mapstar, chunksize).get()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python312\Lib\multiprocessing\pool.py", line 774, in get
raise self._value
OSError: cannot write mode CMYK as PNG

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.