PHPackages                             chillerlan/php-imagetiler - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Image &amp; Media](/categories/media)
4. /
5. chillerlan/php-imagetiler

ActiveLibrary[Image &amp; Media](/categories/media)

chillerlan/php-imagetiler
=========================

An image tile generator. PHP 7.4+

3.2.0(2y ago)95.0k↓50%3MITPHPPHP ^7.4 || ^8.0

Since Jun 21Pushed 2y ago1 watchersCompare

[ Source](https://github.com/chillerlan/php-imagetiler)[ Packagist](https://packagist.org/packages/chillerlan/php-imagetiler)[ Docs](https://github.com/chillerlan/php-imagetiler)[ Fund](https://www.paypal.com/donate?hosted_button_id=WLYUNAT9ZTJZ4)[ Fund](https://ko-fi.com/codemasher)[ RSS](/packages/chillerlan-php-imagetiler/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (8)Dependencies (5)Versions (9)Used By (0)

php-imagetiler
==============

[](#php-imagetiler)

A script for PHP 7.4+ to cut images (maps) into pieces (tiles). Based on the [map tiler script by Fedik](https://github.com/Fedik/php-maptiler). This script will keep the proportions of the input image and generate only necessary tiles - no need for square input files!

[![PHP Version Support](https://camo.githubusercontent.com/946045146c31adcefe6a9525ba8fa49310aa77843bfe2d2441c5cb2af117084e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6368696c6c65726c616e2f7068702d696d61676574696c65723f6c6f676f3d70687026636f6c6f723d383839324246266c6f676f436f6c6f723d666666)](https://www.php.net/supported-versions.php)[![Packagist version](https://camo.githubusercontent.com/a84b809d849cc08468f19a214e72cc0ea2b68cfbecabfa18d215000317f796f1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6368696c6c65726c616e2f7068702d696d61676574696c65722e7376673f6c6f676f3d7061636b6167697374266c6f676f436f6c6f723d666666)](https://packagist.org/packages/chillerlan/php-imagetiler)[![License](https://camo.githubusercontent.com/e0a3af1c6de6960b58d1037f2a3de756e66cef1f77fa790dc0e3e125d0ff64d2/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6368696c6c65726c616e2f7068702d696d61676574696c65722e737667)](https://github.com/chillerlan/php-imagetiler/blob/main/LICENSE)[![Continuous Integration](https://camo.githubusercontent.com/a516916dfc497f2fafe5a3aecceac9efbedff0eceacabdcb65f76b1666400122/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6368696c6c65726c616e2f7068702d696d61676574696c65722f63692e796d6c3f6272616e63683d6d61696e266c6f676f3d676974687562266c6f676f436f6c6f723d666666)](https://github.com/chillerlan/php-imagetiler/actions?query=workflow%3A%22Continuous+Integration%22)[![CodeCov](https://camo.githubusercontent.com/f5538c196bd97c81ac08da635dbc1603ae750a34859377ecdeba1639bdd9122b/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f6368696c6c65726c616e2f7068702d696d61676574696c65722e7376673f6c6f676f3d636f6465636f76266c6f676f436f6c6f723d666666)](https://codecov.io/github/chillerlan/php-imagetiler)[![Packagist downloads](https://camo.githubusercontent.com/95ff1d63fe4b63614c0322010f30d7016f8f1fde7b6f93b461c95c1969051917/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6368696c6c65726c616e2f7068702d696d61676574696c65722e7376673f6c6f676f3d7061636b6167697374266c6f676f436f6c6f723d666666)](https://packagist.org/packages/chillerlan/php-imagetiler/stats)

Documentation
=============

[](#documentation)

Requirements
------------

[](#requirements)

- PHP 7.4+
- the [ImageMagick extension](https://www.imagemagick.org)
- a crapload of RAM, CPU power and free disk space
- image optimization utilities (optional), see [psliwa/image-optimizer](https://github.com/psliwa/image-optimizer#supported-optimizers)

Installation
------------

[](#installation)

**requires [composer](https://getcomposer.org)**

*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
-----

[](#usage)

Use the [example](https://github.com/chillerlan/php-imagetiler/blob/main/examples/imagetiler.php) 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

[](#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`](https://github.com/ImageMagick/ImageMagick/blob/main/config/policy.xml) in the ImageMagick installation path (on Windows). For your consideration: an image of 49152x49152 will generate a cache file of ~28.5GB,

### Image optimizers

[](#image-optimizers)

- PNG
    - [advpng](https://github.com/amadvance/advancecomp)
    - [optipng](http://optipng.sourceforge.net/)
    - [pngcrush](https://pmt.sourceforge.io/pngcrush/)
    - [pngquant](https://pngquant.org/)
- JPG
    - [jpegoptim](https://github.com/XhmikosR/jpegoptim-windows)
    - [jpegtran](https://jpegclub.org/jpegtran/)

API
---

[](#api)

### `Imagetiler` public methods

[](#imagetiler-public-methods)

methodreturndescription`__construct(ContainerInterface $options = null, LoggerInterface $logger = null)`-see [`SettingsContainerInterface`](https://github.com/chillerlan/php-settings-container/blob/main/src/SettingsContainerInterface.php) and [`LoggerInterface`](https://github.com/php-fig/log). Invokes an empty `ImagetilerOptions` object and a `Psr\NullLogger` if the respective parameters aren't set.`setOptions(ContainerInterface $options)``Imagetiler`set options on-the-fly, called internally by the constructor`setOptimizer(Optimizer $optimizer)``Imagetiler`set an optimizer instance on-the-fly, called internally by the constructor`process(string $image_path, string $out_path)``Imagetiler`processes the given image from `$image_path` and dumps the output to `$out_path`### `ImagetilerOptions` properties

[](#imagetileroptions-properties)

propertytypedefaultalloweddescription`$tile_size`int256positive intwidth/height of a single tile`$zoom_min`int0positive intminimum zoom level`$zoom_max`int8positive intmaximum zoom level`$zoom_normalize`intnullpositive intthis zoom level represents the size of the original image. zoom levels higher than this will be upscaled, which may take some time and resources depending on the size of the input image.`$tms`boolfalse\*if set to true - the origin will be set to bottom left, +y upwards, according to [Tile Map Service Specification](http://wiki.osgeo.org/wiki/Tile_Map_Service_Specification#TileMap_Diagram), otherwise the origin is on the top left, +y downwards, like described by the [Google Maps specification](https://developers.google.com/maps/documentation/javascript/coordinates#tile-coordinates)`$fill_color`string'#000000'\*the fill color for leftover space, can be transparent for png`$memory_limit`string'-1'\*see [php.ini settings](https://secure.php.net/manual/ini.core.php#ini.memory-limit)`$store_structure`string'%1$d/%2$d/%3$d'\*storage structure - can be anything. %1$d = zoom, %2$d = x, %3$d = y. see [sprintf()](https://secure.php.net/manual/function.sprintf.php)`$fast_resize_upsample`boolfalse\*determines whether to use fast `Imagick::scaleImage()` (true) or slow `Imagick::resizeImage()` (false)`$resize_filter_upsample`int`Imagick::FILTER_ROBIDOUXSHARP``Imagick::FILTER_*`see `Imagick::resizeImage()` and [Imagick filter constants](https://secure.php.net/manual/imagick.constants.php)`$resize_blur_upsample`float1.0positive floatsee `Imagick::resizeImage()``$fast_resize_downsample`boolfalse\*see `$fast_resize_upsample``$resize_filter_downsample`int`Imagick::FILTER_LANCZOSRADIUS``Imagick::FILTER_*`see `$resize_filter_upsample``$resize_blur_downsample`float1.0positive floatsee `$resize_blur_upsample``$tile_format`string'png'png, jpgsee [Imagick formats](http://www.imagemagick.org/script/formats.php)`$tile_ext`stringnull\*tile image extension - autodetected from format if none given.`$quality_jpeg`int800-100quality of the saved image in jpeg format`$imagick_tmp`stringnull\*ImageMagick tmp folder`$overwrite_base_image`boolfalse\*`$overwrite_tile_image`boolfalse\*`$clean_up`booltrue\*whether or not to delete temp images`$optimize_output`boolfalse\*enable image optimization (requires `Optimizer` instance)`$no_temp_baseimages`boolfalse\*whether or not to create and save temporary base images (may save resources)

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity30

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity73

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~300 days

Recently: every ~469 days

Total

8

Last Release

787d ago

Major Versions

1.0.2 → 2.0.02019-01-30

2.0.0 → 3.0.02021-07-19

PHP version history (2 changes)1.0.0PHP &gt;=7.2.0

3.0.0PHP ^7.4 || ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/ada3d048807a11e536645fb87da881170b18f34c0c61fa09e34807c5d79e0b89?d=identicon)[codemasher](/maintainers/codemasher)

---

Top Contributors

[![codemasher](https://avatars.githubusercontent.com/u/592497?v=4)](https://github.com/codemasher "codemasher (59 commits)")

---

Tags

game-mapsgoogle-mapsimagemagickleafletmapsphp-libraryphp7php8tile-generatorimagegeneratormapsleaflettile

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/chillerlan-php-imagetiler/health.svg)

```
[![Health](https://phpackages.com/badges/chillerlan-php-imagetiler/health.svg)](https://phpackages.com/packages/chillerlan-php-imagetiler)
```

###  Alternatives

[ps/image-optimizer

Image optimization / compression library. This library is able to optimize png, jpg and gif files in very easy and handy way. It uses optipng, pngquant, pngcrush, pngout, gifsicle, jpegoptim and jpegtran tools.

9341.7M25](/packages/ps-image-optimizer)[jcupitt/vips

A high-level interface to the libvips image processing library.

6961.6M31](/packages/jcupitt-vips)[multiavatar/multiavatar-php

Multicultural Avatar Generator

653150.0k4](/packages/multiavatar-multiavatar-php)[standaniels/image-generator

A package to generate random images.

1696.6k1](/packages/standaniels-image-generator)[bravo3/image-manager

A PHP 5.4 library to control dynamic image assets in a cloud environment

158.1k](/packages/bravo3-image-manager)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
