2017 © Pedro Peláez
 

library icelus

Thumbnail generator for Sculpin-based websites

image

beryllium/icelus

Thumbnail generator for Sculpin-based websites

  • Saturday, May 20, 2017
  • by beryllium
  • Repository
  • 3 Watchers
  • 8 Stars
  • 124 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 1 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

Icelus

Build Status SensioLabsInsight, (*1)

Icelus is a quick and easy thumbnail generator for your Sculpin-based websites and blogs., (*2)

Icelus, otherwise known as "Scaled Sculpin", are a genus of small fish mainly found in the North Pacific., (*3)

Requirements

Icelus requires:, (*4)

  • PHP 5.4+
  • Imagick extension (installable via apt-get, pecl, or yum)
  • Imanee library (imanee.io - fetched automatically by Composer)

Installation

If you are using the Phar-based Sculpin utility, you can create or modify a sculpin.json file in your project root and add "beryllium/icelus" to the "require" block. Then, run sculpin install or sculpin update to fetch the required dependencies., (*5)

{
  "require": {
     "beryllium/icelus": "*"
  }
}

Alternatively, if you are using a Composer-based sculpin installation, you should simply be able to run composer require beryllium/icelus to get things rolling., (*6)

Once the library is installed, you have to tell Sculpin how to load it. You can do this by creating or modifying a app/SculpinKernel.php file to resemble the following:, (*7)

<?php

class SculpinKernel extends \Sculpin\Bundle\SculpinBundle\HttpKernel\AbstractKernel
{
    protected function getAdditionalSculpinBundles()
    {
        return array(
            'Beryllium\Icelus\IcelusBundle',
        );
    }
}

Note: The class name should be a string, not an object instantiation. (This differs from the way Symfony 2 configures bundles.), (*8)

Configuration

Generally, no additional configuration is required. If you want to rename the output subfolder for thumbnails (default is 'yourblog.com/_thumbs'), add this to your sculpin_kernel.yml, (*9)

yml icelus: prefix: '/_thumbs', (*10)

  • icelus.prefix : A subdirectory under the Sculpin output directory to store the thumbnails. Default is '/_thumbs'.

Usage

Icelus exposes a thumbnail function in Twig, which you can use either on its own or by creating Twig macros to customize the output., (*11)

thumbnail(image, width, height, crop), (*12)

  • __image__ (string): The relative path to the image in the source/ folder.
  • __width__ (int): Maximum width, in pixels
  • __height__ (int): Maximum height, in pixels
  • crop__ (bool): False will fit the whole image inside the provided dimensions. True will crop the image from the center. Default: __FALSE

Inline Example:, (*13)

<a href="image.jpg"><img src="{{ thumbnail('image.jpg', 100, 100) }}"></a>

Macro Example:, (*14)

index.html:

{% import '_macros.html.twig' as m %}

<h1>Gone Fishin'!</h1>
{{ m.small_thumbnail('image.jpg', 'A picture from my fishing trip') }}


_macros.html.twig: 

{% macro small_thumbnail(image, caption) %}
  <a href="{{ image }}">
    <img src="{{ thumbnail(image, 100, 100) }}">
    <br>
    <em>{{ caption }}</em>
  </a>
{% endmacro %}

A service called icelus.service is also added to the Sculpin dependency injection container, which you can use in your own Sculpin extensions., (*15)

For raw access to the underlying Imanee library, the service is named icelus.imanee. If you need to go deeper, you can then retrieve an Imagick instance using $imanee->getIMResource()., (*16)

Technically speaking, this extension could also be used as a Symfony 2 bundle. This has not been tested, but experimentation is welcome., (*17)

Future Plans

I would like for Icelus to expose more features of the underlying Imanee library, particularly with regard to watermarks and drawing text onto images. Imanee's support for animated gifs could possibly also be advantageous in some way., (*18)

I would also like for Icelus to be compatible with a wide variety of PHP frameworks and workflows. I've concentrated on having it as a Twig extension, but it could also work with other template systems and even Markdown-style parsers., (*19)

Thanks

Special thanks to Beau Simensen, for inviting me into the Sculpin organization, and to Erika Heidi for the ease-of-use of the Imanee library., (*20)

The Versions

20/05 2017

dev-master

9999999-dev http://whateverthing.com

Thumbnail generator for Sculpin-based websites

  Sources   Download

MIT

The Requires

 

The Development Requires

thumbnails images sculpin sculpin-plugin

20/05 2017

1.1.0

1.1.0.0 http://whateverthing.com

Thumbnail generator for Sculpin-based websites

  Sources   Download

MIT

The Requires

 

The Development Requires

thumbnails images sculpin sculpin-plugin

12/12 2015

1.0.1

1.0.1.0 http://whateverthing.com

Thumbnail generator for Sculpin-based websites

  Sources   Download

MIT

The Requires

 

The Development Requires

thumbnails images sculpin sculpin-plugin

05/03 2015

1.0.0

1.0.0.0 http://whateverthing.com

Thumbnail generator for Sculpin-based websites

  Sources   Download

MIT

The Requires

 

The Development Requires

thumbnails images sculpin sculpin-plugin