Extracts of devel-list discussion regarding image module refactoring.

[Eric Scouten]

Here's my rather blunt opinion on image.module. It's trying to serve two rather different purposes:

  • (1) Serve as a site-wide and/or personal image gallery, providing navigation and categorization of the images.
  • (2) Allow users to add individual images to nodes. (Think of them as illustrations for news stories.)

Unfortunately, I think it does neither job well. I think the two purposes should be separated into separate modules.

I have a pressing need for something that does (2) well so I'm working on writing a new module I call attached_image. In my rendition of the module, images are no longer nodes in and of themselves, but rather attachments that live or die with an individual node. Images submitted through this module have no purpose outside of the node to which they are attached.

[Stefan Nategaal]

I'm sure we can use lot's of code, that Marco wrote, but I also think that
we need to split the project again into an;

  • - ImageAPI and
  • - FileAPI.

the FileAPI can be used to upload/download/manage/delete/administer files,
as where the ImageAPI can provide us with thumbnail generation, image
processing, manipulating images, all using GD1, GD2, ImageMagick or none of
them if they are not allowed at all..

[Moshe Weitzmann]

marco's code fileAPI already includes no image functions. to see the inetraction of how an image based modules uses the API, see fsgallery.module in his sandbox.

to those clamoring for a better image.module, I urge you to contribute *code* in addition to ideas. with the notable exception of bruno, noone has given this module much love since its original birth ... if you think it is a complete mess and want to start clean, you should look at marco's fsgallery.module which already uses the fs API and is far simpler (with fewer features).

[Bruno Rocci]

I agree it is time to refactor image module. Using Marco's fileAPI for the
image file handling, including upload is one interesting possibility, and
probably the best way to go. It will simplify the process but this will be
almost hidden to the end user, which is good actually.

Creating an imageAPI is something I had in mind for a while. But I prefer to
call it transformAPI, because I think making image transformations
more streamlined across the different graphical libraries (ImageMagick,
NetPbm, GD) will bring value. Having image module providing functions to
other modules, dealing with images, to scale, rotate images, to watermark
images, etc would be usefull, I think. But again, from the end user
perspective it won't bring much. It will mainly add flexibility to
administrator.

I see the future of image module as a part of the Drupal core, but in a more
simplified version. Extra features would be part of "companion" modules.
IMHO image module in the core should provide:

  • 1. image file handling (including upload) and storage via the file API
  • 2. basic image transformations with the most popular image libraries: ImageMagick, NetPbm, GD
    • - scaling, including creation of image "variations" not only thumbnails
    • - rotating (by 90° steps)
    • - text and logo watermarking
  • This could be extended by external module and supplied as a transform
    API.

  • 3. filter system to include images in nodes with a choice of sizes
    (thumbnail, small image, original image)
  • 4. node based taxonomy support
  • 5. support for custom fields (such as photographier name, etc)

The first "companion" module I see is obviously a gallery. We may provide
the same type of gallery as the current one, but the door is open to
implement a gallery in a different way, without impacting the core image
module. If you don't need private image gallery for your users, make you own
simplified image gallery.

Comments

jose reyero’s picture

Title: Refactoring image module » Refactoring image module: split module

I am currently testing the image module, which I like, and plan to use for some of my sites. But it seems to be too big and a bit complex, and for some sites I really don't need all the image gallery stuff, just the ability to upload images and use them in other nodes.

I think image module should be split in two -or more- inter-dependent modules and here is my proposal:

1. image.module - just keep the functionality to upload images as nodes and attach images to nodes.
2. imagegallery.module - all the stuff about keeping image gallerys and mass image uploading. This one will require image.module to be enabled.

Also the first module, image.module should check if the other module is enabled to add some links when displaying an image node.

And maybe, if you want to add advanced image manipulation functions, one more:

3. imagemanager.module -

jose reyero’s picture

Title: Refactoring image module: split module » Refactoring image module: proof of concept
Assigned: bruno » jose reyero

ok, I've done it and it's available from my sandbox (jareyero/image)

NOTES:

This is just an experiment splitting image.module, which I think is growing too big in smaller pieces.
I've also tried to provide some kind of image manipulation abstraction library

The new modules are
- image.module, handles images as nodes and provides the filter functionality
- imagegallery.module, provides support for galleries, requires image.module

Next files are the image manipulation library. Only the selected library is included, and only when required.
- image.imagemagick.inc
- image.gd1.inc
- image.gd2.inc

Just place all the files in the modules directory and try it.
* Notice that this overwrites the original image.module.
** Database tables must be created, fetch the sql script from the original image.module
*** This is just a proof of concept, so I advise you not to use it for a live system.

Feedback will be welcomed: drupal at reyero dot net

adrinux’s picture

FWIW this seems to work quite nicely, and I like it.

Bèr Kessels’s picture

Component: Code » gd toolkit

The new system is now contributed.

Anonymous’s picture