THESE CODES ARE PROVIDED FOR AN EXAMPLE OF HOW TO USE IMAGEMAGICK WITH PHP. CARE SHOULD BE TAKEN WHEN ACCEPTING USER INPUT.
I TAKE NO RESPONSABILTY FOR ANY PROBLEMS THAT MAY OCCURE WHEN USING ANY OF THIS CODE.
IT IS UP TO YOU TO SECURE THE CODE AND VALIDATE USER INPUT.
You can use different colours specifications in ImageMagick ( you will need to escape the ( ) ).
Specification | Format example | Result |
---|---|---|
Name | Cyan |
![]() |
HEX | #00ffff You may need use ' around the colour '#00ffff' |
![]() |
RGB | rgb\(0,255,255\) |
![]() |
RGBA | rgba\(0,255,255,1\) |
![]() |
HSL | hsl\(180,100,50\) |
![]() |
HSLA | hsla\(180,100,50,1.0\) If black your browser does not support HSLA |
![]() |
CMYK | cmyk\(100,0,0,0\) |
![]() |
CMYKA | cmyka\(100,0,0,0,100\) |
![]() |
The code to produce the colour patchs, just replace the colour section with the examples above.
exec("convert -size 50x20 xc:cmyka(100,0,0,0) cmyka.jpg");
Note: Do not leave spaces between the colours; although the ImageMagick website says it will be OK. e.g. rgb\(255, 0, 0\) will not work but rgb\(255,0,0\) will work.