Version Description
- Tested agains WP 3.2
- Fix JS to be compatible with jQuery 1.6
- Remove some PHP notices
- Change command line limit values to specifik byte amounts (instead of "mb") for compatability with really old IM versions
- Handle open_basename restrictions better
- Handle older versions (pre 6.3.1) of PHP Imagick class
- IM and WordPress compute aspect ratio slightly differently, force the WP values
Download this release
Release Info
Developer | orangelab |
Plugin | ImageMagick Engine |
Version | 1.3.0 |
Comparing to | |
See all releases |
Code changes from version 1.2.3 to 1.3.0
- imagemagick-engine.php +24 -17
- js/ime-admin.js +7 -4
- readme.txt +11 -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.
|
9 |
Text Domain: imagemagick-engine
|
10 |
|
11 |
Copyright 2010, 2011 Orangelab
|
@@ -29,7 +29,6 @@
|
|
29 |
|
30 |
/*
|
31 |
* Current todo list:
|
32 |
-
* - position of resize progressbar in Chrome
|
33 |
* - do not iterate through all images if only resizing non-ime images
|
34 |
*
|
35 |
* Future todo list:
|
@@ -377,7 +376,8 @@ function ime_im_php_resize($old_file, $new_file, $width, $height, $crop) {
|
|
377 |
$im->setImageCompression(Imagick::COMPRESSION_JPEG);
|
378 |
$im->setImageCompressionQuality($quality);
|
379 |
}
|
380 |
-
$im
|
|
|
381 |
|
382 |
if ($crop) {
|
383 |
/*
|
@@ -434,11 +434,22 @@ function ime_im_cli_check_executable($fullpath) {
|
|
434 |
return count($output) > 0;
|
435 |
}
|
436 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
437 |
// Check if path leads to ImageMagick executable
|
438 |
function ime_im_cli_check_command($path, $executable='convert') {
|
439 |
-
$path =
|
440 |
-
if (!is_dir($path))
|
441 |
-
return null;
|
442 |
|
443 |
$cmd = $path . '/' . $executable;
|
444 |
if (ime_im_cli_check_executable($cmd))
|
@@ -456,13 +467,6 @@ function ime_im_cli_find_command($executable='convert') {
|
|
456 |
$possible_paths = array("/usr/bin", "/usr/local/bin");
|
457 |
|
458 |
foreach ($possible_paths AS $path) {
|
459 |
-
/*
|
460 |
-
* This operation would give a warning if path is restricted by
|
461 |
-
* open_basedir.
|
462 |
-
*/
|
463 |
-
$path = @realpath($path);
|
464 |
-
if (!$path)
|
465 |
-
continue;
|
466 |
if (ime_im_cli_check_command($path, $executable))
|
467 |
return $path;
|
468 |
}
|
@@ -492,9 +496,12 @@ function ime_im_cli_resize($old_file, $new_file, $width, $height, $crop) {
|
|
492 |
$old_file = addslashes($old_file);
|
493 |
$new_file = addslashes($new_file);
|
494 |
|
495 |
-
|
|
|
496 |
if ($crop)
|
497 |
$cmd .= "^ -gravity center -extent {$width}x{$height}";
|
|
|
|
|
498 |
|
499 |
$quality = ime_get_option('quality', '-1');
|
500 |
if (is_numeric($quality) && $quality >= 0 && $quality <= 100 && ime_im_filename_is_jpg($new_file))
|
@@ -746,7 +753,7 @@ function ime_option_page() {
|
|
746 |
if (isset($_POST['mode']) && array_key_exists($_POST['mode'], $ime_available_modes))
|
747 |
ime_set_option('mode', $_POST['mode']);
|
748 |
if (isset($_POST['cli_path']))
|
749 |
-
ime_set_option('cli_path',
|
750 |
if (isset($_POST['quality'])) {
|
751 |
if (is_numeric($_POST['quality']))
|
752 |
ime_set_option('quality', min(100, max(0, intval($_POST['quality']))));
|
@@ -828,7 +835,7 @@ function ime_option_page() {
|
|
828 |
<td>
|
829 |
<?php
|
830 |
foreach($sizes AS $s => $name) {
|
831 |
-
echo '<input type="checkbox" name="regen-size-' . $s . '" value="1" ' . ($handle_sizes[$s] ? ' CHECKED ' : '') . ' /> ' . $name . '<br />';
|
832 |
}
|
833 |
?>
|
834 |
</td>
|
@@ -909,7 +916,7 @@ function ime_option_page() {
|
|
909 |
<td>
|
910 |
<?php
|
911 |
foreach($sizes AS $s => $name) {
|
912 |
-
echo '<input type="checkbox" name="handle-' . $s . '" value="1" ' . ($handle_sizes[$s] ? ' CHECKED ' : '') . ' /> ' . $name . '<br />';
|
913 |
}
|
914 |
?>
|
915 |
</td>
|
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.0
|
9 |
Text Domain: imagemagick-engine
|
10 |
|
11 |
Copyright 2010, 2011 Orangelab
|
29 |
|
30 |
/*
|
31 |
* Current todo list:
|
|
|
32 |
* - do not iterate through all images if only resizing non-ime images
|
33 |
*
|
34 |
* Future todo list:
|
376 |
$im->setImageCompression(Imagick::COMPRESSION_JPEG);
|
377 |
$im->setImageCompressionQuality($quality);
|
378 |
}
|
379 |
+
if (method_exists($im, 'setImageOpacity'))
|
380 |
+
$im->setImageOpacity(1.0);
|
381 |
|
382 |
if ($crop) {
|
383 |
/*
|
434 |
return count($output) > 0;
|
435 |
}
|
436 |
|
437 |
+
/*
|
438 |
+
* Try to get realpath of path
|
439 |
+
*
|
440 |
+
* This won't work if there is open_basename restrictions.
|
441 |
+
*/
|
442 |
+
function ime_try_realpath($path) {
|
443 |
+
$realpath = @realpath($path);
|
444 |
+
if ($realpath)
|
445 |
+
return $realpath;
|
446 |
+
else
|
447 |
+
return $path;
|
448 |
+
}
|
449 |
+
|
450 |
// Check if path leads to ImageMagick executable
|
451 |
function ime_im_cli_check_command($path, $executable='convert') {
|
452 |
+
$path = ime_try_realpath($path);
|
|
|
|
|
453 |
|
454 |
$cmd = $path . '/' . $executable;
|
455 |
if (ime_im_cli_check_executable($cmd))
|
467 |
$possible_paths = array("/usr/bin", "/usr/local/bin");
|
468 |
|
469 |
foreach ($possible_paths AS $path) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
470 |
if (ime_im_cli_check_command($path, $executable))
|
471 |
return $path;
|
472 |
}
|
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 -size {$width}x{$height} \"{$old_file}\" -resize {$width}x{$height}";
|
501 |
if ($crop)
|
502 |
$cmd .= "^ -gravity center -extent {$width}x{$height}";
|
503 |
+
else
|
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))
|
753 |
if (isset($_POST['mode']) && array_key_exists($_POST['mode'], $ime_available_modes))
|
754 |
ime_set_option('mode', $_POST['mode']);
|
755 |
if (isset($_POST['cli_path']))
|
756 |
+
ime_set_option('cli_path', ime_try_realpath(trim($_POST['cli_path'])));
|
757 |
if (isset($_POST['quality'])) {
|
758 |
if (is_numeric($_POST['quality']))
|
759 |
ime_set_option('quality', min(100, max(0, intval($_POST['quality']))));
|
835 |
<td>
|
836 |
<?php
|
837 |
foreach($sizes AS $s => $name) {
|
838 |
+
echo '<input type="checkbox" name="regen-size-' . $s . '" value="1" ' . (isset($handle_sizes[$s]) && $handle_sizes[$s] ? ' CHECKED ' : '') . ' /> ' . $name . '<br />';
|
839 |
}
|
840 |
?>
|
841 |
</td>
|
916 |
<td>
|
917 |
<?php
|
918 |
foreach($sizes AS $s => $name) {
|
919 |
+
echo '<input type="checkbox" name="handle-' . $s . '" value="1" ' . (isset($handle_sizes[$s]) && $handle_sizes[$s] ? ' CHECKED ' : '') . ' /> ' . $name . '<br />';
|
920 |
}
|
921 |
?>
|
922 |
</td>
|
js/ime-admin.js
CHANGED
@@ -30,12 +30,15 @@ function imeStartResize() {
|
|
30 |
rt_force = 0;
|
31 |
|
32 |
jQuery('#regenerate-images-metabox input').each(function(){
|
33 |
-
|
34 |
-
|
|
|
|
|
|
|
35 |
}
|
36 |
});
|
37 |
|
38 |
-
if(jQuery('#force').
|
39 |
rt_force = 1;
|
40 |
}
|
41 |
|
@@ -71,7 +74,7 @@ function imeUpdateMode() {
|
|
71 |
jQuery("#ime-select-mode option").each(function(i,e) {
|
72 |
var o = jQuery(this);
|
73 |
var mode = o.val();
|
74 |
-
if (o.
|
75 |
jQuery('#ime-row-' + mode).show();
|
76 |
else
|
77 |
jQuery('#ime-row-' + mode).hide();
|
30 |
rt_force = 0;
|
31 |
|
32 |
jQuery('#regenerate-images-metabox input').each(function(){
|
33 |
+
var i = jQuery(this);
|
34 |
+
var name = i.attr('name');
|
35 |
+
|
36 |
+
if(i.is(':checked') && name && name.substring(0,11) == "regen-size-") {
|
37 |
+
rt_sizes = rt_sizes + name.substring(11) + "|";
|
38 |
}
|
39 |
});
|
40 |
|
41 |
+
if(jQuery('#force').is(':checked')) {
|
42 |
rt_force = 1;
|
43 |
}
|
44 |
|
74 |
jQuery("#ime-select-mode option").each(function(i,e) {
|
75 |
var o = jQuery(this);
|
76 |
var mode = o.val();
|
77 |
+
if (o.is(':selected'))
|
78 |
jQuery('#ime-row-' + mode).show();
|
79 |
else
|
80 |
jQuery('#ime-row-' + mode).hide();
|
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.
|
6 |
-
Stable tag: 1.
|
7 |
|
8 |
Improve the quality of re-sized images by replacing standard GD library with ImageMagick.
|
9 |
|
@@ -74,6 +74,15 @@ You'll probably have problems with various other plugins too unless you fix this
|
|
74 |
|
75 |
== Changelog ==
|
76 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
= 1.2.3 =
|
78 |
* Fix bug in resize all images handling, also remove some PHP notices. Thanks to Andreas Kleinschmidt for the report
|
79 |
* Upgrade jQuery UI Progressbar to version 1.8.9, to match version of UI Core in WordPress
|
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.0
|
7 |
|
8 |
Improve the quality of re-sized images by replacing standard GD library with ImageMagick.
|
9 |
|
74 |
|
75 |
== Changelog ==
|
76 |
|
77 |
+
= 1.3.0 =
|
78 |
+
* Tested agains WP 3.2
|
79 |
+
* Fix JS to be compatible with jQuery 1.6
|
80 |
+
* Remove some PHP notices
|
81 |
+
* Change command line limit values to specifik byte amounts (instead of "mb") for compatability with really old IM versions
|
82 |
+
* Handle open_basename restrictions better
|
83 |
+
* Handle older versions (pre 6.3.1) of PHP Imagick class
|
84 |
+
* IM and WordPress compute aspect ratio slightly differently, force the WP values
|
85 |
+
|
86 |
= 1.2.3 =
|
87 |
* Fix bug in resize all images handling, also remove some PHP notices. Thanks to Andreas Kleinschmidt for the report
|
88 |
* Upgrade jQuery UI Progressbar to version 1.8.9, to match version of UI Core in WordPress
|