Version Description
- Tested with WP 3.2.1
- Bugfix: escape '^' character on Windows (thanks to alx359)
- clean up IM command line argument handling a bit
Download this release
Release Info
Developer | orangelab |
Plugin | ImageMagick Engine |
Version | 1.3.1 |
Comparing to | |
See all releases |
Code changes from version 1.3.0 to 1.3.1
- imagemagick-engine.php +19 -8
- readme.txt +7 -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: http://www.orangelab.se
|
8 |
-
Version: 1.3.
|
9 |
Text Domain: imagemagick-engine
|
10 |
|
11 |
Copyright 2010, 2011 Orangelab
|
@@ -29,9 +29,12 @@
|
|
29 |
|
30 |
/*
|
31 |
* Current todo list:
|
32 |
-
* -
|
|
|
|
|
33 |
*
|
34 |
* Future todo list:
|
|
|
35 |
* - edit post insert image: add custom sizes?
|
36 |
* - admin: smarter find path to executable (maybe try 'which' or package handler?)
|
37 |
* - allow customization of command line / class functions (safely!), check memory limit
|
@@ -429,7 +432,7 @@ function ime_im_cli_check_executable($fullpath) {
|
|
429 |
if (!is_executable($fullpath))
|
430 |
return false;
|
431 |
|
432 |
-
@exec($fullpath . ' --version', $output);
|
433 |
|
434 |
return count($output) > 0;
|
435 |
}
|
@@ -487,6 +490,11 @@ function ime_im_cli_command($executable='convert') {
|
|
487 |
return ime_im_cli_check_command($path, $executable);
|
488 |
}
|
489 |
|
|
|
|
|
|
|
|
|
|
|
490 |
// Resize using ImageMagick executable
|
491 |
function ime_im_cli_resize($old_file, $new_file, $width, $height, $crop) {
|
492 |
$cmd = ime_im_cli_command();
|
@@ -496,18 +504,21 @@ function ime_im_cli_resize($old_file, $new_file, $width, $height, $crop) {
|
|
496 |
$old_file = addslashes($old_file);
|
497 |
$new_file = addslashes($new_file);
|
498 |
|
|
|
|
|
499 |
// limits are 150mb and 128mb
|
500 |
-
$cmd = "\"$cmd\" -limit memory 157286400 -limit map 134217728 -
|
501 |
-
if ($crop)
|
502 |
-
|
503 |
-
|
|
|
504 |
$cmd .= "!"; // force these dimensions
|
505 |
|
506 |
$quality = ime_get_option('quality', '-1');
|
507 |
if (is_numeric($quality) && $quality >= 0 && $quality <= 100 && ime_im_filename_is_jpg($new_file))
|
508 |
$cmd .= " -quality " . intval($quality);
|
509 |
|
510 |
-
$cmd .= "
|
511 |
exec($cmd);
|
512 |
|
513 |
return file_exists($new_file);
|
5 |
Description: Improve the quality of re-sized images by replacing standard GD library with ImageMagick
|
6 |
Author: Orangelab
|
7 |
Author URI: http://www.orangelab.se
|
8 |
+
Version: 1.3.1
|
9 |
Text Domain: imagemagick-engine
|
10 |
|
11 |
Copyright 2010, 2011 Orangelab
|
29 |
|
30 |
/*
|
31 |
* Current todo list:
|
32 |
+
* - test command line version string
|
33 |
+
* - test php module with required image formats
|
34 |
+
* - handle errors in resize, fall back to GD
|
35 |
*
|
36 |
* Future todo list:
|
37 |
+
* - do not iterate through all images if only resizing non-ime images
|
38 |
* - edit post insert image: add custom sizes?
|
39 |
* - admin: smarter find path to executable (maybe try 'which' or package handler?)
|
40 |
* - allow customization of command line / class functions (safely!), check memory limit
|
432 |
if (!is_executable($fullpath))
|
433 |
return false;
|
434 |
|
435 |
+
@exec('"' . $fullpath . '" --version', $output);
|
436 |
|
437 |
return count($output) > 0;
|
438 |
}
|
490 |
return ime_im_cli_check_command($path, $executable);
|
491 |
}
|
492 |
|
493 |
+
// Check if we are running under Windows (which differs for character escape)
|
494 |
+
function ime_is_windows() {
|
495 |
+
return (constant('PHP_SHLIB_SUFFIX') == 'dll');
|
496 |
+
}
|
497 |
+
|
498 |
// Resize using ImageMagick executable
|
499 |
function ime_im_cli_resize($old_file, $new_file, $width, $height, $crop) {
|
500 |
$cmd = ime_im_cli_command();
|
504 |
$old_file = addslashes($old_file);
|
505 |
$new_file = addslashes($new_file);
|
506 |
|
507 |
+
$geometry = $width . 'x' . $height;
|
508 |
+
|
509 |
// limits are 150mb and 128mb
|
510 |
+
$cmd = "\"$cmd\" \"$old_file\" -limit memory 157286400 -limit map 134217728 -resize $geometry";
|
511 |
+
if ($crop) {
|
512 |
+
// '^' is an escape character on Windows
|
513 |
+
$cmd .= (ime_is_windows() ? '^^' : '^') . " -gravity center -extent $geometry";
|
514 |
+
} else
|
515 |
$cmd .= "!"; // force these dimensions
|
516 |
|
517 |
$quality = ime_get_option('quality', '-1');
|
518 |
if (is_numeric($quality) && $quality >= 0 && $quality <= 100 && ime_im_filename_is_jpg($new_file))
|
519 |
$cmd .= " -quality " . intval($quality);
|
520 |
|
521 |
+
$cmd .= ' "' . $new_file . '"';
|
522 |
exec($cmd);
|
523 |
|
524 |
return file_exists($new_file);
|
readme.txt
CHANGED
@@ -2,8 +2,8 @@
|
|
2 |
Contributors: orangelab
|
3 |
Tags: image, images, picture, imagemagick, gd
|
4 |
Requires at least: 2.9
|
5 |
-
Tested up to: 3.2
|
6 |
-
Stable tag: 1.3.
|
7 |
|
8 |
Improve the quality of re-sized images by replacing standard GD library with ImageMagick.
|
9 |
|
@@ -74,6 +74,11 @@ You'll probably have problems with various other plugins too unless you fix this
|
|
74 |
|
75 |
== Changelog ==
|
76 |
|
|
|
|
|
|
|
|
|
|
|
77 |
= 1.3.0 =
|
78 |
* Tested agains WP 3.2
|
79 |
* Fix JS to be compatible with jQuery 1.6
|
2 |
Contributors: orangelab
|
3 |
Tags: image, images, picture, imagemagick, gd
|
4 |
Requires at least: 2.9
|
5 |
+
Tested up to: 3.2.1
|
6 |
+
Stable tag: 1.3.1
|
7 |
|
8 |
Improve the quality of re-sized images by replacing standard GD library with ImageMagick.
|
9 |
|
74 |
|
75 |
== Changelog ==
|
76 |
|
77 |
+
= 1.3.1 =
|
78 |
+
* Tested with WP 3.2.1
|
79 |
+
* Bugfix: escape '^' character on Windows (thanks to alx359)
|
80 |
+
* clean up IM command line argument handling a bit
|
81 |
+
|
82 |
= 1.3.0 =
|
83 |
* Tested agains WP 3.2
|
84 |
* Fix JS to be compatible with jQuery 1.6
|