Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: patch for imagemagick translated dimensions #810

Merged
merged 1 commit into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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