Convert SVG image to PNG with PHP

That’s funny you asked this, I just did this recently for my work’s site and I was thinking I should write a tutorial… Here is how to do it with PHP/Imagick, which uses ImageMagick: $usmap = ‘/path/to/blank/us-map.svg’; $im = new Imagick(); $svg = file_get_contents($usmap); /*loop to color each state as needed, something like*/ $idColorArray = … Read more

Merge Images Side by Side (Horizontally)

ImageMagick ships with the montage utility. Montage will append each image side-by-side allowing you to adjust spacing between each image (-geometry), and the general layout (-tile). montage [0-4].png -tile 5×1 -geometry +0+0 out.png Other examples can be found on Montage Usage page

Ruby: Installing rmagick on Ubuntu

Install the packages imagemagick and libmagickwand-dev (or libmagick9-dev). You should then be able to install the Rmagick Gem. sudo apt-get install imagemagick libmagickwand-dev If not, you are missing ruby related development packages like build-essential and ruby1.8-dev. If that’s the case, a generic “ubuntu install ruby 1.8” query in google should sort you out.

rmagick gem install “Can’t find Magick-config”

When building native Ruby gems, sometimes you’ll get an error containing “ruby extconf.rb”. This is often caused by missing development libraries for the gem you’re installing, or even Ruby itself. Do you have apt installed on your machine? If not, I’d recommend installing it, because it’s a quick and easy way to get a lot … Read more

Recommendation for compressing JPG files with ImageMagick

I use always: quality in 85 progressive (comprobed compression) a very tiny gausssian blur to optimize the size (0.05 or 0.5 of radius) depends on the quality and size of the picture, this notably optimizes the size of the jpeg. Strip any comment or EXIF metadata in imagemagick should be convert -strip -interlace Plane -gaussian-blur … Read more

convert:not authorized `aaaa` @ error/constitute.c/ReadImage/453

Note: the solution in this and other answers involves disabling safety measures that are there to fix arbitrary code execution vulnerabilities. See for instance this ghostscript-related and this ubuntu-related announcement. Only go forward with these solutions if the input to convert comes from a trusted source. I use ImageMagick in php (v.7.1) to slice PDF … Read more