开发者

How do I use ImageMagick binaries from PHP?

开发者 https://www.devze.com 2023-02-16 20:04 出处:网络
I am using locally the ImageMagick library for image editing. In my online shared server there was no Imag开发者_StackOverflow社区eMagick installed but after requested, they installed ImageMagick bina

I am using locally the ImageMagick library for image editing. In my online shared server there was no Imag开发者_StackOverflow社区eMagick installed but after requested, they installed ImageMagick binaries at /usr/local/bin, e.g. the convert binary at /usr/local/bin/convert.

How can I use those binaries in my script?


  1. Download and install ImageMagick on your local machine.
  2. Create a test folder with an image or two to play with.
  3. Open up the shell, go to the test folder, and start playing with the commands until you find a command that gets you the desired results. Consult with the (not-so-helpful) documentation: http://www.imagemagick.org/script/command-line-tools.php
  4. Paste this command into your php script, replacing any filenames or arguments with php variables as needed.
  5. exec( // command );


Use exec like

$inputFile = 'file.jpg';
$outputFile = 'file.png';
exec('/usr/local/bin/convert '.$inputFile.' '.$outputFile);


Those aren't "perl binaries", they're the C libraries and binary executables.

You need to build/install the php module that uses them.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号