2017 © Pedro Peláez
 

library imagine-svg

Contao Imagine SVG library

image

contao/imagine-svg

Contao Imagine SVG library

  • Wednesday, July 18, 2018
  • by leofeyer
  • Repository
  • 4 Watchers
  • 8 Stars
  • 126,540 Installations
  • PHP
  • 4 Dependents
  • 1 Suggesters
  • 4 Forks
  • 0 Open issues
  • 10 Versions
  • 17 % Grown

The README.md

Contao Imagine SVG library

, (*1)

This project implements the interfaces of Imagine and allows you to make simple modifications to SVG images. It is used in [Contao][2] to handle on-the-fly resizing of SVG images., (*2)

Installation

php composer.phar require contao/imagine-svg

Usage

use Contao\ImagineSvg\Imagine;
use Imagine\Image\Box;
use Imagine\Image\Point;

$imagine = new Imagine();

$imagine
    ->open('/path/to/image.svg')
    ->crop(new Point(50, 50), new Box(100, 100))
    ->resize(new Box(40, 40))
    ->save('/path/to/thumbnail.svg')
;

$image = $imagine->open('/path/to/image.svg');

$image->effects()
    ->gamma(1.5)
    ->negative()
    ->grayscale()
    ->colorize($color)
    ->sharpen()
    ->blur(2)
;

$image->save('/path/to/image.svg');

Because of the nature of SVG images, the getSize() method differs a little bit from other implementations. You can check the return value like in this example:, (*3)

use Contao\ImagineSvg\Imagine;
use Contao\ImagineSvg\SvgBox;

$imagine = new Imagine();
$size = $imagine->open('/path/to/image.svg')->getSize();

if (SvgBox::TYPE_NONE === $size->getType()) {
    // The image has no defined size
} elseif (SvgBox::TYPE_ASPECT_RATIO === $size->getType()) {
    // The image has a relative size, $size->getWidth() and $size->getHeight()
    // should be treated as an aspect ratio
} else {
    // The image has a defined size like a regular image
    // $size->getType() would return SvgBox::TYPE_ABSOLUTE in this case
}

The Versions

18/07 2018

dev-master

9999999-dev

Contao Imagine SVG library

  Sources   Download

LGPL-3.0+ LGPL-3.0-or-later

The Requires

 

The Development Requires

02/03 2018

0.2.1

0.2.1.0

Contao Imagine SVG library

  Sources   Download

LGPL-3.0-or-later

The Requires

 

The Development Requires

27/12 2017

0.2.0

0.2.0.0

Contao Imagine SVG library

  Sources   Download

LGPL-3.0+

The Requires

 

The Development Requires

17/10 2017

dev-feature/infection

dev-feature/infection

Contao Imagine SVG library

  Sources   Download

LGPL-3.0+

The Requires

 

The Development Requires

14/09 2017

0.1.5

0.1.5.0

Contao Imagine SVG library

  Sources   Download

LGPL-3.0+

The Requires

 

The Development Requires

20/05 2017

0.1.4

0.1.4.0

Contao Imagine SVG library

  Sources   Download

LGPL-3.0+

The Requires

 

The Development Requires

14/02 2017

0.1.3

0.1.3.0

Contao Imagine SVG library

  Sources   Download

LGPL-3.0+

The Requires

 

The Development Requires

22/11 2016

0.1.2

0.1.2.0

Contao Imagine SVG library

  Sources   Download

LGPL-3.0+

The Requires

 

The Development Requires

28/09 2016

0.1.1

0.1.1.0

Contao Imagine SVG library

  Sources   Download

LGPL-3.0+

The Requires

 

The Development Requires

29/07 2016

0.1.0

0.1.0.0

Contao Imagine SVG library

  Sources   Download

LGPL-3.0+

The Requires

 

The Development Requires