Forum Replies Created

Viewing 1 replies (of 1 total)
  • I recently managed to use imagemagick instead of GD for converting images to thumbnails (I’m using the K2 theme, so I’m not sure if this will be tied to that theme or not). I replaced the code in wp_crop_image in wp-admin/admin-functions.php like this:

    function wp_crop_image( $src_file, $src_x, $src_y, $src_w, $src_h, $dst_w, $dst_h, $src_abs = false, $dst_file = false ) {
            if ( ctype_digit( $src_file ) ) // Handle int as attachment ID
                    $src_file = get_attached_file( $src_file );
    
            if ( $src_abs ) {
                    $src_w -= $src_x;
                    $src_h -= $src_y;
            }
    
            if ( !$dst_file )
                    $dst_file = str_replace( basename( $src_file ), 'cropped-'.basename( $src_file ), $src_file );
    
            $dst_file = preg_replace( '/\\.[^\\.]+$/', '.jpg', $dst_file );
    
            $cmd = sprintf("/sw/bin/convert %s -crop %dx%d+%d+%d -resize %dx%d %s",
                           $src_file,
                           $src_w,$src_h,$src_x,$src_y,
                           $dst_w,$dst_h,
                           $dst_file);
    
            system($cmd,$retcode);
    
            return $dst_file;
    }

    Replace /sw/bin/convert with whereever your copy of convert is located.

    I have not investigated any other impacts this change may have on security etc.

    Good luck

Viewing 1 replies (of 1 total)