Server side image manipulation / replacement of imagefield files using imageapi functions

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
Alan D.'s picture

As anyone done any work on an idea such as this? I have a few images that need minor cropping or rotation and it is a pain to have to modify and re-upload the files, especially when using ImageField Extended that stores a lot of additional information against the original file (ImageField does not have a replace function!)

The UI for my idea is something like this:


[thumbnail] | title, alt, etc
       [edit image] [replace image]
       [remove]


The edit / replace would be popup divs.

The replace would be a simple form with a file field to replace the image.

This would upload the new file & run it through any validation functions, update the delta file references, etc, delete the original file.

The edit would be something similar to the ImageCache preview page, but actions would be saved in the session so that when the user is happy with the changes, they can apply and modify the original file and any corresponding imagecache thumbs would be deleted.

Eg:

[ Preview area ]
(*) original image ( ) preview image ( ) Both ..... radios for toggling the live preview generated using the selected actions or the original image or maybe both side by side.

Selected actions (dragable)
[] Resize 450px by 300px
[
] Rotate 90 degress
[ ] Some action that would be bypassed

Add new action
[ Actions \/ ] [ Add ]

[Update original image] [cancel]

Love any feedback, especially if something like this already exists!!!!!!

Comments

The closest thing that i've

Scott J's picture

The closest thing that i've seen is Picnik module. I've installed it, but haven't got it working yet.

Have you tried ImageMagick raw action module?

Scott Jackson
Wollongong Australia

Hoping for tight imagefield integration

Alan D.'s picture

Thanks Scott

The main issue is the need to update imagefield images without losing the other metadata. My wife keeps uploading photos to our site which need updating, and we have about 15 additional fields per image making it a pain to update individual images.

I've started a new module for this yesterday, replace is 50% there, but functional, and the UI for the editor is nearly there, but still has a day or two worth of work to get it to an early alpha version. The AHAH bits always cause headaches with Drupal, I may have to look at doing it myself using pure AJAX on the sub-form components. I may upload it here if someone is interested. It's great to see that there is a hook_image_update() in Drupal 7, which will make things easy, like flushing imagecache presets, etc. We are traveling through Baja, so lack of time, power & wifi will be an issue, but hopefully I'll get another chance to work on this in a week or so.

Cheers

Basic alpha version

Alan D.'s picture

This is a basic alpha version / prototype that I've made for a personal website. It is functional but has a few bugs. It is good enough for my own use, but not for general release.

Dependencies

imagefield
imageapi
imagecache
modalframe

Issues

There appears to be a delay in the preview when adding new actions, so after adding a new action you need to preview it again before seeing the applied action.
There doesn't appear to have any validation applied to the actions. This causes invalid actions to be ignored, but doesn't appear to cause any additional errors. (Possible security issues with unvalidated GD command parameters maybe?)
Only uses the GD toolkit.
There is no direct feedback to the node forms ImageField, thus being confusing to an end user.
The {files} table should have the file size parameter updated.
Limit the editor to local files, or figure out how to localize the results and what tables need updating to reflect this.
There is a bug in the Modal Frames module that prevents the modal window from closing when there are forms with AHAH based elements present. This prevents the window from closing when either the Cancel or Update original image buttons are clicked.

Enhancements

Refactor it to enable the use of any web-based editor, not just ImageCache / ImageAPI. If I was going to release this as a project, this would be on the top of the todo list.
Look at using a different file name to prevent caching issues, currently it simply overwrites the file in the server. Need to look at all related schema.
Decipher and apply a non-global permission to access the editor, currently it is restricted by "edit any image file" permission.
Better handling of badly configured permissions on the file directory.
Moving all styles into an external style sheet. These are currently all inline.
Providing more feedback, such as at the end of the Drop n Drag of the actions, when selecting different preview modes, etc

The links to the project are:

http://www.etaunknown.com/files/imagefield_editor.zip

And some screen shots:

http://www.etaunknown.com/files/imagefield_editor_imagefield.png - the buttons on the ImageField fields
http://www.etaunknown.com/files/imagefield_editor_sshot_1.png - clean loaded window
http://www.etaunknown.com/files/imagefield_editor_sshot_2.png - adding a new action
http://www.etaunknown.com/files/imagefield_editor_sshot_3.png - editing two existing actions at once
http://www.etaunknown.com/files/imagefield_editor_sshot_4.png - the preview window with the 4 actions applied (scaled desaturated image with rounded corners)

I may be able to help co-maintain, but I will not have the time to be the primary maintainer.

Cheers

Alan

PS: The ImageCache Actions module provides the additional actions such as the Rounded corners effect.

any updates?

nkurach's picture

Hi Alan D.

I just wanted to check with you about your module above. The image replacement piece is something I've been searching hi and low for. I have an ImageField with many additional data fields and that uses FileSources to select an image from the server. Ideally the user would be able to replace that image with a new image from the server, instead of starting over with a new image and re-entering all the content.

Just wanted to check before I start down the road of modifying or building a new module!

Thanks!

  • Nathan

Image

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: