From 1ddf6d789cda3c9a8e105dce707db6d990b38d79 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Tue, 28 Nov 2023 15:00:53 +0100 Subject: [PATCH] wait #6530 @1.25 --- src/CommandLine/Poppler.php | 11 ++++++++++- src/Graphics/Image.php | 4 ++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/CommandLine/Poppler.php b/src/CommandLine/Poppler.php index bc55359..598aeae 100644 --- a/src/CommandLine/Poppler.php +++ b/src/CommandLine/Poppler.php @@ -56,7 +56,7 @@ class Poppler } else { $dest = str_replace('.' . $extension, '', $to); } - if (file_exists($cacheFile)) { + if (Files::isNotEmpty($cacheFile)) { if (null === $to) { return $cacheFile; } @@ -111,6 +111,14 @@ class Poppler return $res; } + /** + * @param $file + * @param $page + * @param $destfile + * @param $rect + * @param $invertPaper + * @return CommandLine + */ protected static function _pdftocairoRect($file, $page, $destfile, $rect, $invertPaper = false) { $pdftocairo = new CommandLine('pdftocairo'); @@ -119,6 +127,7 @@ class Poppler $pdftocairo->setArg('-paperh', round($invertPaper ? $rect['width'] : $rect['height'])); self::_crop($pdftocairo, $page, $rect, 1, 1); self::_exec($pdftocairo, $file, $destfile); + return $pdftocairo; } /** diff --git a/src/Graphics/Image.php b/src/Graphics/Image.php index 1529c67..282fcb7 100644 --- a/src/Graphics/Image.php +++ b/src/Graphics/Image.php @@ -126,10 +126,10 @@ class Image public static function fixSVGDimensions($source, $preserveAspectRatio = "none") { $fixed = str_replace('.svg', '.f.svg', $source); - if (file_exists($fixed) && filemtime($fixed) >= filemtime($source)) { + if (Files::isNotEmpty($fixed) && filemtime($fixed) >= filemtime($source)) { return $fixed; } - if (file_exists($fixed) && is_link($fixed)) { + if (file_exists($fixed) && (is_link($fixed) || filesize($fixed) === 0)) { unlink($fixed); } try { -- 2.39.5