You may consider using something like this for a replacement for the image_close function

function imageapi_imagemagick_image_close($image, $dst) {
  if (strncmp($image->info['mime_type'],"image/",6)==0) {
    $type=substr($image->info['mime_type'],6). ":";
  } else {
    $type="";
  }
  
  return _imageapi_imagemagick_convert($image->source, $type.$dst, $image->ops);
}
CommentFileSizeAuthor
#2 imageapi_375218-2.patch934 bytesegfrith

Comments

nbayaman’s picture

Hi markfoodyburton! I came from here: http://drupal.org/node/314553 where i tried to find out, why IMagick raw action module doesn't want to react to "-format" option. So it turns out, that it's crucial to specify correct output filename to "-format" option to work.

So does your replacement solve this issue?

egfrith’s picture

Title: changing file type with imagemagic » Changing file type with imagemagick
Category: feature » bug
Status: Needs work » Needs review
StatusFileSize
new934 bytes

At present, it is not possible to use the convert action in imagecache_coloractions.module with imageapi_imagemagick.module. This is because the $source and $dest passed to _imageapi_imagemagick_convert() have the same extension, so convert doesn't know it should change the file type.

The code snippet posted at comment #1 fixes this problem, by prepending the file type to the file name with a colon, as per convert -h:

To specify a particular image format, precede the filename
with an image format name and a colon (i.e. ps:image) or specify the
image type as the filename suffix (i.e. image.ps).

The patch I'm posting is a tweaked version of the code posted in comment #1. I've tested that it converts jpeg to png using the imagecache_coloractions.module.

Solving this bug would also help with this feature request in imagecache: #366373: PDF support ( i.e. convert PDF to JPG support)

@nurlan.bayaman: not sure if this would fix your issue.

egfrith’s picture

Hmmm.... this patch sort of works, but causes a "Failed generating image" response from imagecache because of _imageapi_imagemagick_convert() trying to check that $type:$dest is a file... I'll post a patch at #416254: Add equivalent of image_get_info() at the toolkit level that combines the fix for this along with the patch for replacing get_info().

drewish’s picture

I think this part of the patch has snuck into #416254: Add equivalent of image_get_info() at the toolkit level.

mavimo’s picture

I solved using #817290: Quality param