diff --git a/www/commands/site_createBookThumbnails.php b/www/commands/site_createBookThumbnails.php index 6f677e4..3c352ba 100644 --- a/www/commands/site_createBookThumbnails.php +++ b/www/commands/site_createBookThumbnails.php @@ -20,7 +20,13 @@ echo ''; foreach ($SITE->modules->Books()->listAll() as $book) { echo 'Create preview for ' . $book['title'] . '
' . "\n"; - $SITE->modules->Books()->createPreview($book); + + try { + $SITE->modules->Books()->createPreview($book); + } catch (Exception $e) { + echo 'Failed to create preview for ' . $book['title'] . ':' . $e->getMessage() . '
' . "\n"; + } + } echo 'Finished.' . '
' . "\n"; diff --git a/www/commands/site_createProgramThumbnails.php b/www/commands/site_createProgramThumbnails.php index 7c5b00d..a06e275 100644 --- a/www/commands/site_createProgramThumbnails.php +++ b/www/commands/site_createProgramThumbnails.php @@ -20,7 +20,13 @@ echo ''; foreach ($SITE->modules->Programs()->listAll() as $prog) { echo 'Create preview for ' . $prog['name'] . '
' . "\n"; - $SITE->modules->Programs()->createPreview($prog); + + try { + $SITE->modules->Programs()->createPreview($prog); + } catch (Exception $e) { + echo 'Failed to create preview for ' . $prog['name'] . ':' . $e->getMessage() . '
' . "\n"; + } + } echo 'Finished.' . '
' . "\n"; diff --git a/www/internals/utils.php b/www/internals/utils.php index e6bfd0b..46228a0 100644 --- a/www/internals/utils.php +++ b/www/internals/utils.php @@ -176,7 +176,12 @@ function magick_resize_image($file, $width, $height, $output) $cmd = 'convert "' . $file . '" -strip -resize ' . $final_width . 'x' . $final_height . ' "' . $output . '"'; - shell_exec($cmd); + $output=null; + $retval=null; + $r = exec($cmd, $output, $retval); + + if ($r === false) throw new Exception("Magick exec() return FALSE"); + if ($retval !== 0) throw new Exception("Magick exec() returned exitcode $retval"); } function sendMail($subject, $content, $to, $from)