Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Imagick/imagick
🌈 The Imagick PHP extension 🌈
https://github.com/Imagick/imagick
c imagemagick php
Last synced: about 2 months ago
JSON representation
🌈 The Imagick PHP extension 🌈
- Host: GitHub
- URL: https://github.com/Imagick/imagick
- Owner: Imagick
- License: other
- Created: 2013-01-16T06:35:55.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2024-07-07T15:05:26.000Z (6 months ago)
- Last Synced: 2024-07-31T19:18:38.899Z (5 months ago)
- Topics: c, imagemagick, php
- Language: C
- Homepage: http://pecl.php.net/imagick
- Size: 3.6 MB
- Stars: 527
- Watchers: 26
- Forks: 134
- Open Issues: 212
-
Metadata Files:
- Readme: README.md
- Changelog: ChangeLog
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
[![Build status](https://github.com/imagick/imagick/actions/workflows/main.yml/badge.svg)](https://github.com/Imagick/imagick/actions)
[![Build status](https://github.com/imagick/imagick/actions/workflows/windows.yml/badge.svg)](https://github.com/Imagick/imagick/actions)
# 🌈🌈 Imagick 🌈🌈
Imagick 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.
## PHP Imagick
* Source code + issues - https://github.com/imagick/imagick
* Releases - http://pecl.php.net/package/imagick
* Documentation - http://php.net/manual/en/book.imagick.php
Bugs can also be reported at https://bugs.php.net but may have a slower response time.## HHVM Imagick
* https://github.com/facebook/hhvm/tree/master/hphp/runtime/ext/imagick
# Installation on Linux
The best way of installing Imagick is through a package manager e.g. apt, yum, brew, as they will also install ImageMagick for you.
If 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.
Once ImageMagick is installed, the following commands will compile and install Imagick:
```
git clone https://github.com/Imagick/imagick
cd imagick
phpize && ./configure
make
make install
```You will also need to add `extension=imagick.so` to your PHP ini file to make PHP load the extension.
# Installing on Windows
For Windows please install both Imagick and the underlying ImageMagick library from:
* http://windows.php.net/downloads/pecl/releases/imagick/
* http://windows.php.net/downloads/pecl/deps/Once 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.
# NixOS
If 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().
# Examples
Almost 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.
# ImageMagick
ImageMagick, 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.
# Security
The 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.
Because 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:
1) 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.
Doing this will make it more difficult for hackers to exploit a bug, if one should exist in the libraries that ImageMagick is using.
2) 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.
3) 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.
4) 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:
```php
` This file is possibly located at /etc/ImageMagick-6/policy.xml or similar location.* 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.
# TODO
Documentation needs a lot of work. There is an online editor here: [https://edit.php.net/](https://edit.php.net/) Contributions are more than welcome.
Please refer to http://abi-laboratory.pro/tracker/timeline/imagemagick/ for exact version changes of the underlying ImageMagick library.