Plugin Directory

Changeset 420547


Ignore:
Timestamp:
08/08/2011 11:31:53 AM (15 years ago)
Author:
orangelab
Message:

1.3.1-beta1, escape on windows

Location:
imagemagick-engine/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • imagemagick-engine/trunk/imagemagick-engine.php

    r408665 r420547  
    66  Author: Orangelab
    77  Author URI: http://www.orangelab.se
    8   Version: 1.3.0
     8  Version: 1.3.1-beta1
    99  Text Domain: imagemagick-engine
    1010
     
    425425}
    426426
     427// Escape cli executable
     428function ime_im_cli_escape_cmd($cmd) {
     429    return '"' . $cmd . '"';
     430}
     431
    427432// Test if we are allowed to exec executable!
    428433function ime_im_cli_check_executable($fullpath) {
     
    430435        return false;
    431436
    432     @exec($fullpath . ' --version', $output);
     437    @exec(ime_im_cli_escape_cmd($fullpath) . ' --version', $output);
    433438
    434439    return count($output) > 0;
     
    452457    $path = ime_try_realpath($path);
    453458
    454     $cmd = $path . '/' . $executable;
     459    $cmd = escapeshellcmd($path . '/' . $executable);
    455460    if (ime_im_cli_check_executable($cmd))
    456461        return $cmd;
     
    488493}
    489494
     495// Check if we are running under Windows (which differs for character escape)
     496function ime_is_windows() {
     497    return (constant('PHP_SHLIB_SUFFIX') == 'dll');
     498}
     499
    490500// Resize using ImageMagick executable
    491501function ime_im_cli_resize($old_file, $new_file, $width, $height, $crop) {
     
    493503    if (empty($cmd))
    494504        return false;
     505    $cmd = ime_im_cli_escape_cmd($cmd);
    495506
    496507    $old_file = addslashes($old_file);
    497508    $new_file = addslashes($new_file);
    498509
     510    $geometry = $width . 'x' . $height;
     511
    499512    // 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
    504518        $cmd .= "!"; // force these dimensions
    505519
     
    508522        $cmd .= " -quality " . intval($quality);
    509523
    510     $cmd .= " \"{$new_file}\"";
     524    $cmd .= ' "' .  $new_file . '"';
    511525    exec($cmd);
    512526
  • imagemagick-engine/trunk/readme.txt

    r408665 r420547  
    33Tags: image, images, picture, imagemagick, gd
    44Requires at least: 2.9
    5 Tested up to: 3.2
     5Tested up to: 3.2.1
    66Stable tag: 1.3.0
    77
     
    7575== Changelog ==
    7676
     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
    7782= 1.3.0 =
    7883* Tested agains WP 3.2
Note: See TracChangeset for help on using the changeset viewer.