Comments

mondrake’s picture

Title: Part to Drupal 8 » Port to Drupal 8
sun’s picture

Looks like that sandbox is a clean porting effort based on this project's actual repo — would you like to get commit access for the 8.x-1.x branch?

mondrake’s picture

Status: Active » Needs review
StatusFileSize
new121.08 KB

Here's a patch against the current 7.x-1.x branch that would generate a possible 8.x-1.x branch. It's based on the work in the sandbox mentioned in the IS. There is review and more testing to do but locally this is working pretty much ok. I do not expect major changes to the image system API at this point of core development, so I thought it can be time to post here the current status of the sandbox.

A few points from the sandbox work:

  1. the former 'ops' array of command line arguments has been renamed and made protected in the toolkit. Toolkit methods have been introduced to manage the arguments.
  2. 'imagemagick_advanced' module is merged into 'imagemagick'
  3. implements automated tests based on GDToolkitTest - not sure they qualify for the automated testing infrastructure, but they work locally provided the convert executable can be accessed without need to specify a full path
  4. implements #2064223: image_imagemagick_get_info() should use Imagemagick Identify command
  5. implements #1551262: Rotate should alter dimensions
  6. in the rotate operation, a +repage operation is added, otherwise further operations like e.g. crop would not work properly because of changed image geometry
  7. following comments in #1967630: Images with non-ASCII characters in their filenames cannot be converted., #2112987: cannot convert images with UTF-8 filenames, #1502924: escapeshellarg() has problems with non-ASCII filenames, #352262: Non-ascii problems with imagemagick toolkit, and given that escapeshellarg() drops non-ascii characters (for filenames, but also if you want to use 'label:' Imagemagick commands), I replaced calls to escapeshellarg() with a method that just encapsulates strings between quotes. Something better could be done but for the time being it works.

Re. #2 I am fine to get commit access but can not promise to be able to maintain it ongoing, thanks.

mondrake’s picture

StatusFileSize
new11.76 KB
new123.75 KB

Couple of additions to #3:

  1. Following up on #3.7, implemented the solution proposed in #1502924: escapeshellarg() has problems with non-ASCII filenames.
  2. Using the identify command to parse image file (see #3.4), it is possible to retrieve the EXIF orientation tag from JPEG images, and manage it so that the auto-orientation image operation can track the image dimensions before applying further operations. So practically #1964064: auto-orient needs to (conditionally) change dimensions is implemented here.
berdir’s picture

Nice work, this seems to be working well.

The plugin isn't picked up after a module install, because the plugin managers aren't following the plugin.manager naming pattern, so the plugin_manager_cache_clear tag would need to be added those. Happy to review a core issue if you want to work on that.

mondrake’s picture

Thanks @Berdir, not really sure I grasp what you mean. I confirm I am also seeing the toolkit only after refreshing all caches after a module install. Is it a problem with the core image toolkits plugin manager? If so, would you mind creating a core issue for that - I would need more details before I can say if I can work on that.

mondrake’s picture

Title: Port to Drupal 8 » Imagemagick port to Drupal 8

Never mind, I think I understood. Created #2467775: Contrib toolkits are not picked up after module install in Drupal core issue queue.

aspilicious’s picture

Just some info. A closely related project http://www.drupal.org/project/imagick has also working code and a downloadable release.
Maybe it is a good idea to create a dev release as well for this module.

mondrake’s picture

StatusFileSize
new123.57 KB
new25.46 KB

Refreshed patch to take care of a few things that changed in core since #4 in Dec 2014 (immutable configuration, String class dropped).

Can anybody review core's #2311679: Separate MIME type mapping from ExtensionMimeTypeGuesser?

That would help to get rid of the workaround to get the image mimetype from the source format through a dummy filename

+++ b/src/Plugin/ImageToolkit/ImagemagickToolkit.php
@@ -0,0 +1,915 @@
+  /**
+   * {@inheritdoc}
+   */
+  public function getMimeType() {
+    // @todo change if extension mapping service gets in, see #2311679
+    $format = $this->getSourceFormat();
+    return empty($format) ? NULL : $this->mimeTypeGuesser->guess('dummy.' . $format);
+  }
+
+  /**
mondrake’s picture

StatusFileSize
new120.79 KB
new10.66 KB

Aligned to current sandbox:

#8: +1

andypost’s picture

Here's a big difference in modules - in-process and proc_open()
So maybe for 8.x better to merge them into one configurable module?

mondrake’s picture

Issue summary: View changes
StatusFileSize
new7.59 KB
new125.01 KB

Updated after core's #1364670: ImageStyle::transformDimensions unable to deal with all effects., now AutoOrientImageEffect::transformDimensions() can use the original image EXIF data to determine styled image dimensions.

Can a maintainer open a 8.x-1.x dev branch?

mondrake’s picture

Status: Needs review » Closed (won't fix)

I got co-maintainership of this module and made a first commit, however different from the patch in #12. Will create a new plan issue to move forward.