chillerlan / php-imagetiler
An image tile generator. PHP 7.4+
Fund package maintenance!
Ko Fi
www.paypal.com/donate?hosted_button_id=WLYUNAT9ZTJZ4
Installs: 3 602
Dependents: 2
Suggesters: 0
Security: 0
Stars: 8
Watchers: 3
Forks: 4
Open Issues: 0
Requires
- php: ^7.4 || ^8.0
- ext-imagick: *
- chillerlan/php-settings-container: ^2.1.5
- codemasher/image-optimizer: ^2.1
- psr/log: ^1.1 || ^2.0 || ^3.0
Requires (Dev)
- phan/phan: ^5.4
- phpunit/phpunit: ^9.6
README
A script for PHP 7.4+ to cut images (maps) into pieces (tiles). Based on the map tiler script by Fedik. This script will keep the proportions of the input image and generate only necessary tiles - no need for square input files!
Documentation
Requirements
- PHP 7.4+
- the ImageMagick extension
- a crapload of RAM, CPU power and free disk space
- image optimization utilities (optional), see psliwa/image-optimizer
Installation
requires composer
composer.json (note: replace dev-main
with a version boundary)
{ "require": { "php": "^7.4 || ^8.0", "ext-imagick": "*", "chillerlan/php-imagetiler": "dev-main" } }
Profit!
Usage
Use the example for live testing.
// invoke an options instance $options = new ImagetilerOptions([ 'zoom_min' => 0, 'zoom_max' => 8, 'zoom_normalize' => 6, 'fill_color' => 'transparent', 'fast_resize' => true, 'optimize_output' => true, // ... whatever you need ]); // see https://github.com/psliwa/image-optimizer#configuration $optimizer = (new OptimizerFactory([]))->get(); // invoke and run the tiler $tiler = new Imagetiler($options, $optimizer); $tiler->process('/path/to/image.png', '/path/to/output/');
That's it!
Memory trouble
If you're running into issues with ImageMagick complaining about not enough space on the cache path, you might want to check the policy.xml
in the ImageMagick installation path (on Windows).
For your consideration: an image of 49152x49152 will generate a cache file of ~28.5GB,