Aug 292008

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.

  4 Responses to “PHP Comic Viewer”

  1. This is great! I’ve also been looking for something like this as well for a while now. I actually gave up a few weeks ago and started writing down some notes on paper and sketching up some thoughts on how I wanted this to work. Its great to see I’m not the only one out there who wants a web-based solution to viewing my CBR files. Have you thought about sharing your code at all, maybe turning it into a Sourceforge project?

  2. I’ve thought about it, but I’d really like to get it to the point that it’s what I consider fairly polished before I release it. I still want to do things like move all of the “customizable” stuff out to a config file, and maybe add new features like keeping track of the titles that have been read, to eliminate the “did I read this yet?” that I’ve encountered too much recently.

  3. Have you abandoned this project? I’d love to use even the base of what you have done.

  4. It’s at the limit of what I wanted to do with it, so I’ve pretty much ceased development on the project. All of the latest source code is on SourceForge CVS/SVN.

Sorry, the comment form is closed at this time.