ImageMagick Engine - Version 1.7.1

Version Description

  • Use WP_Image_Editor class to generate filename
  • Tested compability with WordPress 5.8.1
Download this release

Release Info

Developer rickardw
Plugin Icon 128x128 ImageMagick Engine
Version 1.7.1
Comparing to
See all releases

Code changes from version 1.7.0 to 1.7.1

Files changed (2) hide show
  1. imagemagick-engine.php +19 -5
  2. readme.txt +6 -2
imagemagick-engine.php CHANGED
@@ -5,7 +5,7 @@
5
  Description: Improve the quality of re-sized images by replacing standard GD library with ImageMagick
6
  Author: Orangelab
7
  Author URI: https://orangelab.com/
8
- Version: 1.7.0
9
  Text Domain: imagemagick-engine
10
 
11
  Copyright @ 2021 Orangelab AB
@@ -35,7 +35,7 @@ if ( ! defined( 'ABSPATH' ) ) {
35
  * Constants
36
  */
37
  define( 'IME_OPTION_VERSION', 1 );
38
- define( 'IME_VERSION', '1.7.0' );
39
 
40
  /*
41
  * Global variables
@@ -330,6 +330,21 @@ function ime_filter_attachment_metadata( $metadata, $attachment_id ) {
330
  return $metadata;
331
  }
332
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
333
  // Get size & image type of original image
334
  $old_stats = @getimagesize( $ime_image_file );
335
  if ( ! $old_stats ) {
@@ -344,7 +359,6 @@ function ime_filter_attachment_metadata( $metadata, $attachment_id ) {
344
  $info = pathinfo( $ime_image_file );
345
  $dir = $info['dirname'];
346
  $ext = $info['extension'];
347
- $namebase = basename( $ime_image_file, ".{$ext}" );
348
 
349
  /*
350
  * Do the actual resize
@@ -367,7 +381,7 @@ function ime_filter_attachment_metadata( $metadata, $attachment_id ) {
367
  list($dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h) = $dims;
368
 
369
  $suffix = "{$dst_w}x{$dst_h}";
370
- $new_filename = "{$dir}/{$namebase}-{$suffix}.{$ext}";
371
 
372
  $resized = ime_im_resize( $ime_image_file, $new_filename, $dst_w, $dst_h, $crop, ime_get_resize_mode( $size ) );
373
  if ( ! $resized ) {
@@ -375,7 +389,7 @@ function ime_filter_attachment_metadata( $metadata, $attachment_id ) {
375
  }
376
 
377
  $metadata['sizes'][ $size ] = [
378
- 'file' => basename( $new_filename ),
379
  'width' => $dst_w,
380
  'height' => $dst_h,
381
  ];
5
  Description: Improve the quality of re-sized images by replacing standard GD library with ImageMagick
6
  Author: Orangelab
7
  Author URI: https://orangelab.com/
8
+ Version: 1.7.1
9
  Text Domain: imagemagick-engine
10
 
11
  Copyright @ 2021 Orangelab AB
35
  * Constants
36
  */
37
  define( 'IME_OPTION_VERSION', 1 );
38
+ define( 'IME_VERSION', '1.7.1' );
39
 
40
  /*
41
  * Global variables
330
  return $metadata;
331
  }
332
 
333
+ $editor = wp_get_image_editor( $ime_image_file );
334
+ if ( is_wp_error( $editor ) ) {
335
+ // Display a more helpful error message.
336
+ if ( 'image_no_editor' === $editor->get_error_code() ) {
337
+ $editor = new WP_Error( 'image_no_editor', __( 'The current image editor cannot process this file type.', 'regenerate-thumbnails' ) );
338
+ }
339
+
340
+ $editor->add_data( array(
341
+ 'attachment' => $this->attachment,
342
+ 'status' => 415,
343
+ ) );
344
+
345
+ return $editor;
346
+ }
347
+
348
  // Get size & image type of original image
349
  $old_stats = @getimagesize( $ime_image_file );
350
  if ( ! $old_stats ) {
359
  $info = pathinfo( $ime_image_file );
360
  $dir = $info['dirname'];
361
  $ext = $info['extension'];
 
362
 
363
  /*
364
  * Do the actual resize
381
  list($dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h) = $dims;
382
 
383
  $suffix = "{$dst_w}x{$dst_h}";
384
+ $new_filename = $editor->generate_filename( $suffix, null, $ext );
385
 
386
  $resized = ime_im_resize( $ime_image_file, $new_filename, $dst_w, $dst_h, $crop, ime_get_resize_mode( $size ) );
387
  if ( ! $resized ) {
389
  }
390
 
391
  $metadata['sizes'][ $size ] = [
392
+ 'file' => wp_basename( $new_filename ),
393
  'width' => $dst_w,
394
  'height' => $dst_h,
395
  ];
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: rickardw, orangelab
3
  Tags: image, images, picture, imagemagick, gd
4
  Requires at least: 3.0
5
- Tested up to: 5.8.0
6
- Stable tag: 1.7.0
7
 
8
  Improve the quality of re-sized images by replacing standard GD library with ImageMagick.
9
 
@@ -74,6 +74,10 @@ You'll probably have problems with various other plugins too unless you fix this
74
 
75
  == Changelog ==
76
 
 
 
 
 
77
  = 1.7.0 =
78
  * Add option to resize images interlaced
79
  * Fix: Don't attempt to regenerate SVG's.
2
  Contributors: rickardw, orangelab
3
  Tags: image, images, picture, imagemagick, gd
4
  Requires at least: 3.0
5
+ Tested up to: 5.8.1
6
+ Stable tag: 1.7.1
7
 
8
  Improve the quality of re-sized images by replacing standard GD library with ImageMagick.
9
 
74
 
75
  == Changelog ==
76
 
77
+ = 1.7.1 =
78
+ * Use WP_Image_Editor class to generate filename
79
+ * Tested compability with WordPress 5.8.1
80
+
81
  = 1.7.0 =
82
  * Add option to resize images interlaced
83
  * Fix: Don't attempt to regenerate SVG's.