Using ImageMagick in a theme function.

Hello.

I would like to create a new image size on the fly inside my theme using ImageMagick.

It is installed and working (new derivatives are created when uploading filed) but doesn't appear to be accessible inside the theme.

When attempting: $image = new Imagick($originalImage); I get the error:

Fatal error: Class 'Imagick' not found in /var/www/omeka/themes...

How would I go about using ImageMagick inside my theme?

If possible, a simpler solution might be to change the default image size constraints under Appearance -> Settings. That, and/or customize the theme's CSS to display the size you need.

The error you are getting makes it look like PHP's ImageMagick package is not installed on the server. This is different from the default way that Omeka generates derivative images, which uses the command line convert command from the imagemagick server application. the PHP package just also makes use of that lower-level application.

Thanks for the reply.

Unfortunately, the Fullsize image size differs from what I am after, and using CSS is an option but will mean serving either a pixelated image (stretching the Fullsize image) or much too large a file (by getting it from the 'original' folder).

If there isn't a way to use Omeka's ImageMagick implementation from inside the theme, I'll have to look in to installing it on the server.

A third option would be to generate an additional image when they're added. Would you that's possible?

I don't think you can add a new derivative image type, but there are many deeper-down options for the existing derivative strategies, or creating your own, that might get closer to what you need. See File Derivative Strategies in the documentation.

Can you clarify what you're trying to do a little bit? It seems to me that if the main issue with using the original-size image is that it would be too large, then an appropriately-large setting for "fullsize" would fit the bill.

Is it that you're using fullsize for something else?

Currently, the 'fullsize' image is in use on each item page with no CSS to change the size. It's working perfectly.

The original images are vast (3000px+).

I am putting together a home page that uses a large header image (gathered from featured items), and these need to be around 1200px to strike a balance between file size and dimensions. The 'fullsize' image is far too pixelated and the originals are too heavy.

When a featured item image is to be shown on the front page, take the original file and resize, store and return it. On any subsequent request, the stored image should be returned.

I've used a function in WordPress that does exactly what I need in the past: https://github.com/developerbmw/img_resize

Okay well if you really want to do that, the thing with the "Imagick" class is that it's part of a PHP extension. It'll only exist if you have the imagick extension installed.