PHPackages                             tacnoman/thumcno - 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. tacnoman/thumcno

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

tacnoman/thumcno
================

Package to serve your thumbnails

1.4(9y ago)29[4 issues](https://github.com/tacnoman/thumcno/issues)MITPHPPHP &gt;=5.3.0

Since Nov 15Pushed 9y ago2 watchersCompare

[ Source](https://github.com/tacnoman/thumcno)[ Packagist](https://packagist.org/packages/tacnoman/thumcno)[ RSS](/packages/tacnoman-thumcno/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (4)Versions (2)Used By (0)

[![Build Status](https://camo.githubusercontent.com/b4ff368830321c20ea7968f43af35d94a34c1829abc525ddf4d98c603f8b18d7/68747470733a2f2f7472617669732d63692e6f72672f7461636e6f6d616e2f7468756d636e6f2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/tacnoman/thumcno) [![Code Climate](https://camo.githubusercontent.com/c6653bb5c589ec46a794d8ceaa0818491dd0f6cd0e2b371e1aa5e224ad193c32/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f7461636e6f6d616e2f7468756d636e6f2f6261646765732f6770612e737667)](https://codeclimate.com/github/tacnoman/thumcno)

Thumcno - A Tacno Thumbnail Generator in runtime
================================================

[](#thumcno---a-tacno-thumbnail-generator-in-runtime)

Pre requisites
--------------

[](#pre-requisites)

To use thumcno, you need install the php-gd first.

```
 $ sudo apt-get install php-gd # Ubuntu
 $ sudo yum install php-gd # CentOs
 $ brew install php-gd # Mac OS
```

You must install composer too. \[\]

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

[](#installation)

```
git clone git@github.com:tacnoman/thumcno.git
cd thumcno
composer install
php thumcno config # Follow the instructions
php thumcno serve
```

Based on timthumb:

You can use for any projects with different domains.

How it works?
-------------

[](#how-it-works)

There are many solutions to crop images. I like the timthumb solution. The request goes to a php file with params. The crop happen in runtime and generate a cache file. The Thumcno project, add a security for this and reuse for multiple projects. It's veeeery easy to use! I'll show you!

#### First step:

[](#first-step)

You need to add your custom domain. You could run:

```
php thumcno domain:add img.mydomain.com
```

This command will generate a file called `img.mydomain.com.ini` in `/app/apps` directory. This file contains the custom configuration for this domain (example: cache directory, etc). This params will replace the params in default.ini (you can change it).

##### This is the `default.ini`.

[](#this-is-the-defaultini)

```
; This document has default params
port = 80

debug_on = true    ; Enable debug logging to web server error log. Remember to update this param in your app
debug_level = 1 ; Debug level 1 is less noisy and 3 is the most noisy

memory_limit = 30M              ; Set PHP memory limit
block_external_leechers = false ; If the image or webshot is being loaded on an external site, display a red "No Hotlinking" gif.
display_error_messages = true   ; Display error messages. Set to false to turn off errors (good for production websites)

allow_external = false       ; Allow image fetching from external websites. Will check against ALLOWED_SITES if ALLOW_ALL_EXTERNAL_SITES is false
allow_external_sites = false ; Less secure.

file_cache_enabled = true              ; Should we store resized/modified images on disk to speed things up?
file_cache_time_between_cleans = 86400 ; How often the cache is cleaned

file_cache_max_file_age = 86400 ; How old does a file have to be to be deleted from the cache
file_cache_suffix = .thumcno    ; What to put at the end of all files in the cache directory so we can identify them
file_cache_prefix = null        ; What to put at the beg of all files in the cache directory so we can identify them
file_cache_directory = cache    ; Directory where images are cached. Left blank it will use the system temporary directory (which is better for security)
max_file_size = 10485760        ; 10 Megs is 10485760. This is the max internal or external file size that we'll process.
curl_timeout = 20               ; Timeout duration for Curl. This only applies if you have Curl installed and aren't using PHP's default URL fetching mechanism.
wait_between_fetch_errors = 3600; Time to wait between errors fetching remote file

; Browser caching
browser_cache_max_age = 864000 ; Time to cache in the browser
browser_cache_disable = false  ; Use for testing if you want to disable all browser caching

; Image size and defaults
max_width = 1500         ; Maximum image width
max_height = 1500        ; Maximum image height
not_found_image = null   ; Image to serve if any 404 occurs
error_image = ''         ; Image to serve if an error occurs instead of showing error message
png_is_transparent = true; Define if a png image should have a transparent background color. Use False value if you want to display a custom coloured canvas_colour
default_q = 90           ; Default image quality. Allows overrid in timthumb-config.php
default_zc = 1           ; Default zoom/crop setting. Allows overrid in timthumb-config.php
default_f = null         ; Default image filters. Allows overrid in timthumb-config.php
default_s = 0            ; Default sharpen value. Allows overrid in timthumb-config.php
default_cc = ffffff      ; Default canvas colour. Allows overrid in timthumb-config.php
default_width = 100      ; Default thumbnail width. Allows overrid in timthumb-config.php
default_height = 100     ; Default thumbnail height. Allows overrid in timthumb-config.php

```

You need to replace only the necessary.

See working in local machine
----------------------------

[](#see-working-in-local-machine)

To see in your local machine, run this commands:

```
cd /path/to/thumcno
php thumcno config
php thumcno serve
```

### Running with Docker

[](#running-with-docker)

```
docker run -it -p 8888:80 tacnoman/thumcno ./thumcno server
# Sharing folder
docker run -it -p 8888:80 -v /path/to/thumcno/apps:/app/apps -v /path/to/thumcno/example_images:/app/example_images tacnoman/thumcno ./thumcno server
```

### Using with docker-compose

[](#using-with-docker-compose)

#### TODO THIS!

[](#todo-this)

Now, go to your browser and open the url:

[http://localhost:8888/?src=/dubai.jpg&amp;w=200&amp;h=200&amp;q=80](http://localhost:8888/?src=/dubai.jpg&w=200&h=200&q=80)

You will see this:

[![dubai thumb](./example_image/thumbnail.jpg)](./example_image/thumbnail.jpg)

Possible params
---------------

[](#possible-params)

This list is the params that you can pass in url ($\_GET):

parameterstands forvaluesWhat it doessrcsourceurl to imageTells Thumbcno which image to resizewwidththe width to resize toRemove the width to scale proportionally (will then need the height)hheightthe height to resize toRemove the height to scale proportionally (will then need the width)qquality0-100Compression quality. The higher the number the nicer the image will look. I wouldn’t recommend going any higher than about 95 else the image will get too largeaalignmentc,t,l,r,b,tl,tr,bl,brCrop alignment. c = center, t = top, b = bottom, r = right, l = left. The positions can be joined to create diagonal positionszczoom/crop0,1,2,3Change the cropping and scaling settingsffilterstoo many to mentionYou can use the link abovessharpenApply a sharpen filter to the image, makes scaled down images look a little crispercccanvas colourhexadecimal color(#fff)Change background colour. Most used when changing the zoom and crop settings, which in turn can add borders to the image.ctcanvas transptrue (1)Use transparency and ignore background colourstylethumb sizesstringString to define the style of the size, for example, thumb=30x30, medium=200x200 and big=800x800Set possible sizes
------------------

[](#set-possible-sizes)

If you don't set the sizes, you could have a big security problem! Suppose that your URI is this `//`. A hacker could make a script to generate ALL POSSIBLE SIZES in cache. But, you can define the possible sizes to generate in your website. It's simple:

```
; .ini
; Possible_sizes
[sizes]
thumb = 30x30
medium = 200x200
large = 800x800

```

Now, you can generate thumbs only with sizes 30x30, 200x200 and 800x800. If you don't want to show the size in the URL, you can use the `style` (like paperclip for ruby).

The style will replace the size. An example for this config is:

```
; .ini
[styles]
medium = 500x500
big = 800x700
```

`http:///?src=dubai.jpg&style=medium` -&gt; Without friendly url. `http:///medium/dubai.jpg` -&gt; Considering a friendly url, where the uri is `/(?P\w+)/(?P(\w|-|\.)+)`.

### URL Friendly

[](#url-friendly)

If you want to use friendly urls, you can set the params in your .ini file passing the URLS params. (You must know abour regex) The param is `route` and you can use the same url params in this format:

```
(?P\regex)
ex: (?P\d+) -> Regex for para w (width) accepting only integers values

Another example:
^\/(?P\d+)x(?P\d+)\/(?P\d{1,3})\/?
/x//?src=example_images/dubai.jpg

One more example:
^\/(?P\d+)x(?P\d+)\/(?P\d{1,3})\/(?[\w.-]+)?
/x//
http://localhost:8080/200x200/80/dubai.jpg

Ps: If you don't set any params in your regex, you can pass like $_GET param.

```

### Bugs

[](#bugs)

`Send-me an email: .`

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 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

Unknown

Total

1

Last Release

3471d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/904dffc09e9e7060ed4a1b5bb5023e100f0a723240e2bd14a5324cd9d184a675?d=identicon)[Tacnoman](/maintainers/Tacnoman)

---

Top Contributors

[![renatocassino](https://avatars.githubusercontent.com/u/5348316?v=4)](https://github.com/renatocassino "renatocassino (91 commits)")

---

Tags

phpthumbnailserverresizethumbTimThumb

### Embed Badge

![Health badge](/badges/tacnoman-thumcno/health.svg)

```
[![Health](https://phpackages.com/badges/tacnoman-thumcno/health.svg)](https://phpackages.com/packages/tacnoman-thumcno)
```

###  Alternatives

[stefangabos/zebra_image

A single-file, lightweight PHP library designed for efficient image manipulation featuring methods for modifying images and applying filters

141110.4k6](/packages/stefangabos-zebra-image)[coldume/imagecraft

A reliable and extensible PHP image manipulation library

10133.7k2](/packages/coldume-imagecraft)[francodacosta/phmagick

image manipulation with php and ImageMagick

3869.7k1](/packages/francodacosta-phmagick)[mediamonks/sonata-media-bundle

A powerful, flexible and easy to use alternative for the existing Sonata Media Bundle

109.8k](/packages/mediamonks-sonata-media-bundle)

PHPackages © 2026

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