Name Date Size #Lines LOC

..28-Sep-2023-

.github/H04-Jul-2021-

docker/H04-Jul-2021-

examples/H04-Jul-2021-

rpm/H04-Jul-2021-

tests/H04-Jul-2021-

util/H04-Jul-2021-

.gitignoreH A D04-Jul-202139 44

.travis.ymlH A D04-Jul-20212.3 KiB8064

CREDITSH A D04-Jul-202139 32

ChangeLogH A D04-Jul-202139 KiB1,057951

Imagick.stub.phpH A D04-Jul-202139.7 KiB1,383593

ImagickDraw.stub.phpH A D04-Jul-202111.5 KiB410179

ImagickDraw_arginfo.hH A D04-Jul-202158.3 KiB1,9471,527

ImagickKernel.stub.phpH A D04-Jul-2021603 2611

ImagickKernel_arginfo.hH A D04-Jul-20214.3 KiB166132

ImagickPixel.stub.phpH A D04-Jul-20212.4 KiB8528

ImagickPixelIterator.stub.phpH A D04-Jul-20211.6 KiB6234

ImagickPixelIterator_arginfo.hH A D04-Jul-20218.1 KiB205152

ImagickPixel_arginfo.hH A D04-Jul-202110 KiB346258

Imagick_arginfo.hH A D04-Jul-2021190.1 KiB6,5875,284

LICENSEH A D04-Jul-20213.1 KiB6955

README.mdH A D04-Jul-20216.5 KiB11967

check-loaded.phptH A D04-Jul-2021422 2017

clean.shH A D04-Jul-2021149 83

config.m4H A D04-Jul-20212.5 KiB8771

config.w32H A D04-Jul-20211.4 KiB2522

configure-cflags.shH A D04-Jul-20211.6 KiB6436

docker-compose.ymlH A D04-Jul-2021989 5655

imagemagick.m4H A D04-Jul-20217.4 KiB236196

imagemagick_dependency.shH A D04-Jul-20213 KiB10878

imagick.cH A D04-Jul-2021149.2 KiB4,076971

imagick_class.cH A D04-Jul-2021342.5 KiB13,1298,690

imagick_file.cH A D04-Jul-202110 KiB361267

imagick_helpers.cH A D04-Jul-202177.6 KiB1,9721,651

imagickdraw_class.cH A D04-Jul-202184.1 KiB3,0881,844

imagickkernel_class.cH A D04-Jul-202123.3 KiB865624

imagickpixel_class.cH A D04-Jul-202122 KiB842551

imagickpixeliterator_class.cH A D04-Jul-202117.4 KiB636419

package.xmlH A D04-Jul-202125.4 KiB429428

php_imagemagick_version_defs.hH A D04-Jul-20212.8 KiB8224

php_imagick.hH A D04-Jul-20212.1 KiB5215

php_imagick_defs.hH A D04-Jul-202137.4 KiB1,1911,037

php_imagick_file.hH A D04-Jul-20212.9 KiB7635

php_imagick_helpers.hH A D04-Jul-20214.5 KiB8933

php_imagick_macros.hH A D04-Jul-20212.2 KiB5022

php_imagick_shared.hH A D04-Jul-20211.8 KiB4112

regen_arginfo.shH A D04-Jul-2021663 2112

runTests.shH A D04-Jul-2021213 71

shim_im6_to_im7.cH A D04-Jul-202123.2 KiB880573

shim_im6_to_im7.hH A D04-Jul-20216.9 KiB156137

shim_php7_to_php8.hH A D04-Jul-2021397 147

README.md

1[![Build Status](https://travis-ci.org/imagick/imagick.png)](https://travis-ci.org/imagick/imagick)
2
3# ���� Imagick ����
4
5Imagick is a PHP extension to create and modify images using the ImageMagick library. There is also a version of Imagick available for HHVM. Although the two extensions are mostly compatible in their API, and they both call the ImageMagick library, the two extensions are completely separate code-bases.
6
7## PHP Imagick
8
9* Source code + issues - https://github.com/imagick/imagick
10* Releases - http://pecl.php.net/package/imagick
11* Documentation - http://php.net/manual/en/book.imagick.php
12
13Bugs can also be reported at https://bugs.php.net but may have a slower response time.
14
15## HHVM Imagick
16
17* https://github.com/facebook/hhvm/tree/master/hphp/runtime/ext/imagick
18
19# Installation on Linux
20
21The best way of installing Imagick is through a package manager e.g. apt, yum, brew, as they will also install ImageMagick for you.
22
23If you need to compile Imagick from source, first you should install [ImageMagick](https://github.com/ImageMagick/ImageMagick), at least version 6.2.4 but it is STRONGLY recommended to use a more recent version due to the many bug fixes in it.
24
25Once ImageMagick is installed, the following commands will compile and install Imagick:
26
27```
28git clone https://github.com/Imagick/imagick
29cd imagick
30phpize && ./configure
31make
32make install
33```
34
35You will also need to add `extension=imagick.so` to your PHP ini file to make PHP load the extension.
36
37
38# Installing on Windows
39
40For Windows please install both Imagick and the underlying ImageMagick library from:
41* http://windows.php.net/downloads/pecl/releases/imagick/
42* http://windows.php.net/downloads/pecl/deps/
43
44Once compiled, Imagick should be run with the same version of ImageMagick that it was compiled against. Running against a different version of ImageMagick is known to cause stability issues, and so is not recommended or supported.
45
46# NixOS
47
48If using Imagick on NixOS, you probably [want to define](https://github.com/Imagick/imagick/blob/master/docker/nixos/shell.nix) FONTCONFIG_FILE to avoid a warning message when loading fonts, and MAGICK_CONFIGURE_PATH to have all the information available from Imagick::getConfigureOptions().
49
50# Examples
51
52Almost all of the functions in the library have an example at [www.phpimagick.com](http://www.phpimagick.com/), where you can see the example code to call the function, as well as the generated image or output.
53
54
55# ImageMagick
56
57
58ImageMagick, the library that the Imagick extension exposes to PHP has had many bug fixes, that have fixed many image corruption issues. We _strongly_ recommend upgrading to the latest version (greater than 6.9.1 or 7.x) if at all possible.
59
60
61# Security
62
63The PHP extension Imagick works by calling the ImageMagick library. Although the ImageMagick developers take good care in avoiding bugs it is inevitable that some bugs will be present in the code. ImageMagick also uses a lot of third party libraries to open, read and manipulate files. The writers of these libraries also take care when writing their code. However everyone makes mistakes and there will inevitably be some bugs present.
64
65Because ImageMagick is used to process images it is feasibly possible for hackers to create images that contain invalid data to attempt to exploit these bugs. Because of this we recommend the following:
66
671) Do not run Imagick in a server that is directly accessible from outside your network. It is better to either use it as a background task using something like SupervisorD or to run it in a separate server that is not directly accessible on the internet.
68
69Doing this will make it more difficult for hackers to exploit a bug, if one should exist in the libraries that ImageMagick is using.
70
712) Run it as a very low privileged process. As much as possible the files and system resources accessible to the PHP script that Imagick is being called from should be locked down.
72
733) Verify that all image files begin with the expected "magic bytes" corresponding to the image file types you support before sending them to ImageMagick for processing. This an be be done with finfo_file() - see below.
74
754) Check the result of the image processing is a valid image file before displaying it to the user. In the extremely unlikely event that a hacker is able to pipe arbitrary files to the output of Imagick, checking that it is an image file, and not the source code of your application that is being sent, is a sensible precaution. This can be accomplished by the following code:
76
77
78```php
79<?php
80	$finfo = finfo_open(FILEINFO_MIME_TYPE);
81	$mimeType = finfo_file($finfo, $filename);
82
83	$allowedMimeTypes = [
84		'image/gif',
85		'image/jpeg',
86		'image/jpg',
87		'image/png'
88	];
89
90	if (in_array($mimeType, $allowedMimeTypes) == false) {
91		throw new \SecurityException("Was going to send file '$filename' to the user, but it is not an image file.");
92	}
93```
94
955) NEVER directly serve any files that have been uploaded by users directly through PHP, instead either serve them through the webserver, without invoking PHP, or use [readfile](http://php.net/manual/en/function.readfile.php) to serve them within PHP.
96
97These recommendations do not guarantee any security, but they should limit your exposure to any Imagick/ImageMagick related security issue.
98
99# OpenMP
100
101ImageMagick has the ability to use the Open Multi-Processing API to be able to use multiple threads to process an image at once. Some implementations of OpenMP are known to have stability issues when they are used in certain environments.
102
103We recommend doing one of the following:
104
105* Disabling OpenMP support in ImageMagick by compiling it with the compile flag "--disable-openmp" set.
106
107* Disable the use of threads in ImageMagick via Imagick by calling: `Imagick::setResourceLimit(\Imagick::RESOURCETYPE_THREAD, 1);` or `Imagick::setResourceLimit(6, 1);` if your version of Imagick does not contain the RESOURCETYPE_THREAD constant.
108
109* Disable the use of threads in ImageMagick by setting the thread resource limit in ImageMagick' policy.xml file with `<policy domain="resource" name="thread" value="1"/>` This file is possibly located at /etc/ImageMagick-6/policy.xml or similar location.
110
111* If you do want to use OpenMP in ImageMagick when it's called through Imagick, you should test thoroughly that it behaves correctly on your server.
112
113
114# TODO
115
116Documentation needs a lot of work. There is an online editor here: [https://edit.php.net/](https://edit.php.net/) Contributions are more than welcome.
117
118Please refer to http://abi-laboratory.pro/tracker/timeline/imagemagick/ for exact version changes of the underlying ImageMagick library.
119