image.module --> doesn't create thumnail or preview images (Drupal 4.7) using Image_Magick

neoliminal - September 21, 2006 - 15:07

I have tracked down the problem to this function:

<?php
/**
* Generate image derivatives.
*/ 
function _image_build_derivatives(&$node, $temp = FALSE) {
 
// sanity check:
 
if (!_image_check_settings()) {
    return
false;
  }
 
$info = image_get_info(file_create_path($node->images['_original']));
 
$sizes = _image_get_sizes();
  if (!
$temp) {
   
_image_remove($node);
  }
  foreach (
$sizes as $size) {
    if (
$size['label'] && $size['width'] && $size['height']) {
      if (
$info['width'] > $size['width'] || $info['height'] > $size['height']) {
       
$source = file_create_path($node->images['_original']);
       
$destination = _image_filename(basename($source), $size['label'], $temp);
        if (!
image_scale($source, file_create_path($destination), $size['width'], $size['height'])) {
         
drupal_set_message(t('Unable to create %label image', array('%label' => $size['label'])), 'erro$
        }
        else {
          $node->images[$size['
label']] = $destination;
          if (!$temp) {
            _image_insert($node, $size['
label'], file_create_path($destination));
          }
        }
      }
      else {
        $node->images[$size['
label']] = $node->images['_original];
      }
    }
  }
}
?>

And in particular this line:

<?php
       
if (!image_scale($source, file_create_path($destination), $size['width'], $size['height'])) {
         
drupal_set_message(t('Unable to create %label image', array('%label' => $size['label'])), erro$
        }
?>

I can't, for the life of me, find any function called image_scale(), but it's clearly failing.

Does anyone know where this function lives?

I'm trying to prove to my boss that we can use this NOW, but I need to get the preview up and running today.

I forget where the function

riothamus - September 21, 2006 - 16:46

I forget where the function is, but it ends up calling the convert function in /includes/image.imagemagick.inc.

I had the same problem, and tracked it down to the lines:

function _image_imagemagick_convert($source, $dest, $filter) {
  $convert_path = variable_get('image_imagemagick_convert', '/usr/bin/convert');

in /includes/image.imagemagick.inc

For some reason, it was getting a blank value. I set it in the database, but still it did not work.

I just changed it manually to:

function _image_imagemagick_convert($source, $dest, $filter) {
  $convert_path = variable_get('image_imagemagick_convert', '/usr/bin/convert');
$convert_path="/usr/bin/convert";

This is not a good solution, but it'll make it work for now....

 
 

Drupal is a registered trademark of Dries Buytaert.