Install imagick on macOS (Laravel, xampp)

if you are using latest macOS then you can run via brew or for oldest try to download manual from official website and other link below .

install imagemagick:

brew install imagemagick

Successfully:

🍺  /usr/local/Cellar/imagemagick/7.0.10-0: 1,487 files, 24.3MB

install ghostscript:

brew install ghostscript

Successfully:

🍺  /usr/local/Cellar/ghostscript/9.51_1: 671 files, 87.4MB

check installation

which magick

Then:

/usr/local/bin/magick

setup is done !

now lets example !

i have some file like jpeg, jpg, pdf so wanna conver any one

magick origin.jpeg converted.png

origin i wanna convert origin.jpeg(input file name) 2 converted.png(result file name)

sudo magick S.pdf S.png

if you have script then put this

shell_exec('magick origin.jpg converted_php.png');

then run script sudo php script.php

Thanks for reading

Bonus point

script for laravel

$im = new imagick($uploadfile);
$pages = $im->getNumberImages();
if ($pages < 3) { $resolution = 600; } else { $resolution = floor(sqrt(1000000/$pages)); }
$imagick = new imagick();
$imagick->setResolution($resolution, $resolution);
$imagick->readImage($uploadfile);
$imagick->setImageFormat('jpg');
foreach($imagick as $i=>$imagick) { $imagick->writeImage($uploadfile. " page ". ($i+1) ." of ". $pages.".jpg");
}
$imagick->clear();

Full Stack Developer | IOS Developer | Research Developer | NIT

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store