From e24698d986bf3e145fa753f13c50704249f964d3 Mon Sep 17 00:00:00 2001 From: Lester Caine Date: Tue, 2 Jun 2026 09:30:25 +0100 Subject: Tidy Imagick usage in processor and mime.pdf plugins MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit processor.imagick: ImagickPixel('none') explicit colour, add clear() to rotate mime.pdf: fix dest_branch absolute path in regenerate case — strip STORAGE_PKG_PATH and ensure trailing slash before passing to liberty_generate_thumbnails Co-Authored-By: Claude Sonnet 4.6 --- plugins/mime.pdf.php | 2 +- plugins/processor.imagick.php | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/plugins/mime.pdf.php b/plugins/mime.pdf.php index 5b428f9..d2cbe77 100644 --- a/plugins/mime.pdf.php +++ b/plugins/mime.pdf.php @@ -221,7 +221,7 @@ function mime_pdf_thumbnail( $pFileHash ) { if( is_file( $thumb_file ) && filesize( $thumb_file ) > 0 ) { $genHash = [ 'attachment_id' => $pFileHash['attachment_id'], - 'dest_branch' => $pFileHash['upload']['dest_branch'] ?? $dest_branch, + 'dest_branch' => $pFileHash['upload']['dest_branch'] ?? rtrim( str_replace( STORAGE_PKG_PATH, '', $dest_branch ), '/' ).'/', 'source_file' => $thumb_file, 'type' => 'image/jpeg', ]; diff --git a/plugins/processor.imagick.php b/plugins/processor.imagick.php index e85c6ff..c02b640 100755 --- a/plugins/processor.imagick.php +++ b/plugins/processor.imagick.php @@ -120,7 +120,7 @@ function liberty_imagick_resize_image( &$pFileHash ) { } // destroy object - $im->destroy(); + $im->clear(); $ret = $destFile; } catch( ImagickException $e ) { @@ -145,9 +145,10 @@ function liberty_imagick_rotate_image( &$pFileHash ) { } elseif( empty( $pFileHash['degrees'] ) || !is_numeric( $pFileHash['degrees'] )) { $pFileHash['error'] = KernelTools::tra( 'Invalid rotation amount' ); } else { - $im->rotateImage( new ImagickPixel(), $pFileHash['degrees'] ); + $im->rotateImage( new ImagickPixel('none'), $pFileHash['degrees'] ); $im->writeImage( $pFileHash['source_file'] ); } + $im->clear(); } catch( ImagickException $e ) { \Bitweaver\bit_error_log( $e->getMessage().' '.$pFileHash['source_file'] ); $pFileHash['error'] = $e->getMessage(); -- cgit v1.3