Skip to content

Commit

Permalink
fix: patch for imagemagick translated dimensions
Browse files Browse the repository at this point in the history
Refs: RWR-456

This should probably be fixed in the translation stage, but this removes
the error for now.
  • Loading branch information
lazysoundsystem committed Aug 27, 2024
1 parent 7eb4fe4 commit 719ab79
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
37 changes: 37 additions & 0 deletions PATCHES/imagemagick-ints.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
diff --git a/src/Plugin/ImageToolkit/Operation/imagemagick/Resize.php b/src/Plugin/ImageToolkit/Operation/imagemagick/Resize.php
index 01e9101..df8c833 100644
--- a/src/Plugin/ImageToolkit/Operation/imagemagick/Resize.php
+++ b/src/Plugin/ImageToolkit/Operation/imagemagick/Resize.php
@@ -68,7 +68,7 @@ protected function execute(array $arguments = []): bool {
'-resize',
$arguments['width'] . 'x' . $arguments['height'] . '!',
]);
- $this->getToolkit()->setWidth($arguments['width'])->setHeight($arguments['height']);
+ $this->getToolkit()->setWidth((int) $arguments['width'])->setHeight((int) $arguments['height']);
return TRUE;
}

diff --git a/src/Plugin/ImageToolkit/Operation/imagemagick/Scale.php b/src/Plugin/ImageToolkit/Operation/imagemagick/Scale.php
index 7efd34e..6dfbc5d 100644
--- a/src/Plugin/ImageToolkit/Operation/imagemagick/Scale.php
+++ b/src/Plugin/ImageToolkit/Operation/imagemagick/Scale.php
@@ -68,15 +68,15 @@ protected function validateArguments(array $arguments): array {
// calculated to be bigger than its target.
$aspect = $this->getToolkit()->getHeight() / $this->getToolkit()->getWidth();
if (($arguments['width'] && !$arguments['height']) || ($arguments['width'] && $arguments['height'] && $aspect < $arguments['height'] / $arguments['width'])) {
- $arguments['height'] = (int) round($arguments['width'] * $aspect);
+ $arguments['height'] = round((int) $arguments['width'] * $aspect);
}
else {
- $arguments['width'] = (int) round($arguments['height'] / $aspect);
+ $arguments['width'] = round((int) $arguments['height'] / $aspect);
}

// Assure integers for all arguments.
- $arguments['width'] = (int) round($arguments['width']);
- $arguments['height'] = (int) round($arguments['height']);
+ $arguments['width'] = round((int) $arguments['width']);
+ $arguments['height'] = round((int) $arguments['height']);

// Fail when width or height are 0 or negative.
if ($arguments['width'] <= 0) {
3 changes: 3 additions & 0 deletions composer.patches.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
"drupal/imageapi_optimize_webp": {
"https://www.drupal.org/project/imageapi_optimize_webp/issues/3453941": "https://www.drupal.org/files/issues/2024-06-14/3453941-bc-break_0.patch"
},
"drupal/imagemagick": {
"Cast dimensions to int after translations": "PATCHES/imagemagick-ints.patch"
},
"drupal/linkchecker": {
"Provide a list of unconfigured but eligible fields - https://www.drupal.org/project/linkchecker/issues/3244743": "PATCHES/linkchecker-unconfirmed-but-eligible-field-list-3244743.patch",
"Do not break admin denied": "./PATCHES/linkchecker_use_uid.patch",
Expand Down

0 comments on commit 719ab79

Please sign in to comment.