Adding new Derivative Type

X-101

Joined: 2009-02-05
Posts: 5
Posted: Thu, 2009-02-05 09:46

Hi all,

I'm creating a module (with gallery2.3) that will create a new derivative type and handle the rendering of it. Is there a "correct" way to do this. I'd like to do this entirely within the module, but there doesn't seem to be a way to register a new type without hacking the core classes. Any suggestions?

Thanks

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Thu, 2009-02-05 11:17

Interesting. What's your derivative going to be?

 
X-101

Joined: 2009-02-05
Posts: 5
Posted: Thu, 2009-02-05 13:41

I've written a module to allow me to embed the IIPImage high resolution image viewer (see http://iipimage.sf.net) into Gallery. But, as the system requires images to be in a tiled multi-resolution TIFF format, I've created a special derivative type and a toolkit to generate these. The module renderer can then embed the Ajax viewer if the image is suitably flagged.

I think doing this as a new kind of derivative image makes sense. The problem is that derivative type information is hard-wired into the Gallery core. Perhaps there is a better way to do this than via a derivative? Any suggestions would be welcome.

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Thu, 2009-02-05 13:47

Could it not be handled as a new type of GalleryItem?

 
X-101

Joined: 2009-02-05
Posts: 5
Posted: Thu, 2009-02-05 14:29

The tiled multi-resolution image needs to be generated by Gallery from the source image so logically it's a kind of derivative image. Perhaps it could be done through a GalleryItem but it seems to me even more of a hack than changing the derivative types!

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Thu, 2009-02-05 14:53

ok... engaging brain now...

Derivatives can be of any MIME-type, and your derivativeOperations string has your custom operation which is handled only by your custom toolkit. Why therefore does it have to be a new *kind* of derivative? Can it not be just another resize?

 
X-101

Joined: 2009-02-05
Posts: 5
Posted: Thu, 2009-02-05 15:19

I guess this could be a solution. Although the image is not resized in any way, I could just mark it as such to simplfy things.

 
alecmyers

Joined: 2006-08-01
Posts: 4342
Posted: Thu, 2009-02-05 15:31

Otherwise yes I think you have to hack core. I was interested once in creating a Black-and-white derivative type, but I think I decided it would have to be classed as a "resize".

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Thu, 2009-02-05 16:56

For the transcode module, since there are no movie derivatives, we cheat, and just change the renderer on the source to the FlashVideoRenderer, and present the transcoded version as the preferred.
Then when searching for pre-existing derivatives of that type or we want to work on the transcoded derivative, we check the derivative operations for a "convert-to-video/flv" string.

There was talk of adding other derivative types, but I don't think it will happen.

-s

FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
X-101

Joined: 2009-02-05
Posts: 5
Posted: Thu, 2009-02-05 18:05

Well, thanks guys, I've now got it working as a fake resize type :)

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Fri, 2009-02-06 04:45

Did not read the whole thread but this pops up:
http://gallery.menalto.com/node/80713

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team