Skip to content
Tinify PHP Client for ProcessWire
Branch: master
Clone or download

Tinify PHP client for ProcessWire

Hooks TinyPNG on the fly image compression to ProcessWire

Get your API key at TinyPNG Developer page. This module connects to API by Tinify PHP client.


Using manually

This module adds new $image->tinify() method to the Pageimage object:

$image = $page->images->first()->tinify();
echo "<img src='{$image->url}' alt='{$image->description}' />";

Behind the scenes image is copied and compressed. As a succesful result tiny variation of Pageimage is returned:

<img src='/site/assets/files/1/my_image.-tiny.jpg' alt='My description' />

Automatically on $image->size()

Resized variations can be automatically compressed by enabling auto mode at module config page.

$image = $page->images->first()->size(200,200);
echo "<img src='{$image->url}' alt='{$image->description}' />";
<img src='/site/assets/files/1/my_image.200x200-tiny.jpg' alt='My description' />


Module config options

Name Type Default Description
apikey string TinyPNG developer API key (required).
logging int 1 Log compression data (1=true, 0=false).
limit int 500 Monthly compression usage limit (zero or empty for no limit).
auto int 0 Auto mode (1=true, 0=false). Compress automatically $image->size() resized variations.
sizes string Ignored sizes at auto mode. Separate width/height by colon and sizes by pipe (200,200|960,0|0,320).


Name Type Default Description
tinify bool null Enable/Disable compression (overrides auto option at module config).
tinify-png bool true Enable/Disable compression for PNG images.
tinify-jpeg bool true Enable/Disable compression for JPEG images.


Please report any bugs or enhancements as opening new issue. If you find this module useful, you can always support our work by making a small donation. Thanks!


This software is licensed under the MIT License (MIT). View the license.

You can’t perform that action at this time.