KnpLabs / snappy

PHP library allowing thumbnail, snapshot or PDF generation from a url or a html page. Wrapper for wkhtmltopdf/wkhtmltoimage
https://knplabs.com
MIT License
4.4k stars 436 forks source link

Error Acces to wkhtmltoimage with MAMP #99

Closed sebastienhouzet closed 7 years ago

sebastienhouzet commented 10 years ago

Impossible de generate with php (MAMP PRO 2)

Fatal error: Uncaught exception 'RuntimeException' with message 'The file '/Users/sebastien/Documents/git/test/test.jpg' was not created (command: /usr/local/bin/wkhtmltoimage --format 'jpg' 'http://www.google.fr' '/Users/sebastien/Documents/git/test/test.jpg').' in /Users/sebastien/Documents/git/test/vendor/knplabs/knp-snappy/src/Knp/Snappy/AbstractGenerator.php:276 Stack trace: #0 /Users/sebastien/Documents/git/test/vendor/knplabs/knp-snappy/src/Knp/Snappy/AbstractGenerator.php(132): Knp\Snappy\AbstractGenerator->checkOutput('/Users/sebastie...', '/usr/local/bin/...') #1 /Users/sebastien/Documents/git/test/index.php(8): Knp\Snappy\AbstractGenerator->generate('http://www.goog...', '/Users/sebastie...') #2 {main} thrown in /Users/sebastien/Documents/git/test/vendor/knplabs/knp-snappy/src/Knp/Snappy/AbstractGenerator.php on line 276

$snappy = new Image('/usr/local/bin/wkhtmltoimage');
$snappy->generate("http://www.google.fr","/Users/sebastien/Documents/git/test/test.jpg");
?>

When i exec usr/local/bin/wkhtmltoimage --format 'jpg' 'http://www.google.fr' '/Users/sebastien/Documents/git/test/test.jpg' in a terminal, the image is generated.

sebastienhouzet commented 10 years ago

For fix this problem, change the configuration MAMP

Edit /Applications/MAMP/Library/bin/envvars:

export PATH=/usr/local/bin/:$PATH
#DYLD_LIBRARY_PATH="/Applications/MAMP/Library/lib:$DYLD_LIBRARY_PATH"
#export DYLD_LIBRARY_PATH

Complete solution : http://www.prestagence.fr/wkhtmltopdf-wkhtmltoimage-mamp-mac-os-x-snappy-10580.html