ImageMagick Engine - Version 1.7.0

Version Description

  • Add option to resize images interlaced
  • Fix: Don't attempt to regenerate SVG's.
  • Handle scaled images with wp_get_original_image_path
  • Bugfix cli executable respnsonse
  • Tested compability with WordPress 5.8
Download this release

Release Info

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

Code changes from version 1.6.5 to 1.7.0

Files changed (2) hide show
  1. imagemagick-engine.php +36 -6
  2. readme.txt +9 -2
imagemagick-engine.php CHANGED
@@ -5,10 +5,10 @@
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.6.5
9
  Text Domain: imagemagick-engine
10
 
11
- Copyright @ 2020 Orangelab AB
12
 
13
  Licenced under the GNU GPL:
14
 
@@ -35,7 +35,7 @@ if ( ! defined( 'ABSPATH' ) ) {
35
  * Constants
36
  */
37
  define( 'IME_OPTION_VERSION', 1 );
38
- define( 'IME_VERSION', '1.6.5' );
39
 
40
  /*
41
  * Global variables
@@ -56,6 +56,7 @@ $ime_options_default = [
56
  'quality' => -1,
57
  'size' => 70,
58
  ],
 
59
  'quality' => '',
60
  'version' => constant( 'IME_OPTION_VERSION' ),
61
  ];
@@ -241,6 +242,11 @@ function ime_set_option( $option_name, $option_value, $store = false ) {
241
  }
242
  }
243
 
 
 
 
 
 
244
  // Get image quality setting for type
245
  function ime_get_quality( $resize_mode = 'quality' ) {
246
  $quality = ime_get_option( 'quality', '-1' );
@@ -441,6 +447,10 @@ function ime_im_php_resize( $old_file, $new_file, $width, $height, $crop, $resiz
441
  $im->setImageCompressionQuality( $quality );
442
  }
443
 
 
 
 
 
444
  if ( $resize_mode == 'size' ) {
445
  $im->stripImage();
446
  }
@@ -503,7 +513,7 @@ function ime_im_cli_check_executable($fullpath) {
503
 
504
  ime_set_option( 'imagemagick_version', $output, true );
505
 
506
- return count( $output ) > 0;
507
  }
508
 
509
  /*
@@ -596,6 +606,10 @@ function ime_im_cli_resize( $old_file, $new_file, $width, $height, $crop, $resiz
596
  $cmd .= ' -quality ' . intval( $quality );
597
  }
598
 
 
 
 
 
599
  if ( $resize_mode == 'size' ) {
600
  $cmd .= ' -strip';
601
  }
@@ -630,7 +644,7 @@ function ime_ajax_regeneration_get_images() {
630
  }
631
 
632
  // Query for the IDs only to reduce memory usage
633
- $images = $wpdb->get_results( "SELECT ID FROM $wpdb->posts WHERE post_type = 'attachment' AND post_mime_type LIKE 'image/%'" );
634
 
635
  // Generate the list of IDs
636
  $ids = [];
@@ -700,7 +714,7 @@ function ime_ajax_process_image() {
700
 
701
  $force = isset( $_REQUEST['force'] ) && ! ! $_REQUEST['force'];
702
 
703
- $ime_image_file = get_attached_file( $id );
704
 
705
  if ( false === $ime_image_file || ! file_exists( $ime_image_file ) ) {
706
  die( '-1' );
@@ -949,6 +963,9 @@ function ime_option_page() {
949
  }
950
  ime_set_option( 'quality', $new_quality );
951
 
 
 
 
952
  $new_handle_sizes = [];
953
  foreach ( $sizes as $s => $name ) {
954
  $new_mode = isset( $_POST[ 'handle-mode-' . $s ] ) ? $_POST[ 'handle-mode-' . $s ] : 'skip';
@@ -1011,6 +1028,8 @@ function ime_option_page() {
1011
  $quality = $n;
1012
  }
1013
 
 
 
1014
  $handle_sizes = ime_get_option( 'handle_sizes' );
1015
 
1016
  if ( ! $any_valid ) {
@@ -1127,6 +1146,17 @@ function ime_option_page() {
1127
  <p class="ime-description"><?php _e( 'Set to 0-100. Higher value gives better image quality but larger file size. Leave empty for default value, computed dynamically.', 'imagemagick-engine' ); ?></p>
1128
  </td>
1129
  </tr>
 
 
 
 
 
 
 
 
 
 
 
1130
  <tr>
1131
  <td colspan="2" class="ime-handle-table-wrapper">
1132
  <table border='0' class="ime-handle-table" id="ime-handle-table">
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
12
 
13
  Licenced under the GNU GPL:
14
 
35
  * Constants
36
  */
37
  define( 'IME_OPTION_VERSION', 1 );
38
+ define( 'IME_VERSION', '1.7.0' );
39
 
40
  /*
41
  * Global variables
56
  'quality' => -1,
57
  'size' => 70,
58
  ],
59
+ 'interlace' => false,
60
  'quality' => '',
61
  'version' => constant( 'IME_OPTION_VERSION' ),
62
  ];
242
  }
243
  }
244
 
245
+ // Should images be converted with interlace or not
246
+ function ime_interlace() {
247
+ return ime_get_option( 'interlace' );
248
+ }
249
+
250
  // Get image quality setting for type
251
  function ime_get_quality( $resize_mode = 'quality' ) {
252
  $quality = ime_get_option( 'quality', '-1' );
447
  $im->setImageCompressionQuality( $quality );
448
  }
449
 
450
+ if ( ime_interlace() ) {
451
+ $im->setInterlaceScheme( Imagick::INTERLACE_PLANE );
452
+ }
453
+
454
  if ( $resize_mode == 'size' ) {
455
  $im->stripImage();
456
  }
513
 
514
  ime_set_option( 'imagemagick_version', $output, true );
515
 
516
+ return (is_array($output)) ? (count( $output ) > 0) : false;
517
  }
518
 
519
  /*
606
  $cmd .= ' -quality ' . intval( $quality );
607
  }
608
 
609
+ if ( ime_interlace() ) {
610
+ $cmd .= ' -interlace Plane';
611
+ }
612
+
613
  if ( $resize_mode == 'size' ) {
614
  $cmd .= ' -strip';
615
  }
644
  }
645
 
646
  // Query for the IDs only to reduce memory usage
647
+ $images = $wpdb->get_results( "SELECT ID FROM $wpdb->posts WHERE post_type = 'attachment' AND post_mime_type LIKE 'image/%' AND post_mime_type != 'image/svg+xml'" );
648
 
649
  // Generate the list of IDs
650
  $ids = [];
714
 
715
  $force = isset( $_REQUEST['force'] ) && ! ! $_REQUEST['force'];
716
 
717
+ $ime_image_file = function_exists('wp_get_original_image_path') ? wp_get_original_image_path( $id ) : get_attached_file( $id );
718
 
719
  if ( false === $ime_image_file || ! file_exists( $ime_image_file ) ) {
720
  die( '-1' );
963
  }
964
  ime_set_option( 'quality', $new_quality );
965
 
966
+ $new_interlace = isset( $_POST['interlace'] ) && ! ! $_POST['interlace'];
967
+ ime_set_option( 'interlace', $new_interlace );
968
+
969
  $new_handle_sizes = [];
970
  foreach ( $sizes as $s => $name ) {
971
  $new_mode = isset( $_POST[ 'handle-mode-' . $s ] ) ? $_POST[ 'handle-mode-' . $s ] : 'skip';
1028
  $quality = $n;
1029
  }
1030
 
1031
+ $interlace = ime_get_option( 'interlace' );
1032
+
1033
  $handle_sizes = ime_get_option( 'handle_sizes' );
1034
 
1035
  if ( ! $any_valid ) {
1146
  <p class="ime-description"><?php _e( 'Set to 0-100. Higher value gives better image quality but larger file size. Leave empty for default value, computed dynamically.', 'imagemagick-engine' ); ?></p>
1147
  </td>
1148
  </tr>
1149
+ <tr>
1150
+ <th scope="row" valign="top"><?php _e( 'Image interlace?', 'imagemagick-engine' ); ?>:</th>
1151
+ <td>
1152
+ <input type="checkbox" id="interlace" name="interlace" value="1"
1153
+ <?php
1154
+ echo $interlace ? ' CHECKED ' : '';
1155
+ ?>
1156
+ />
1157
+ <p class="ime-description"><?php _e( 'Adds interlace option to ImageMagick when images are processed.', 'imagemagick-engine' ); ?></p>
1158
+ </td>
1159
+ </tr>
1160
  <tr>
1161
  <td colspan="2" class="ime-handle-table-wrapper">
1162
  <table border='0' class="ime-handle-table" id="ime-handle-table">
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.5.0
6
- Stable tag: 1.6.5
7
 
8
  Improve the quality of re-sized images by replacing standard GD library with ImageMagick.
9
 
@@ -74,6 +74,13 @@ You'll probably have problems with various other plugins too unless you fix this
74
 
75
  == Changelog ==
76
 
 
 
 
 
 
 
 
77
  = 1.6.5 =
78
  * Turkish translation thanks to Haydar ŞAHİN
79
  * Bugfix
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
 
75
  == Changelog ==
76
 
77
+ = 1.7.0 =
78
+ * Add option to resize images interlaced
79
+ * Fix: Don't attempt to regenerate SVG's.
80
+ * Handle scaled images with wp_get_original_image_path
81
+ * Bugfix cli executable respnsonse
82
+ * Tested compability with WordPress 5.8
83
+
84
  = 1.6.5 =
85
  * Turkish translation thanks to Haydar ŞAHİN
86
  * Bugfix