8000 Add Symfony Image Component · symfony/symfony@4ee00c7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4ee00c7

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 4ee00c7

File tree

218 files changed

+16877
-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.

218 files changed

+16877
-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

appveyor.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ install:
3939
- echo apc.enable_cli=1 >> php.ini-max
4040
- echo extension=php_memcache.dll >> php.ini-max
4141
- echo extension=php_intl.dll >> php.ini-max
42+
- echo extension=php_exif.dll >> php.ini-max
43+
- echo extension=php_gd2.dll >> php.ini-max
4244
- echo extension=php_mbstring.dll >> php.ini-max
4345
- echo extension=php_fileinfo.dll >> php.ini-max
4446
- echo extension=php_pdo_sqlite.dll >> php.ini-max
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 int $start
29+
* @param int $end
30+
* @param ColorInterface $color
31+
* @param int $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 int $start
45+
* @param int $end
46+
* @param ColorInterface $color
47+
* @param bool $fill
48+
* @param int $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 bool $fill
64+
* @param int $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 int $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 int $start
90+
* @param int $end
91+
* @param ColorInterface $color
92+
* @param bool $fill
93+
* @param int $thickness
94+ 10000
*
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 bool $fill
121+
* @param int $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 int $angle
139+
* @param int $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: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
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+
*
24+
* @return EffectsInterface
25+
*
26+
* @throws RuntimeException
27+
*/
28+
public function gamma($correction);
29+
30+
/**
31+
* Invert the colors of the image.
32+
*
33+
* @return EffectsInterface
34+
*
35+
* @throws RuntimeException
36+
*/
37+
public function negative();
38+
39+
/**
40+
* Grayscale the image.
41+
*
42+
* @return EffectsInterface
43+
*
44+
* @throws RuntimeException
45+
*/
46+
public function grayscale();
47+
48+
/**
49+
* Colorize the image.
50+
*
51+
* @param ColorInterface $color
52+
*
53+
* @return EffectsInterface
54+
*
55+
* @throws RuntimeException
56+
*/
57+
public function colorize(ColorInterface $color);
58+
59+
/**
60+
* Sharpens the image.
61+
*
62+
* @return EffectsInterface
63+
*
64+
* @throws RuntimeException
65+
*/
66+
public function sharpen();
67+
68+
/**
69+
* Blur the image.
70+
*
71+
* @param float|int $sigma
72+
*
73+
* @return EffectsInterface
74+
*
75+
* @throws RuntimeException
76+
*/
77+
public function blur($sigma);
78+
}
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+
}

0 commit comments

Comments
 (0)
0