PHP-CBViewer 0.1

Version 0.1 is in SVN now.  A README file is pending (I can’t work on this project while at work, so when I get home, I’ll be writing some documentation, including necessary modules, etc).

For the un-enlightened, this project is a PHP-based CBR and CBZ viewer, for reading “comic book archives” in a web browser, instead of in a standalone client.

PHP Comic Viewer

OK, I’m gonna have to start out with a bit of geek-translation and/or explanation.

When you steal acquire comic books off of the Internet, they generally come in one of two convenient formats (or in a very inconvenient format that I don’t care about): CBR and CBZ.  CBR files are RAR files that have been renamed, and CBZ files are ZIP files that have been similarly renamed.  Both archives contain multiple individual image files, which are the pages of the acquired comic.  Traditionally, there are two potential ways to deal with these files.  You can rename them back to .rar or .zip, extract them, and use an image viewer to look at the individual pages, or you can use a specialized program that’s designed to view “comic archives”, which extracts the images to a temporary location and displays them for you.  The latter method is simply several fewer steps than the former.  The “inconvenient” format that I mentioned is “a bunch of images”.  This seems to me like a much more difficult way to manage your collection, increases the possibility that you’ll end up with 22 complete pages out of a 23-page book, and generally makes your life more complicated.  If you’re the kind of person who likes this method of comic organization, more power to you.  But I like the archive method; it fits my needs much more completely.

I was talking to my friend Paul about this a week or two ago, and he mentioned that he’d seen someone with a web-based viewer for comic archives.  Naturally, I spent a bit of time looking for it, because I’m lazy. If I can just load a web page to read comics, I’m 100 times more likely to use it than I am to download & install a comic viewer on each computer I use (please note, I actually have done this; I’m speaking of a theoretical rather than an actual).  I was unable to find such a program, in any language.  So I decided to write one myself.  It’s still in a very alpha state, but here are a couple of screenshots of the cbviewer 0.2alpha.  It uses a couple of what seem like non-stock PHP libraries (for the RAR and ZIP support), but the bonus of this is that it doesn’t use any external programs to achieve its magic; it’s 100% PHP.


I recommend clicking the thumbnails to enlarge, because the tiny squares that wordpress auto-generated really don’t do the program justice.  Naturally, I’m still working on the “make it pretty” aspect of designing a web program (aesthetics aren’t my strong suit), but at the very least I’ve managed to get everything working without having to resort to any hacks.  In this version, at least.  In version 0.1a, I was forced to use embedded base64-encoded images to display files that were inside .cbz files, because I hadn’t yet figured out how to extract the image to a temporary (and arbitrary) location without being forced to also include whatever sub-directories were included in the archive.  This had the wonderful side-effect of crashing Safari and WebKit.  0.2a eliminates that problem, as well as significantly tightening up the code, reducing the necessary number of source files from 7 down to 4 (by extending some of my previous logic and discoveries, I was able to make the archive-handling and page generation more generic).

And I think I’m done geeking out for a while, at least on this project.  I’ll probably tweak the CSS some more, in an attempt to make the site more aesthetically pleasing, but by and large I’ve got all but one of the features I want.