PHP Classes

PHP Comic Reader Tools: Display images from comic books in HTML pages

Recommend this page to a friend!
  Info   View files Example   Screenshots Screenshots   View files View files (12)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog (1)    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 110 All time: 9,631 This week: 129Up
Version License PHP version Categories
comicbooktools 1.0.0Custom (specified...7HTML, Graphics, PHP 7


This package can display images from comic books in HTML pages.

It can read comic book files in cbz or cbr format and extract comic images from them.

The package can also display the extracted comic images as a slideshow in an Web page.

Innovation Award
PHP Programming Innovation award nominee
May 2020
Number 5
Many people like to read comic books. In the past they used to be available only in paper.

Nowadays, many comic books are available as computer file archives that contain digitized versions of the comic book images.

This package provides a solution to access and display files with comic book images.

Manuel Lemos
Picture of Karl Holz
  Performance   Level  
Name: Karl Holz <contact>
Classes: 14 packages by
Country: Canada Canada
Age: 43
All time rank: 44918 in Canada Canada
Week rank: 25 Up2 in Canada Canada Up
Innovation award
Innovation award
Nominee: 9x



$dir = "./comic" ;

if (
array_key_exists('QUERY_STRING', $_SERVER) && isset($_SERVER['QUERY_STRING'])) {

    if (
$cb = $file;
    } elseif(
is_file($dir . $file)) {
$cb = $dir . $file;
    } else {
$arc, $img) = explode('|', $file);
        if (
is_file($dir . $arc)) {
$cb=$dir . $arc;
$cbr = new comic_reader($cb);

header("Location: {$_SERVER['PHP_SELF']}}");


    if (
$cbr=new comic_reader($cb)) {
$urls = $cbr->list_files();

$slides_tmpl= new slide_show_html();
    } else {


} else {

$ini=parse_ini_file('comic.ini', TRUE);
    foreach (
$ini as $i) {
$url=$_SERVER['PHP_SELF'] . "?" . base64_encode(str_replace($i['dir'], '', $i['file']));

$main .= <<<EOF
<li><a href="$url" target="_blank">$txt</a><br /><img src="$img" /></li>



?><!DOCTYPE html>
    <title>cbr/cbz Comicbook viewer</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
        * {box-sizing: border-box}

        body {
            font-family: "Lato", sans-serif;
        img {
            min-width: 100px;

            max-width: 300px;
            height: 500px;
            padding: 5px;
            margin: 5px;;
        a {
            font-family: fantasy;
            font-size: larger;
            color: ghostwhite;
            background-color: darkred;
        ul {
            list-style-type: none;


        li {
            padding: 5px;
            margin: 5px;
            float: left;
            vertical-align: middle;
            text-align: center;
            border: solid;
            border-color: navy;

<?php echo $main ?>




Package: ComicBookTools Author: Abu Khadeejah Karl Holz <binholz|a|hotmail|d|com> Licence: LICENCE

About Me

I'm Abu Khadeejah Karl Holz, I'm a StageHand by trade and coding is my hobby. I have diploma for Computer Systems Technologies from Seneca College in Toronto, this is where I learned the basics of UNIX, Linux, Shell Scripting, Perl, PHP, Windows, etc. I'm a father, so i have been busy taking care of my girl and not spending a lot of time coding php on my off time.

Comic Book Tools

this is a quick little tool to let you view your cbr files off of a webserver using PHP, like the built-in server. This project uses the rar pecl extention and it will need to be built by the user. Not all file versons are read by the pecl plugin, I have added a setup.php file that will create an ini file with all your cbz/cbr files, this is used for the front page page so you can select your comic from what was found. i have tried added conversion to png support, not all images seem to be viewable so far. the links that are generated are base64 encoded as a query string. you will need to increase the php memory usage for this class in your php.ini

File type viewing status

My class will deal with both rar and zip based comic books, class will test for rar first, then zip for all requests. 7-zip (cb7) is not supported, i didn't see a pecl extention or anything in the documentation about 7-zip. You can create a zip file arcive of selected images, like in MacOS Finder, then rename the extention to cbz.

|_ File01.png
|_ File02.jpg
|_ File03.png

As you can see from above, this class can be used for more than just comics, take a look at the samples i made in the comic folder (check my github)

You Need the RAR PECL EXTENTION for cbr files

you will need this pecl extention installed on your system. i built it from source using the link bellow:

$ cd <src dir>
$ ./configure
$ make
$ make test
$ make install

I used the system version of PHP 7 in MacOS High Sieara and not MAMP (failed to build for me).


Enable pecl extention in the /etc/php.ini

you should add the code bellow to your php.ini file, if my scripts setting doesn't work. Most images in cbr/cbz files are high resolution.

memory_limit = 2048M

use PHP built-in webserver

for this project, i'm just using the built in webserver for PHP since this is just a personal reader for comics that you can setup on a raspberry pi, pine64 or other SBC. take a look at the index.php and edit the $dir variable for your comic book directory.

$ cd <comic srv>
$ php -S localhost:8888 index.php
$ php -S <ip address|hostname>:8888 index.php

Support My Work

If you like any of the work I have done in the past, I'm welcome to any support you would like to provide via PayPal or EMT. I would like to focus on the projects with the most downloads, like the Excel2JSON, eKitab (code clean-up?), WebMap (upgrade) or others listed on PHP Classes website. My current computer is an MacMini 2010. I would like to get a new laptop (Mac perferablly). E-mail or make an issue on GitHub if you would like to ask questions or provide help. I like to keep things open source so we can have these tools availale and educational.

  • comic_view
  • commandline
  • index_page
  Files folder image Files  
File Role Description
Files folder image.idea (6 files)
Accessible without login Plain text file comic.ini Data Auxiliary data
Plain text file ComicBookTools.class.php Class Class source
Accessible without login Plain text file index.php Example Example script
Accessible without login Plain text file LICENCE Lic. License text
Accessible without login Plain text file README.MD Doc. Documentation
Accessible without login Plain text file setup.php Example Example script

  Files folder image Files  /  .idea  
File Role Description
  Accessible without login Plain text file comic_reader.iml Data Auxiliary data
  Accessible without login Plain text file misc.xml Data Auxiliary data
  Accessible without login Plain text file modules.xml Data Auxiliary data
  Accessible without login Plain text file php.xml Data Auxiliary data
  Accessible without login Plain text file vcs.xml Data Auxiliary data
  Accessible without login Plain text file workspace.xml Data Auxiliary data

 Version Control Unique User Downloads Download Rankings  
This week:0
All time:9,631
This week:129Up