ibnux/generic-book-cover

PHP package to generate generic book covers for books where no original cover is available.

dev-master 2022-10-23 04:22 UTC

This package is auto-updated.

Last update: 2024-04-23 07:19:14 UTC


README

This is a small package for generating generic book covers that can be used with online book displays, etc. in cases where no original cover is available.

The cover elements (title, subtitle, creators, etc.) will be sized, adjusted and possibly wrapped automatically. This works quite well in most cases, but the result will certainly not be visually/typographically pleasant in all cases. The package doesn't currently provide any options for manually adjusting the arrangement of cover elements.

The package is based on a script by @kyrretl.

Installation

Install using Composer:

composer require ibnux/covergenerator dev-master

The package requires ImageMagick and Ghostscript.

Usage example

require('vendor/autoload.php');
use ibnux\GenericBookCover\BookCover;

$cover = new BookCover();
$cover->setTitle('Manual of scientific illustration')
	->setSubtitle('with special chapters on photography, cover design and book manufacturing')
	->setCreators('Charles S. Papp')
	->setEdition('3rd enl. ed.')
	->setPublisher('American Visual Aid Books')
	->setDatePublished('1976')
	->setRandomBackgroundColor()
	->save('cover1.png');

Instead of saving the cover to a file, you can also get the image data and serve it directly:

header('Content-Type: image/png');
echo $cover->getImageBlob();

Example covers

See examples/examples.php for the source code for the example covers.

Cover 1 Cover 2 Cover 3 Cover 4