Will this module be ported to Drupal 7? I am using it on all my D6 and have just started to use Drupal 7 and it would be real sweat if it will be ported.

Comments

dman’s picture

It's going to happen. he tinterface to imagecache (now partly in core) should be stable or consistent, so I don't see any reason why it will be too hard.
I'll have to put it off until I've got a planned project using 7 before I dedicate any unsponsored time to it though.

tsvenson’s picture

Nice. I've actually already made one site, http://www.nutshell.nu, live on Drupal 7 alpha 5 this week and have not run into any big issues, same with the contributed modules I am using.

Unfortunately I don't have the resources (yet) to sponsor a port, but I will offer to help testing and evaluating it when you do find the time and/or sponsor for such a project.

ryan.armstrong’s picture

Same here, I would love to see this for Drupal 7, it's a great module!

Jackinloadup’s picture

subscribe

rwohleb’s picture

subscribe

mike503’s picture

Yeah I was looking for "Define Canvas" which I was using in D6, but it's not available in D7 yet :(

nwe_44’s picture

subscribing

fultonchain’s picture

subscribe

vood002’s picture

Subscribing, happy to help test

justmagicmaria’s picture

+1 on this request.

atobis’s picture

subscribe

scott falconer’s picture

Status: Active » Needs work
StatusFileSize
new158.46 KB

Here's a first shot at a d7 version. Core API changes, code style changes, etc.

Seem to be working as intended:
- canvasactions
- coloractions

Needs testing:
- autorotate

Still needs work:
- customactions (Should just need a few changes around the DB interface)
- testsuite

dman’s picture

Excellent. I was hoping to branch this over the weekend but missed that (Lovely Summer).
I'll try to make some time for that. Got some solid work on right now.

But this roll is much appreciated, I hope I can get it out there soon!

dman’s picture

Version: » 7.x-1.x-dev
Status: Needs work » Needs review

OK.
I've put a new DRUPAL-7--1 branch up. Looks like you've been busy to get it that far, thanks!!
I'm dropping the 'tests' snippets idea altogether. I really wanted to get a solid test suite happening before I tried the upgrade, but I failed, so I'll remove those directories. Tests from now on I'll be bundling as exportable 'features'
Forget 'testsuite'

I had a small modification done to the D6 branch to support Features import/export, so I had to do a little of the patching by hand. About to start reviewing it now.

YES
- watermark works.
- watermark basic positioning works.
- watermark alpha works.
- watermark advanced positioning (right+100, bottom+100) works.

- define_canvas I got going after some work. color picker is still AWOL though.
- colorize works
- alpha transparency now works again, was aborting a bit on big images (alpha process on huge images is expensive), I've loosened the limitation. slow.
- brightness OK
- negative OK (removed a small warning)

- rounded corners (all) works
- rounded corners (individual) works

- textactions are gone - will be in a different module imageapi_textactions.

- aspect switcher - works, needed readjusting so that it's safe to export as features.
- Looks like some code there needs investigating, we are now inheriting a number of things that imageapi used to do for us - I need to see if I can find what those routines have been renamed to.

Great, thanks for your kick-start!

I'll try again to figure out what I can do for a real test suite.

HELP APPRECIATED if anyone wants to poke the effects - please find AND FIX any bits that are not working fully yet.
But it looks like most of the basics are now there.

http://drupal.org/node/999846
Take a fresh CVS, not that patch, many things are a bit adjusted.

Scott, do you want CVS? I would appreciate some help now I'm trying to track two branches. I like what you did, always appreciate a code clean-up!

dman’s picture

StatusFileSize
new2.05 KB

Here's a "feature" package of half-dozen test image styles I used.

If you enable features and install these, you should see them in action.

scott falconer’s picture

Glad I could help. CVS access would be great as I'm working on a project now that will make heavy use of imagecache_actions, so I'm sure I will have plenty to contribute back.

dman’s picture

You have CVS!

will_in_wi’s picture

Subscribe

idiotprayer’s picture

Turned this on today, thanks for the work so far. A few things I ran into before I could get parts of it working. I have hacked around them for now, and I'm sure one of you who is more familiar will have better solutions than I. These seem to be rather large structural flaws that I can't wrap my head around now, considering the first problem I ran into immediately upon enabling.
Fatal errors on both imagecache_rgb_form() and hex_to_rgb() in utility-color.inc, redeclared function. I commented out both of these as I have no need of this functionality for now anyway.
The functionality I do need is in rounded_corners.inc. I had to change line 130, due to parameter expected to be a reference error.

-  function image_gd_roundedcorners(&$image, $action = array()) {
+  function image_gd_roundedcorners($image, $action = array()) {
scott falconer’s picture

StatusFileSize
new16.2 KB

The patch attached brings utility.inc up to date with what's in the latest 6x branch (with a few changes) and everything seems to work as it should. I'm still wrapping my head around the code a bit, so let me know if this seems right and I'll get it committed.

dman’s picture

@idiotprayer I apologize for some inconsistencies in the includes.
I had been attempting to break out the dependencies a little - what used to be one large set of util functions has been broken out into a few more specific libraries that the relevant submodules call when they want. Unfortunately sometimes I missed an include() that was needed, but didn't notice if another module was enabled that had already included the library.
Basically, the state of the inc libraries needs some rationalization. Architectural improvements welcome.

mstrelan’s picture

subscribe

serg2’s picture

subcribing

traceelements’s picture

subscribe

dman’s picture

I'm on holiday but intend to push a working release out when I get back to my desk. 3 weeks away from the laptop and in the sun instead is being enjoyed. But with d7 release a reality I'll see what I can do in the new year. Promise.

traceelements’s picture

Thanks so much, dman! Have a good new year!

Branjawn’s picture

subscribe

drupa11y’s picture

Define Canvas and Underlaying (Background) still are creating errors:
Fatal error: Cannot redeclare imagecache_rgb_form() in /Applications/MAMP/htdocs/drupal-7.0/sites/mori.d7.dev/modules/media/imagecache_actions/utility-color.inc on line 15

Version was the latest dev-version available for download.

After applying the "imagecache_actions-818798.19.patch":
Fatal error: Call to undefined function imagecache_rgb_form() in /Applications/MAMP/htdocs/drupal-7.0/sites/mori.d7.dev/modules/media/imagecache_actions/canvasactions/canvasactions.inc on line 60

Rotate image e.g. works.

drupa11y’s picture

Underlay background now works ;-)

fietserwin’s picture

Defining a canvas with:
- "Resize canvas under image (possibly cropping)" checked
- exact size fields left empty
- relative size fields filled in

gives me:
Fatal error: Call to undefined function imagecache_actions_hex2rgba() in D:\Projecten\Drupal7\www\sites\all\modules\imagecache_actions\canvasactions\canvasactions.inc on line 215

Note: this function is called in canvasactions.inc and in coloractions/transparency.inc

fietserwin’s picture

#30 was solved by applying the patch from #20 to the December 16, 2010 version at http://drupal.org/node/999846 (and installing imageapi that now is required))

However, now I get a:
Warning: Parameter 1 to image_gd_definecanvas() expected to be a reference, value given in image_toolkit_invoke() (regel 98 van D:\Projecten\Drupal7\www\includes\image.inc).

And after fixing that, the same on parameter 1 and 2 of image_gd_overlay in imageapi_image_overlay.inc

Fix by removing the & from the mentioned parameters, both in the gd and imagick versions of the mentioned functions. Objects don't need to be passed by reference if you want to change properties of the object (only if you want to assign another object to the variable)

fietserwin’s picture

And another one:

file canvasactions/canvasactions.inc:

function canvasactions_definecanvas_image(&$image, $action = array()) {

  // May be given either exact or relative dimensions.
  if ($action['exact']['width'] || $action['exact']['width']) {
    ...

Seems to be an error to check on the width twice, the 2nd check probably should be on height

sludwig’s picture

subscribe

fietserwin’s picture

I tested "define canvas" using Imagemagick and found the following error:
(note: define canvas using imagemagick is not yet supported, but as there seemed to be an implementation, I thought to give it a try)

file: canvasactions.inc
function: image_imageapi_imagemagick_definecanvas
error: single quotes are added around the arguments, leading to error messages from convert

Configuration:
Windows Vista with

Version information for convert

Version: ImageMagick 6.6.1-6 2010-04-23 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2010 ImageMagick Studio LLC
Features: OpenMP

The ImageMagick convert binary was located and return this version information.
Version information for identify

Version: ImageMagick 6.6.1-6 2010-04-23 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2010 ImageMagick Studio LLC
Features: OpenMP

The ImageMagick identify binary was located and return this version information.

The error messages from convert on stderr:

convert.exe: unrecognized color `'#333333'' @ warning/color.c/GetColorInfo/946.
convert.exe: invalid geometry `'184x139-2-2!'' @ error/geometry.c/ParseGravityGeometry/990.
convert.exe: unrecognized color `'#333333'' @ warning/color.c/GetColorInfo/946.
convert.exe: invalid geometry `'184x139-2-2!'' @ error/geometry.c/ParseGravityGeometry/990.
convert.exe: unrecognized color `'#333333'' @ warning/color.c/GetColorInfo/946.
convert.exe: invalid geometry `'184x139-2-2!'' @ error/geometry.c/ParseGravityGeometry/990.
convert.exe: unrecognized color `'#333333'' @ warning/color.c/GetColorInfo/946.
convert.exe: invalid geometry `'184x139-2-2!'' @ error/geometry.c/ParseGravityGeometry/990.

Removing the single quotes works fine and as other actions don't add single quotes as well I think this is an error.

fietserwin’s picture

And another one:

file coloractions/imagecache_coloractions.module:
function: function imagecache_convert_form:

    'format' => array(
      '#title' => t("File format"),
      '#type' => 'select',
      '#default_value' => isset($action['format']) ? isset($action['format']) : 'image/png',
      '#options' => imagecache_file_formats(),
    ),

Should be (i.e. remove 2nd isset on default value):

    'format' => array(
      '#title' => t("File format"),
      '#type' => 'select',
      '#default_value' => isset($action['format']) ? $action['format'] : 'image/png',
      '#options' => imagecache_file_formats(),
    ),

EDIT: Just found that this one is also reported for Drupal 6: #980408: Imagecache_convert action always reverts to ‘jpg’

fietserwin’s picture

See: #1022758: Convert format for imagemagick toolkit (with implementation) for implementation of convert format for imagemagick toolkit.

fietserwin’s picture

I think that function imagecache_imagefilter (in file imagecache_coloractions.module) should make use of image_toolkit_invoke. This will lead to something like (not tested):

function imagecache_imagefilter($image, $data) {
  $data += array('filter_arg2' => null, 'filter_arg3' => null);
  $success = image_toolkit_invoke('imagefilter', $image, $data);
  //$funcname =  'imageapi_' . $image->toolkit . '_imagefilter';
  //$success = $funcname($image, $data['filter'], $data['filter_arg1'], isset($data['filter_arg2']) ? $data['filter_arg2'] : NULL, isset($data['filter_arg3']) ? $data['filter_arg3'] : NULL );

  if (! $success) {
    watchdog('imagecache', 'imagecache_imagefilter failed. image: %image, data: %data.', array('%path' => $image, '%data' => print_r($data, TRUE)), WATCHDOG_ERROR);
    return FALSE;
  }
  return TRUE;
}

/**
 * Attempt to run imagefilter, which may or may not be included with your
 * gdtoolkit. If it isn't, a local script is used to emulate the simpler of its
 * functions.
 */
function image_gd_imagefilter($image, $data) {

  // some distros that allegedly include PHP5 GD2 are faulty.
  // thankyou http://www.weberdev.com/get_example-4601.html
  if (!function_exists('imagefilter')) {
    include_once DRUPAL_ROOT . '/' . 'imagefilter.inc';
  }
  $info = $image->info;
  if (!$info) {
    return FALSE;
  }
  #dpm("run imagefilter imagefilter($image->resource, $filter, $arg1, $arg2, $arg3)");

  imagesavealpha($image->resource, TRUE);

  # This is a bit silly really, php internals complain if it's given TOO MANY args!
  # Should refactor this and not be so lazy.
  if (!is_null($data['filter_arg3'])) {
    return imagefilter($image->resource, $data['filter'], $data['filter_arg1'], $data['filter_arg2'], $data['filter_arg3']);
  }
  else if (!is_null($data['filter_arg2'])) {
    return imagefilter($image->resource, $data['filter'], $data['filter_arg1'], $data['filter_arg2']);
  }
  else {
    return imagefilter($image->resource, $data['filter'], $data['filter_arg1']);
  }
}

/**
 * Try to emulate some imagefilter actions with imagemagick.
 */
function imageapi_imagemagick_imagefilter($image, $data) {

  switch ($data['filter']) {
    case 4: # colorize
      $R100 = round($data['filter_arg1'] / 255 * 100);
      $G100 = round($data['filter_arg2'] / 255 * 100);
      $B100 = round($data['filter_arg3'] / 255 * 100);
      $image->ops[] = "-fill rgb\\($R100,$G100,$B100\\) -colorize 50\\%";
      return TRUE;
      break;
  }

  drupal_set_message("Imagefilter is only currently supported for GD toolkit. Code welcome.", 'error');
  return FALSE;
}

(I just see that the optional include of imagefilter.inc points to the wrong dir...)

dman’s picture

The imagefilter function in general is not available outside GD. It's a messy func, and shouldn't be emulated for imagemagick.
What is supposed to happen is the individual actions ( imagecache_brightness_image etc ) should really be delegating to their own image_gd_brightness() sort of mini-funcs earlier on in the piece.
Re-using the GD 'imagefilter' function was just to avoid creating 8 trivial stub functions that did nothing except end up in the same place in the end anyway.
BUT if imagemagick versions for each of these actions is to be added, then yes, we should refactor the calls to use image_toolkit_invoke at the beginning of the process (imagecache_brightness_image) not half way through.

fietserwin’s picture

In addition to #34, when I tested the changes on a Linux server, it turned out that $backgroundcolor has to be escaped, but with the proper escape sequences for the actual platform. So use escapeshellarg(). The `resize canvas above image` option did not work at all, so I rewrote and tested that as well (on Linux and Windows) (see http://www.imagemagick.org/Usage/canvas/#solid for an explanation of the change).

file: canvasactions.inc
function: image_imageapi_imagemagick_definecanvas
new code:

function image_imageapi_imagemagick_definecanvas($image, $action = array()) {
  $targetsize = $action['targetsize'];
  $RGB = $action['RGB'];
  $backgroundcolor = $RGB['HEX'] != '' ? '#' . $RGB['HEX'] : 'None';
  $backgroundcolor = escapeshellarg($backgroundcolor);

  # TODO needs work.
  #
  $background = "-background $backgroundcolor";
  $crop = "-crop {$targetsize['width']}x{$targetsize['height']}-{$targetsize['left']}-{$targetsize['top']}!";

  if ($action['under']) {
    $extent = "-extent {$targetsize['width']}x{$targetsize['height']}-{$targetsize['left']}-{$targetsize['top']}!";
    $compose = "$background $crop $extent";
  }
  else {
    // see http://www.imagemagick.org/Usage/canvas/#solid
    $draw = "+matte -fill $backgroundcolor -colorize 100%";
    $compose = "$background $crop $draw";
  }

  $image->ops[] = $compose;
  return TRUE;
}
fietserwin’s picture

@#38: #37 was indeed an aside for me. I did not use it, so did not test it. I just stumbled upon it and thought let's mention it, hoping to arrive at a "correct" first official Drupal7 version.

kevin p davison’s picture

Subscribe, and please add a DEV or alpha version so more can test it out.

LEternity’s picture

I patched the Dec 16 version with #20 and got rid of the error described in #30. The rounded corner function isn't working. Please follow #41's request so more people will join in. Great module!

fietserwin’s picture

@#41,#42: downloadable via "view all releases": http://drupal.org/node/263664/release, this is the 16 December release, so you will have to patch with #20.

My remarks so far are not available as one patch. I might produce one as soon as I have my site running stable. But hopefully dman can catch up with all remarks, as I guess that a patch against the december 16 version won't help him that much. If you want I can zip my local version as a whole.

kiyoshin’s picture

subscribe

Countzero’s picture

Thanks a lot for the patch in #20.

Applied to the 16th december version, it almost worked.

I only had to move the hex_to_rgb and imagecache_rgb_form to utility.inc from utility-color.inc to avoid the include/missing function loop described here http://drupal.org/node/1031588#comment-3984954.

Aleksey Zubko’s picture

Countzero, thanks a lot for your comment.

I apply patch in #20, after that move the hex_to_rgb and imagecache_rgb_form to utility.inc from utility-color.inc Then I have error such as in comment #31 and fixed them.

Watermarks work fine :)

fietserwin’s picture

StatusFileSize
new50.4 KB

A patch containing all my remarks (between #31 and #39) and the patch from #20. So in fact this is one large patch against the 16 december dev version containing all(?) remarks in this thread so far.

Actually, I think this patch is growing too large. Is there some way we can get this patch (or at least the most important changes in it) into a new dev version and from then on separate all issues mentioned here into separate issues?

andypost’s picture

subscribe

fuse’s picture

Should rounded corners work after applying this patch? Still can't get it to work.

fietserwin’s picture

@#49: I did not look into that.

There is a D7 version published on the project page now, so we should start to file and patch separate issues. However to not loose all the work in the patch, I hope dman, as practically the only committer for this project, will catch up.

On the other hand, with the imagapi imagemagick toolkit project being phased out (#1028876: Future of ImageMagick toolkit), I'm afraid that yet another big rewrite will be needed.

dman’s picture

Yeah sorry guys, I have the hugest project on right now, and it's *not* D7, so it's a bit of a brain-strain to be working on two architectures at once.
I did look at the patch #47, but most of the bulk of it is whitespace changes - probably due to someones editor helpfully stripping trailing whitespace. So it's a big job to go through it line by line.
/however/
Seeing as to my mind the D7-dev is totally unreviewed (by me) so far, there is no great harm in trying to whack the whole patch at it without testing.
At least that will clear the decks and get us up to speed for the next round?

I'll commit everything here (unreviewed, untested) *iff* it applies cleanly. Let's see...

dman’s picture

Status: Needs review » Fixed

OK. Yes, that was a clean patch - Nothing had been committed since before Christmas, as I guess everybody had noticed, so the Dec version was just fine.

I HAVE PUT #47 in to the current 7-dev.
I'm seeing issues already, but won't attack them just yet.
So, as fietserwin says, finish this thread, start new issues against D7-dev and we may be able to manage more progress.

Thanks for your patience fietserwin. I've been up to my ears in feature-driven deployments. Sorta needed all my attention on it. No flash graphics this month.

dman’s picture

fietserwin’s picture

Thanks dman, I understand your situation. I had a smaller project and decided to give D7 a try to see if the modules I normally use were reliable and usable and to see if I could add some fixes, requests, etc. to D7 modules. I managed to get it all running but have posted quite some issues, though most of them were warnings due to the stricter error level of D7. For this module it was more lack of imagemagick support that wasn't there in D6 either. But the client wanted rotated thumbnails and those are *so* ugly with GD (no anti-aliasing), so I decided to try to fix those issues.

Any ideas on the future of this module (in D7, in the context of sun's activity on imagemagick)?

dman’s picture

I've never fully got behind imagemagick, it's just not something I use, apart from as a very simple commandline tool.
I've lost days trying to get the smallest things working, and it's seldom available on a number of medium-level hosts. So basically, I don't care much.
GD has issues, but at least I can understand them, and work around them using maths.

That said, I did manage to fix up D6-2.x imagemagick support to 98% around new year. overlays, borders, offsets etc all do their thing now. They just were not happening right before
If I get around to it, that can be ported to D7. I guess.

michaelfavia’s picture

Subscribe. Well done here guys. Next project i have needs watermark support so i was just checking in. Happy to help push the boulder a little further if this isn't resolved by the time i need it. Thanks for the hard work.

dman’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

witchcraft’s picture

Subscribe.

p.selfin’s picture

Fatal error: Call to undefined function imagecache_rgb_form() in /Applications/MAMP/htdocs/drupal-7.0/sites/mori.d7.dev/modules/media/imagecache_actions/canvasactions/canvasactions.inc on line 60

Just enable all submodules in ImageCache Actions
--
Sorry for my english

dman’s picture

Yeah, sounds like one of the libs is depending on another that was'nt included. Sorry, my test suites are usually "turn everything on, test everything" . Have not tried every possible permutation. This one lib moved around a few times between versions, the required file prob got renamed.

Seems canvasactions needs to be sure to get the color form library. (I made things TOO modular)

boon4376’s picture

I just wanted to give a big thanks to whoever is working on the Drupal 7 version. I am building an e-commerce site in D7 with Ubercart and the image cache actions have been invaluable for our product displays... Mostly the "define canvas" option for generating thumbnails.


Thanks Again!!!