Drupal and image.module only support images of type JPEG, GIF, or PNG. This is one of three patches for supporting many more image types by using ImageMagick.

The changes I've made to image.module include the addition of an image_viewable function, that defines whether an image type is web-viewable or not. If it isn't, then derivative images will be created in PNG format, and the 'Original' image view links to the original image file.

I'll be adding issues for patches to image.inc and image.imagemagick.inc shortly.

Comments

wrunt’s picture

StatusFileSize
new6.14 KB

Here's the patch.

wrunt’s picture

I forgot to mention, I have a site to demonstrate this at http://test.wrunt.net/drupal-5.7.

wrunt’s picture

The patch for image.imagemagick.inc is at http://drupal.org/node/269329, and the patch for image.inc is at http://drupal.org/node/269337.

lagrange’s picture

This is a very helpful patch. Does it handle multiple-pages files ?

For example, with a 3 pages pdf input, is it possible to output 3 pngs, 1 per page ?

wrunt’s picture

lagrange: It does handle multiple-page files. See http://test.wrunt.net/drupal-5.7/node/20 for an example. Currently it appends all of the pages vertically into one large image.

ImageMagick can output one file per page, so you could theoretically have separate images, but then the image node would have to keep track of multiple files, or perhaps uploading a multiple-page pdf would create multiple image nodes. It would be an interesting project, but perhaps not trivial.

MGParisi’s picture

woops, wrong image module!

rj’s picture

Hi, I was able to get this to work but only after I downloaded the files from your websites; one of the patches did not work. I could get image.imagemagick.inc and menu.inc to patch without a problem but image.module gave this output:

patching file image.module
Hunk #1 succeeded at 4 with fuzz 1.
Hunk #2 succeeded at 353 (offset -1 lines).
Hunk #3 succeeded at 642 (offset -7 lines).
Hunk #4 succeeded at 781 (offset -1 lines).
Hunk #5 succeeded at 792 (offset -7 lines).
Hunk #6 succeeded at 859 (offset -1 lines).
Hunk #7 succeeded at 936 (offset -7 lines).
Hunk #8 succeeded at 955 (offset -1 lines).
Hunk #9 succeeded at 984 (offset -7 lines).
Hunk #10 succeeded at 1025 (offset -5 lines)

The other patches did not give this output.

After fooling around with this for MUCH too long, I found the patched files on your demo site, placed them in the right folders, and it worked without a problem.

Any help would be appreciated, I think this is a valuable contribution. Thx.

wrunt’s picture

It looks like the above patched correctly. The changes made were not on the same lines (hence the 'offset x lines' messages), but they still succeeded. Did the patched module work?

rj’s picture

It didn't, I had to download and use the files from your test site to get it to work. I have Drupal 5.11 and image 5.2-alpha3.

JollyMaeh’s picture

Hi wrunt,

i´ve installed the patch but it doesn´t work.

It says: Can´t create thumbnail and the original picture isn´t showed.

I have to show psd-files.

Greetings,

JollyMäh

wrunt’s picture

Version: 5.x-2.x-dev » 6.x-1.x-dev
StatusFileSize
new5.81 KB

I have updated this and the other two accompanying patches (#269329 and #269337) for D6.

egfrith’s picture

I believe that imageapi is heading for core:
http://lists.drupal.org/pipermail/development/2009-March/032407.html
, so I wonder if it would be worth seeing if this patch would have a good home at: #416254: Add equivalent of image_get_info() at the toolkit level

But I'm not 100% sure exactly what is going on with image stuff in D7.

joachim’s picture

In D7, filefield is in core, and imagefield as a wrapper on that will be in core too along with imagecache.
The current image module will most likely cease to exist, as everything it does will be available in core.

So I would only add this feature to image module if it's supported by core D7, otherwise there won't be an upgrade path.

egfrith’s picture

As long as the imagecache_coloractions module is ported to D7, this feature should work in D7. See #269337: Support for more image types (PDF, TIFF, EPS, etc.) for the changes in the core image toolkit functions that allow this and see #269329: ImageMagick support for more image types for a patch to D7 imageapi module that still needs revision and work.

See #366373: PDF support ( i.e. convert PDF to JPG support) for how it can work with patches to imageapi and imagecache in D6.

Although this feature will be available in D7, I would suggest that this bug is closed, as any code committed here is not going to make it to D7.

sun’s picture

Component: image.module » imagemagick toolkit
Status: Needs review » Closed (won't fix)

This is not going to happen for Image module for D6.