Skip to content

Commit ffc201d

Browse files
avalanche123romainneutron
authored andcommitted
Add Symfony Image Component
This component is a port of Bulat Shakirzyanov's Imagine library (https://github.com/avalanche123/Imagine) into Symfony.
1 parent 28a00da commit ffc201d

File tree

217 files changed

+16856
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

217 files changed

+16856
-2
lines changed

.travis.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ addons:
1111
- language-pack-fr-base
1212
- ldap-utils
1313
- slapd
14+
- libtiff-dev
15+
- libjpeg-dev
16+
- libdjvulibre-dev
17+
- libwmf-dev
18+
- pkg-config
19+
- liblcms2-dev
1420

1521
env:
1622
global:
@@ -27,15 +33,16 @@ matrix:
2733
- php: 5.5
2834
- php: 5.6
2935
- php: 7.0
30-
env: deps=high
36+
env: deps=high IMAGE_DRIVER=gmagick
3137
- php: 7.1
32-
env: deps=low
38+
env: deps=low IMAGE_DRIVER=imagick
3339
fast_finish: true
3440

3541
cache:
3642
directories:
3743
- .phpunit
3844
- php-$MIN_PHP
45+
- cache
3946

4047
services:
4148
- memcached
@@ -89,6 +96,8 @@ install:
8996
- if [[ ! $skip ]]; then composer update; fi
9097
- if [[ ! $skip ]]; then ./phpunit install; fi
9198
- if [[ ! $skip && ! $PHP = hhvm* ]]; then php -i; else hhvm --php -r 'print_r($_SERVER);print_r(ini_get_all());'; fi
99+
- if [[ $IMAGE_DRIVER = imagick ]]; then bash ./.travis/imagick.sh; fi
100+
- if [[ $IMAGE_DRIVER = gmagick ]]; then bash ./.travis/gmagick.sh; fi
92101

93102
script:
94103
- REPORT=' && echo -e "\\e[32mOK\\e[0m {}\\n\\n" || (echo -e "\\e[41mKO\\e[0m {}\\n\\n" && $(exit 1))'

.travis/gmagick.sh

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/bin/bash
2+
3+
set -xe
4+
5+
GRAPHICSMAGIC_VERSION="1.3.23"
6+
if [ $TRAVIS_PHP_VERSION = '7.0' ] || [ $TRAVIS_PHP_VERSION = '7.1' ]
7+
then
8+
GMAGICK_VERSION="2.0.4RC1"
9+
else
10+
GMAGICK_VERSION="1.1.7RC2"
11+
fi
12+
13+
mkdir -p cache
14+
cd cache
15+
16+
if [ ! -e ./GraphicsMagick-$GRAPHICSMAGIC_VERSION ]
17+
then
18+
wget http://78.108.103.11/MIRROR/ftp/GraphicsMagick/1.3/GraphicsMagick-$GRAPHICSMAGIC_VERSION.tar.xz
19+
tar -xf GraphicsMagick-$GRAPHICSMAGIC_VERSION.tar.xz
20+
rm GraphicsMagick-$GRAPHICSMAGIC_VERSION.tar.xz
21+
cd GraphicsMagick-$GRAPHICSMAGIC_VERSION
22+
./configure --prefix=$HOME/opt/gmagick --enable-shared --with-lcms2
23+
make -j
24+
else
25+
cd GraphicsMagick-$GRAPHICSMAGIC_VERSION
26+
fi
27+
28+
make install
29+
cd ..
30+
31+
if [ ! -e ./gmagick-$GMAGICK_VERSION ]
32+
then
33+
wget https://pecl.php.net/get/gmagick-$GMAGICK_VERSION.tgz
34+
tar -xzf gmagick-$GMAGICK_VERSION.tgz
35+
rm gmagick-$GMAGICK_VERSION.tgz
36+
cd gmagick-$GMAGICK_VERSION
37+
phpize
38+
./configure --with-gmagick=$HOME/opt/gmagick
39+
make -j
40+
else
41+
cd gmagick-$GMAGICK_VERSION
42+
fi
43+
44+
make install
45+
echo "extension=gmagick.so" >> `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"`
46+
php --ri gmagick

.travis/imagick.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/bash
2+
3+
set -xe
4+
5+
IMAGEMAGICK_VERSION="6.8.9-10"
6+
IMAGICK_VERSION="3.4.3"
7+
8+
mkdir -p cache
9+
cd cache
10+
11+
if [ ! -e ./ImageMagick-$IMAGEMAGICK_VERSION ]
12+
then
13+
wget http://www.imagemagick.org/download/releases/ImageMagick-$IMAGEMAGICK_VERSION.tar.xz
14+
tar -xf ImageMagick-$IMAGEMAGICK_VERSION.tar.xz
15+
rm ImageMagick-$IMAGEMAGICK_VERSION.tar.xz
16+
cd ImageMagick-$IMAGEMAGICK_VERSION
17+
./configure --prefix=$HOME/opt/imagemagick
18+
make -j
19+
else
20+
cd ImageMagick-$IMAGEMAGICK_VERSION
21+
fi
22+
23+
make install
24+
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$HOME/opt/imagemagick/lib/pkgconfig
25+
ln -s $HOME/opt/imagemagick/include/ImageMagick-6 $HOME/opt/imagemagick/include/ImageMagick
26+
cd ..
27+
28+
if [ ! -e ./imagick-$IMAGICK_VERSION ]
29+
then
30+
wget https://pecl.php.net/get/imagick-$IMAGICK_VERSION.tgz
31+
tar -xzf imagick-$IMAGICK_VERSION.tgz
32+
rm imagick-$IMAGICK_VERSION.tgz
33+
cd imagick-$IMAGICK_VERSION
34+
phpize
35+
./configure --with-imagick=$HOME/opt/imagemagick
36+
make -j
37+
else
38+
cd imagick-$IMAGICK_VERSION
39+
fi
40+
41+
make install
42+
echo "extension=imagick.so" >> `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"`
43+
php --ri imagick
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
composer.lock
2+
phpunit.xml
3+
vendor/
4+
Tests/Fixtures/results/in_out
5+
!Tests/Fixtures/results/in_out/.placeholder
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Image\Draw;
13+
14+
use Symfony\Component\Image\Image\AbstractFont;
15+
use Symfony\Component\Image\Image\BoxInterface;
16+
use Symfony\Component\Image\Image\Palette\Color\ColorInterface;
17+
use Symfony\Component\Image\Image\PointInterface;
18+
use Symfony\Component\Image\Exception\RuntimeException;
19+
20+
interface DrawerInterface
21+
{
22+
/**
23+
* Draws an arc on a starting at a given x, y coordinates under a given
24+
* start and end angles
25+
*
26+
* @param PointInterface $center
27+
* @param BoxInterface $size
28+
* @param integer $start
29+
* @param integer $end
30+
* @param ColorInterface $color
31+
* @param integer $thickness
32+
*
33+
* @throws RuntimeException
34+
*
35+
* @return DrawerInterface
36+
*/
37+
public function arc(PointInterface $center, BoxInterface $size, $start, $end, ColorInterface $color, $thickness = 1);
38+
39+
/**
40+
* Same as arc, but also connects end points with a straight line
41+
*
42+
* @param PointInterface $center
43+
* @param BoxInterface $size
44+
* @param integer $start
45+
* @param integer $end
46+
* @param ColorInterface $color
47+
* @param Boolean $fill
48+
* @param integer $thickness
49+
*
50+
* @throws RuntimeException
51+
*
52+
* @return DrawerInterface
53+
*/
54+
public function chord(PointInterface $center, BoxInterface $size, $start, $end, ColorInterface $color, $fill = false, $thickness = 1);
55+
56+
/**
57+
* Draws and ellipse with center at the given x, y coordinates, and given
58+
* width and height
59+
*
60+
* @param PointInterface $center
61+
* @param BoxInterface $size
62+
* @param ColorInterface $color
63+
* @param Boolean $fill
64+
* @param integer $thickness
65+
*
66+
* @throws RuntimeException
67+
*
68+
* @return DrawerInterface
69+
*/
70+
public function ellipse(PointInterface $center, BoxInterface $size, ColorInterface $color, $fill = false, $thickness = 1);
71+
72+
/**
73+
* Draws a line from start(x, y) to end(x, y) coordinates
74+
*
75+
* @param PointInterface $start
76+
* @param PointInterface $end
77+
* @param ColorInterface $outline
78+
* @param integer $thickness
79+
*
80+
* @return DrawerInterface
81+
*/
82+
public function line(PointInterface $start, PointInterface $end, ColorInterface $outline, $thickness = 1);
83+
84+
/**
85+
* Same as arc, but connects end points and the center
86+
*
87+
* @param PointInterface $center
88+
* @param BoxInterface $size
89+
* @param integer $start
90+
* @param integer $end
91+
* @param ColorInterface $color
92+
* @param Boolean $fill
93+
* @param integer $thickness
94+
*
95+
* @throws RuntimeException
96+
*
97+
* @return DrawerInterface
98+
*/
99+
public function pieSlice(PointInterface $center, BoxInterface $size, $start, $end, ColorInterface $color, $fill = false, $thickness = 1);
100+
101+
/**
102+
* Places a one pixel point at specific coordinates and fills it with
103+
* specified color
104+
*
105+
* @param PointInterface $position
106+
* @param ColorInterface $color
107+
*
108+
* @throws RuntimeException
109+
*
110+
* @return DrawerInterface
111+
*/
112+
public function dot(PointInterface $position, ColorInterface $color);
113+
114+
/**
115+
* Draws a polygon using array of x, y coordinates. Must contain at least
116+
* three coordinates
117+
*
118+
* @param array $coordinates
119+
* @param ColorInterface $color
120+
* @param Boolean $fill
121+
* @param integer $thickness
122+
*
123+
* @throws RuntimeException
124+
*
125+
* @return DrawerInterface
126+
*/
127+
public function polygon(array $coordinates, ColorInterface $color, $fill = false, $thickness = 1);
128+
129+
/**
130+
* Annotates image with specified text at a given position starting on the
131+
* top left of the final text box
132+
*
133+
* The rotation is done CW
134+
*
135+
* @param string $string
136+
* @param AbstractFont $font
137+
* @param PointInterface $position
138+
* @param integer $angle
139+
* @param integer $width
140+
*
141+
* @throws RuntimeException
142+
*
143+
* @return DrawerInterface
144+
*/
145+
public function text($string, AbstractFont $font, PointInterface $position, $angle = 0, $width = null);
146+
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Image\Effects;
13+
14+
use Symfony\Component\Image\Exception\RuntimeException;
15+
use Symfony\Component\Image\Image\Palette\Color\ColorInterface;
16+
17+
interface EffectsInterface
18+
{
19+
/**
20+
* Apply gamma correction
21+
*
22+
* @param float $correction
23+
* @return EffectsInterface
24+
*
25+
* @throws RuntimeException
26+
*/
27+
public function gamma($correction);
28+
29+
/**
30+
* Invert the colors of the image
31+
*
32+
* @return EffectsInterface
33+
*
34+
* @throws RuntimeException
35+
*/
36+
public function negative();
37+
38+
/**
39+
* Grayscale the image
40+
*
41+
* @return EffectsInterface
42+
*
43+
* @throws RuntimeException
44+
*/
45+
public function grayscale();
46+
47+
/**
48+
* Colorize the image
49+
*
50+
* @param ColorInterface $color
51+
*
52+
* @return EffectsInterface
53+
*
54+
* @throws RuntimeException
55+
*/
56+
public function colorize(ColorInterface $color);
57+
58+
/**
59+
* Sharpens the image
60+
*
61+
* @return EffectsInterface
62+
*
63+
* @throws RuntimeException
64+
*/
65+
public function sharpen();
66+
67+
/**
68+
* Blur the image
69+
*
70+
* @param float|int $sigma
71+
*
72+
* @return EffectsInterface
73+
*
74+
* @throws RuntimeException
75+
*/
76+
public function blur($sigma);
77+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Image\Exception;
13+
14+
interface ExceptionInterface
15+
{
16+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Image\Exception;
13+
14+
class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface
15+
{
16+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy