Skip to main content

PyComicView - 1

Library for displaying comics


Jeffrey Aylesworth
(jeffayle)

PyComicView

PyComicView is a python library for displaying comic directories.

Why?

There is a lack of good, free and Mac compatible comic book readers. Not that this is only for Mac, but being written in Python, it should work properly on any platform.

Looking for a program for reading comics, some of the problems I found in the major readers are:

  • Only runs on a single OS. Readers with Mac support tended to be dead, and only have PPC binaries.
  • Commercial
  • Unstable

Library?

Instead of completely writing a whole new comic reader, I decided to write a python module that will display a comic when told to. The reasoning was that without the need to write all the comic displaying code, more people would be willing to write frontend programs that organize comics and all that stuff.

Usage

PyComicView is contained in a single module, comicview. Importing this module will grant access to the single class contained, the Comic class.

This alone is enough to display a comic, as in the example found in readcomic.py:

import comicview
import sys
import os

c = comicview.Comic(os.path.join(sys.argv[1], '*'))
c.read()

That's all! This will display the comic in the directory specified on the command line. (Note: The Comic constructor expects a shell glob pattern, and not a directory. This may change in the future)

However, it can be subclassed to add more functionality, for example by overloading the customDraw() method, you can add extra information to the display.

For example, in customDrawingExample.py:

import comicview
import sys
import os
import pygame #We'll want this in here for convenience

class CustomComic(comicview.Comic):
    fnt = pygame.font.SysFont(pygame.font.get_default_font(), 36)
    def customDraw(self):
            text = CustomComic.fnt.render(str(self.page),False,(255,255,255))
            self.scr.blit(text, (0,0) )

c = CustomComic(os.path.join(sys.argv[1], '*'))
c.read()

This will draw the page number in the upper left hand corner.

Features

It is really bare on features. It doesn't use too much memory, but does use more processor cycles than other comic readers, due to being written in python.

The main feature it has (that I have not seen in other viewers) is continuous scrolling from one page to the next, ie. it looks like one long page.

Limitations

The module is still young, and limited in features. Currently, it can only display uncompressed images in a directory, and not in standard cbz or cbr archives. I am undecided on whether or not to include reading from archives, each has it's advantage; not having that feature would mean that each program can organize files however they want, and not reading from archives is faster. Having the ability to read from archives would mean that each program would not need to implement it themselves, and would allow for optimizations specific to it.

There is also as yet, no zooming functionality. There probably wont be for a while. In the nearer future, there will probbly be a magnifying glass to help see detail.

Memory Usage

Each page is stored in memory only once, and that is what is shown on screen. It is stored scaled to the size being viewed (when you resize, the image is reloaded from disk). Pages that are more than two pages away from the currently view pageare deleted from memory, and are loaded again when needed.

When reading a typically sized comic on full width (1280px) it usually uses 48mb, and spikes at 58mb.

License

PyComicView is written by Jeffrey Aylesworth. See COPYING for more license information.

The comic in the screenshot is "A Spectrum of Rights": http://wiki.creativecommons.org/Spectrumofrights_Comic1

Changes

Links

Home Page
http://github.com/jeffayle/PyComicView
Source
http://github.com/jeffayle/PyComicView/downloads

Releases

PyComicView 1 — 22 Oct, 2009

Pygame.org account Comments