PHPackages                             vagovszky/imokutr - 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. vagovszky/imokutr

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

vagovszky/imokutr
=================

PHP image thumbnailer created with primary use for Nette framework, but also usable as a standalone PHP library

1.0.5(5y ago)026MITPHPPHP &gt;=5.6.0

Since Mar 4Pushed 3y agoCompare

[ Source](https://github.com/vagovszky/imokutr)[ Packagist](https://packagist.org/packages/vagovszky/imokutr)[ RSS](/packages/vagovszky-imokutr/feed)WikiDiscussions master Synced yesterday

READMEChangelog (1)Dependencies (1)Versions (5)Used By (0)

imokutr
=======

[](#imokutr)

PHP image thumbnailer created with primary use for Nette framework, but also usable as a standalone PHP library.

Documentation:

The basic philosophy
--------------------

[](#the-basic-philosophy)

Imokutr is PHP library designed to automatically generate thumbnails from original images.

It was created with the following assumptions in mind:

1. We have some original images in directories.

Example:

```
/disk0/web/files/articles/2018/10/image.jpg
/disk0/web/files/gallery/pigs/pig01.png
/disk0/web/files/wallpaper/bifFish.png

```

2. We have relative paths to these images stored somewhere, like for example in a database:

Example:

```
id |title                 | url
1  | Blue image           | /articles/2018/10/Blueimage.jpg
2  ! Cute pig at our farm | /gallery/pigs/pig01.png
3  | Big fish             | /wallpaper/bifFish.png

```

3. We want to easily create and show listing images, perex images or gallery thumbnails images created from original images on a web site.

Nette integration
=================

[](#nette-integration)

Composer
--------

[](#composer)

```
composer install skachcz/imokutr

```

Nette extension registration in neon.config and configuration:
--------------------------------------------------------------

[](#nette-extension-registration-in-neonconfig-and-configuration)

```
extensions:
    imokutr: SkachCz\Imokutr\Nette\ImokutrExtension

imokutr:
    originalRootPath: /home/webs/nette-app/www
    thumbsRootPath: /home/webs/nette-app/www/thumbs
    thumbsRootRelativePath: /thumbs
    qualityJpeg: 85
    qualityPng: 8

```

Using in \*.latte template:
---------------------------

[](#using-in-latte-template)

Parameters - width, height, resizeType, cropParameter

width (mandatory) - Width in pixels for thumbnail.

height (mandatory) - Height in pixels for thumbnail.

resizeType (optional) - default is 'w'

'w' - thumbnail width will be same as with parameter, thumbnail height is calculated according to image ratio 'h' - thumbnail height will be same as height parameter, thumbnail width is calculated according to image ratio 'c' - crop - thumbnail will be cropped to specific width and height

cropParameter (optional) 0-8 - default is 0

```
  ↖    ↑   ↗
    1  2  3
 ←  8  0  4  →
    7  6  5
  ↙    ↓   ↘

```

Nette Filter
------------

[](#nette-filter)

```
{'/files/original/image1.jpg'|imoUrl:100:200:'h'}

```

Macro
-----

[](#macro)

Inside the macro code, you can use placeholders %url%, %width% and %height%:

```
{imoTag '/files/original/image1.jpg', 300, 150, 'w'}

{/imoTag}

{imoTag '/files/original/image1.jpg', 300, 150, 'h'}

{/imoTag}

{imoTag '/files/original/image1.jpg', 300, 150, 'c'}

{/imoTag}

{imoTag '/files/original/image1.jpg', 300, 150, 'c', 5}

{/imoTag}

```

Standalone library
==================

[](#standalone-library)

with composer
=============

[](#with-composer)

composer.json ''' { "require": { "skachcz/imokutr": "master-dev" } } '''

''' composer update '''

without composer
================

[](#without-composer)

```
