Changeset 420547
- Timestamp:
- 08/08/2011 11:31:53 AM (15 years ago)
- Location:
- imagemagick-engine/trunk
- Files:
-
- 2 edited
-
imagemagick-engine.php (modified) (7 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
imagemagick-engine/trunk/imagemagick-engine.php
r408665 r420547 6 6 Author: Orangelab 7 7 Author URI: http://www.orangelab.se 8 Version: 1.3. 08 Version: 1.3.1-beta1 9 9 Text Domain: imagemagick-engine 10 10 … … 425 425 } 426 426 427 // Escape cli executable 428 function ime_im_cli_escape_cmd($cmd) { 429 return '"' . $cmd . '"'; 430 } 431 427 432 // Test if we are allowed to exec executable! 428 433 function ime_im_cli_check_executable($fullpath) { … … 430 435 return false; 431 436 432 @exec( $fullpath. ' --version', $output);437 @exec(ime_im_cli_escape_cmd($fullpath) . ' --version', $output); 433 438 434 439 return count($output) > 0; … … 452 457 $path = ime_try_realpath($path); 453 458 454 $cmd = $path . '/' . $executable;459 $cmd = escapeshellcmd($path . '/' . $executable); 455 460 if (ime_im_cli_check_executable($cmd)) 456 461 return $cmd; … … 488 493 } 489 494 495 // Check if we are running under Windows (which differs for character escape) 496 function ime_is_windows() { 497 return (constant('PHP_SHLIB_SUFFIX') == 'dll'); 498 } 499 490 500 // Resize using ImageMagick executable 491 501 function ime_im_cli_resize($old_file, $new_file, $width, $height, $crop) { … … 493 503 if (empty($cmd)) 494 504 return false; 505 $cmd = ime_im_cli_escape_cmd($cmd); 495 506 496 507 $old_file = addslashes($old_file); 497 508 $new_file = addslashes($new_file); 498 509 510 $geometry = $width . 'x' . $height; 511 499 512 // 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 513 $cmd = "$cmd \"$old_file\" -limit memory 157286400 -limit map 134217728 -resize $geometry"; 514 if ($crop) { 515 // '^' is an escape character on Windows 516 $cmd .= (ime_is_windows() ? '^^' : '^') . " -gravity center -extent $geometry"; 517 } else 504 518 $cmd .= "!"; // force these dimensions 505 519 … … 508 522 $cmd .= " -quality " . intval($quality); 509 523 510 $cmd .= " \"{$new_file}\"";524 $cmd .= ' "' . $new_file . '"'; 511 525 exec($cmd); 512 526 -
imagemagick-engine/trunk/readme.txt
r408665 r420547 3 3 Tags: image, images, picture, imagemagick, gd 4 4 Requires at least: 2.9 5 Tested up to: 3.2 5 Tested up to: 3.2.1 6 6 Stable tag: 1.3.0 7 7 … … 75 75 == Changelog == 76 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 77 82 = 1.3.0 = 78 83 * Tested agains WP 3.2
Note: See TracChangeset
for help on using the changeset viewer.