Posted by keep smiling on April 13, 2009 at 2:43pm
Jump to:
| Project: | Acidfree Albums |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | major |
| Assigned: | mwheinz |
| Status: | closed (fixed) |
Issue Summary
While creating acidfree album's images, the rotating option doesn't work..
even after setting it to clockwise or anti clockwise, the pic is in the same old position..
Pls help..
Comments
#1
moving yet another misplaced support request.
#2
Was there any more info found out about this? I'd like to ask the orig error reporter (keep smiling) more about his/her setup.
For me, same observation: "rotate doesn't seem to do anything". One thing I can contribute to the conversation is that my setup has Node Weight-- it seems that when I enabled that many months ago, I was unable to do some things against the node.
Where should we go to find error logs on this to provide more info? I see nothing reported in watchdog..
#3
This might be the user perception due to browser caching - When asking Acidfree to rotate, it _does_ work, but the browser refuses to download the photo if it is already cached. In my case (using Iceweasel (basically Firefox) ), I had to open the just rotated image (not the page, but just the image) and hit reload.
#4
Hi - Yes, I've fallen to the browser caching perception issue before. This is definitely not rotating. Again, it is possibly due to interaction with another module like node weight: Since there is no additional info, I will try to do more research on my end and report back what I find out.
#5
Confirmed. Rotate works when you edit an image, but not when you upload it. It appears to have been disabled.
Turning it on causes image uploads to fail. It appears that even though the information has been added to the database, the file still isn't in the files/images directory, causing the rotation to fail.
#6
Bumping the priority to help order the things I'm working on.
#7
Partial success - in the current dev code, the rotate takes effect, but image doesn't recognize that it must rebuild the preview and thumbnail.
#8
Okay, I had literally written a comment about how I was ready to give up on this. Apparently there isn't a single module that uses the image_rotate() function, and the only thing I got from trying it was I found a bug in the image module, so I stomped off to the... errr... thinking room for a short break, and it occurred to me how to do it.
The new code uses a two-stage rotate operation. At the "presave" point, the original image is rotated. At the "update" or "insert" point (after the image is in the db) I re-load the node (had to, couldn't avoid it) and tell the image module to rebuild the derivative images for it.
Works like a charm.
#9
Here's the patch, if anyone cares.
Index: acidfree_image.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/acidfree/types/acidfree_image/acidfree_image.module,v
retrieving revision 1.1.2.11
retrieving revision 1.1.2.12
diff -u -d -p -r1.1.2.11 -r1.1.2.12
--- acidfree_image.module 15 Feb 2011 02:57:03 -0000 1.1.2.11
+++ acidfree_image.module 23 Feb 2011 19:38:55 -0000 1.1.2.12
@@ -100,16 +100,35 @@ function theme_acidfree_print_thumb_imag
return $imagediv;
}
-function _class_image_rotate(&$node) {
- if ($node->rotate != 0) {
- $large_path = file_create_path($node->images[IMAGE_ORIGINAL]);
- $ret = acidfree_rotate_image($large_path, $node->rotate);
- $filesize = filesize($large_path);
- db_query("UPDATE {files} f JOIN {image} i ON f.fid=i.fid SET filesize=%d WHERE filename='%s' AND nid=%d",
- $filesize, IMAGE_ORIGINAL, $node->nid);
- $node->rebuild_images = true;
- unset($node->rotate);
- image_update($node);
+function _class_image_rotate($op,&$node) {
+ /* Because of the way the image module works,
+ * we have to do rotates in two stages. First, we rotate the original
+ * at the "presave" stage. Then, when the final files have been written
+ * we tell the image module to regenerate the smaller images.
+ */
+ if (($op == 'insert' || $op == 'update')) {
+ if ($node->nid && $node->rebuild_images) {
+ $n2 = node_load($node->nid);
+ $n2->rebuild_images = true;
+ image_update($n2);
+ $node->rebuild_images = false;
+ }
+ } else if ($op == 'presave') {
+ if ($node->rotate != 0 || $node->rotate == 'auto') {
+ $large_path = file_create_path($node->images[IMAGE_ORIGINAL]);
+ $ret = acidfree_rotate_image($large_path, $node->rotate);
+ if ($ret) {
+ $filesize = filesize($large_path);
+ db_query("UPDATE {files} f JOIN {image} i ON f.fid=i.fid SET filesize=%d WHERE filename='%s' AND nid=%d",
+ $filesize, IMAGE_ORIGINAL, $node->nid);
+ $node->rebuild_images = true;
+ } else {
+ drupal_set_message("Image rotation failed.",'warning');
+ }
+ unset($node->rotate);
+ }
+ } else {
+ drupal_set_message(__FUNCTION__ . ": Invalid operation, $op", error);
}
}
@@ -150,12 +169,17 @@ function acidfree_image_form_alter(&$for
}
*/
+ $exiftran = variable_get('acidfree_path_to_exiftran','/usr/bin/exiftran');
$rotate_options = Array(
'270' => t('Counterclockwise'),
'0' => t('No rotation'),
'90' => t('Clockwise'),
- 'auto'=>t('Use exif orientation tag'),
+ '180' => t('Inverted'),
);
+ if (is_executable($exiftran)) {
+ $rotate_options['auto']=t('Use exif orientation tag');
+ }
+
$form['rotate'] = array(
'#type' => 'select',
'#title' => t('Rotate image'),
@@ -182,12 +206,13 @@ function acidfree_image_nodeapi(&$node,
if ($node->type != 'image') {
return;
}
- //drupal_set_message(__FUNCTION__.": $op (" . print_r($node,1) . ")");
+ //drupal_set_message(__FUNCTION__.": $op ({$node->nid})");
switch ($op) {
- case "update":
case "presave":
+ case "update":
+ case "insert":
// if it is an image node, check to see if we need to rotate it
- _class_image_rotate($node);
+ _class_image_rotate($op,$node);
break;
case "view":
$node->content['body']['#weight'] = 1;
#10
Automatically closed -- issue fixed for 2 weeks with no activity.