From 94bfdd0de17dfb2772fd25127e8e7f6723a2b52a Mon Sep 17 00:00:00 2001
From: Jason Hildebrand <jason@peaceworks.ca>
Date: Thu, 20 Oct 2022 16:11:14 -0500
Subject: [PATCH 1/3] Add an "input args" parameter when defining derivative
 actions.  In the UI, this field is only exposed for image derivatives, where
 it allows passing "input options" to imagemagick convert (houdini).

---
 .../src/Plugin/Action/GenerateAudioDerivative.php |  1 +
 .../src/Plugin/Action/GenerateImageDerivative.php |  7 ++++++-
 .../Plugin/Action/GenerateImageDerivativeFile.php |  6 ++++++
 .../src/Plugin/Action/GenerateOCRDerivative.php   |  1 +
 .../Plugin/Action/GenerateOCRDerivativeFile.php   |  1 +
 .../src/Plugin/Action/GenerateVideoDerivative.php |  1 +
 src/Plugin/Action/AbstractGenerateDerivative.php  |  9 +++++++++
 .../AbstractGenerateDerivativeMediaFile.php       | 15 +++++++++++++--
 8 files changed, 38 insertions(+), 3 deletions(-)

diff --git a/modules/islandora_audio/src/Plugin/Action/GenerateAudioDerivative.php b/modules/islandora_audio/src/Plugin/Action/GenerateAudioDerivative.php
index 904d05e6..3f7ad896 100644
--- a/modules/islandora_audio/src/Plugin/Action/GenerateAudioDerivative.php
+++ b/modules/islandora_audio/src/Plugin/Action/GenerateAudioDerivative.php
@@ -36,6 +36,7 @@ class GenerateAudioDerivative extends AbstractGenerateDerivative {
     $form = parent::buildConfigurationForm($form, $form_state);
     $form['mimetype']['#description'] = $this->t('Mimetype to convert to (e.g. audio/mpeg, audio/m4a, etc...)');
     $form['args']['#description'] = $this->t('Additional command line parameters for FFMpeg');
+    unset($form['inputargs']);
     return $form;
   }
 
diff --git a/modules/islandora_image/src/Plugin/Action/GenerateImageDerivative.php b/modules/islandora_image/src/Plugin/Action/GenerateImageDerivative.php
index e81f157b..758c7375 100644
--- a/modules/islandora_image/src/Plugin/Action/GenerateImageDerivative.php
+++ b/modules/islandora_image/src/Plugin/Action/GenerateImageDerivative.php
@@ -33,7 +33,12 @@ class GenerateImageDerivative extends AbstractGenerateDerivative {
   public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
     $form = parent::buildConfigurationForm($form, $form_state);
     $form['mimetype']['#description'] = $this->t('Mimetype to convert to (e.g. image/jpeg, image/png, etc...)');
-    $form['args']['#description'] = $this->t('Additional command line arguments for ImageMagick convert (e.g. -resize 50%');
+
+    $form['inputargs']['#title'] = $this->t('Additional input arguments');
+    $form['inputargs']['#description'] = $this->t('Additional input options for ImageMagick convert (e.g. -density 144).<br>Check the <a target="_blank" href="https://manpages.ubuntu.com/manpages/trusty/man1/convert.im6.1.html">man page</a> to see which options are input options.');
+
+    $form['args']['#title'] = $this->t('Additional output arguments');
+    $form['args']['#description'] = $this->t('Additional output options for ImageMagick convert (e.g. -resize 50% -unsharp 0x.5).<br>See <a target="_blank" href="https://imagemagick.org/script/convert.php">documentation</a> for available options.');
     return $form;
   }
 
diff --git a/modules/islandora_image/src/Plugin/Action/GenerateImageDerivativeFile.php b/modules/islandora_image/src/Plugin/Action/GenerateImageDerivativeFile.php
index d6f99b58..8a9d7355 100644
--- a/modules/islandora_image/src/Plugin/Action/GenerateImageDerivativeFile.php
+++ b/modules/islandora_image/src/Plugin/Action/GenerateImageDerivativeFile.php
@@ -37,6 +37,12 @@ class GenerateImageDerivativeFile extends AbstractGenerateDerivativeMediaFile {
     $form['mimetype']['#description'] = $this->t('Mimetype to convert to (e.g. application/xml, etc...)');
     $form['mimetype']['#value'] = 'image/jpeg';
     $form['mimetype']['#type'] = 'hidden';
+
+    $form['inputargs']['#title'] = $this->t('Additional input arguments');
+    $form['inputargs']['#description'] = $this->t('Additional input options for ImageMagick convert (e.g. -density 144).<br>Check the <a target="_blank" href="https://manpages.ubuntu.com/manpages/trusty/man1/convert.im6.1.html">man page</a> to see which options are input options.');
+
+    $form['args']['#title'] = $this->t('Additional output arguments');
+    $form['args']['#description'] = $this->t('Additional output options for ImageMagick convert (e.g. -resize 50% -unsharp 0x.5).<br>See <a target="_blank" href="https://imagemagick.org/script/convert.php">documentation</a> for available options.');
     return $form;
   }
 
diff --git a/modules/islandora_text_extraction/src/Plugin/Action/GenerateOCRDerivative.php b/modules/islandora_text_extraction/src/Plugin/Action/GenerateOCRDerivative.php
index 745c5772..19417ec4 100644
--- a/modules/islandora_text_extraction/src/Plugin/Action/GenerateOCRDerivative.php
+++ b/modules/islandora_text_extraction/src/Plugin/Action/GenerateOCRDerivative.php
@@ -38,6 +38,7 @@ class GenerateOCRDerivative extends AbstractGenerateDerivative {
     $form['mimetype']['#type'] = 'textfield';
 
     unset($form['args']);
+    unset($form['inputargs']);
     return $form;
   }
 
diff --git a/modules/islandora_text_extraction/src/Plugin/Action/GenerateOCRDerivativeFile.php b/modules/islandora_text_extraction/src/Plugin/Action/GenerateOCRDerivativeFile.php
index f6b8034a..578f1b0c 100644
--- a/modules/islandora_text_extraction/src/Plugin/Action/GenerateOCRDerivativeFile.php
+++ b/modules/islandora_text_extraction/src/Plugin/Action/GenerateOCRDerivativeFile.php
@@ -58,6 +58,7 @@ class GenerateOCRDerivativeFile extends AbstractGenerateDerivativeMediaFile {
     $form = array_merge($first, $middle, $last);
 
     unset($form['args']);
+    unset($form['inputargs']);
     return $form;
   }
 
diff --git a/modules/islandora_video/src/Plugin/Action/GenerateVideoDerivative.php b/modules/islandora_video/src/Plugin/Action/GenerateVideoDerivative.php
index 7c861992..d5fb710d 100644
--- a/modules/islandora_video/src/Plugin/Action/GenerateVideoDerivative.php
+++ b/modules/islandora_video/src/Plugin/Action/GenerateVideoDerivative.php
@@ -35,6 +35,7 @@ class GenerateVideoDerivative extends AbstractGenerateDerivative {
     $form = parent::buildConfigurationForm($form, $form_state);
     $form['mimetype']['#description'] = $this->t('Mimetype to convert to (e.g. video/mp4, video/quicktime, etc...)');
     $form['args']['#description'] = $this->t('Additional command line parameters for FFMpeg');
+    unset($form['inputargs']);
     return $form;
   }
 
diff --git a/src/Plugin/Action/AbstractGenerateDerivative.php b/src/Plugin/Action/AbstractGenerateDerivative.php
index b22201e1..a2e44a65 100644
--- a/src/Plugin/Action/AbstractGenerateDerivative.php
+++ b/src/Plugin/Action/AbstractGenerateDerivative.php
@@ -21,6 +21,7 @@ class AbstractGenerateDerivative extends AbstractGenerateDerivativeBase {
       'source_term_uri' => '',
       'derivative_term_uri' => '',
       'mimetype' => '',
+      'inputargs' => '',
       'args' => '',
       'destination_media_type' => '',
       'scheme' => $this->config->get('default_scheme'),
@@ -130,6 +131,13 @@ class AbstractGenerateDerivative extends AbstractGenerateDerivativeBase {
       '#rows' => '8',
       '#description' => $this->t('Mimetype to convert to (e.g. image/jpeg, video/mp4, etc...)'),
     ];
+    $form['inputargs'] = [
+      '#type' => 'textfield',
+      '#title' => $this->t('Additional input arguments'),
+      '#default_value' => $this->configuration['inputargs'],
+      '#rows' => '8',
+      '#description' => $this->t('Additional command line options related to the source file'),
+    ];
     $form['args'] = [
       '#type' => 'textfield',
       '#title' => $this->t('Additional arguments'),
@@ -199,6 +207,7 @@ class AbstractGenerateDerivative extends AbstractGenerateDerivativeBase {
     $this->configuration['derivative_term_uri'] = $this->utils->getUriForTerm($term);
 
     $this->configuration['mimetype'] = $form_state->getValue('mimetype');
+    $this->configuration['inputargs'] = $form_state->getValue('inputargs');
     $this->configuration['args'] = $form_state->getValue('args');
     $this->configuration['scheme'] = $form_state->getValue('scheme');
     $this->configuration['path'] = trim($form_state->getValue('path'), '\\/');
diff --git a/src/Plugin/Action/AbstractGenerateDerivativeMediaFile.php b/src/Plugin/Action/AbstractGenerateDerivativeMediaFile.php
index be9eca80..15776591 100644
--- a/src/Plugin/Action/AbstractGenerateDerivativeMediaFile.php
+++ b/src/Plugin/Action/AbstractGenerateDerivativeMediaFile.php
@@ -27,6 +27,7 @@ class AbstractGenerateDerivativeMediaFile extends AbstractGenerateDerivativeBase
       'event' => 'Generate Derivative',
       'source_term_uri' => $uri,
       'mimetype' => '',
+      'inputargs' => '',
       'args' => '',
       'path' => '[date:custom:Y]-[date:custom:m]/[media:mid].bin',
       'source_field_name' => 'field_media_file',
@@ -69,6 +70,7 @@ class AbstractGenerateDerivativeMediaFile extends AbstractGenerateDerivativeBase
     $allowed = [
       'queue',
       'event',
+      'inputargs',
       'args',
       'source_uri',
       'destination_uri',
@@ -109,12 +111,20 @@ class AbstractGenerateDerivativeMediaFile extends AbstractGenerateDerivativeBase
       '#description' => $this->t('File field on Media Type to hold derivative.  Cannot be the same as source'),
     ];
 
+    $form['inputargs'] = [
+      '#type' => 'textfield',
+      '#title' => $this->t('Additional input arguments'),
+      '#default_value' => $this->configuration['inputargs'],
+      '#rows' => '8',
+      '#description' => $this->t('Additional command line options related to the source file'),
+    ];
+
     $form['args'] = [
       '#type' => 'textfield',
-      '#title' => $this->t('Additional arguments'),
+      '#title' => $this->t('Additional output arguments'),
       '#default_value' => $this->configuration['args'],
       '#rows' => '8',
-      '#description' => $this->t('Additional command line arguments'),
+      '#description' => $this->t('Additional command line options related to the output file (derivative)'),
     ];
 
     $form['mimetype'] = [
@@ -170,6 +180,7 @@ class AbstractGenerateDerivativeMediaFile extends AbstractGenerateDerivativeBase
   public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
     parent::submitConfigurationForm($form, $form_state);
     $this->configuration['mimetype'] = $form_state->getValue('mimetype');
+    $this->configuration['inputargs'] = $form_state->getValue('inputargs');
     $this->configuration['args'] = $form_state->getValue('args');
     $this->configuration['scheme'] = $form_state->getValue('scheme');
     $this->configuration['path'] = trim($form_state->getValue('path'), '\\/');

From deff2ddb267f68c3f68f172dd39ed4c101442363 Mon Sep 17 00:00:00 2001
From: Jason Hildebrand <jason@peaceworks.ca>
Date: Mon, 24 Oct 2022 12:35:52 -0500
Subject: [PATCH 2/3] Implement inputargs in GenerateImageDerivative and
 GenerateImageDerivativeFile, instead of in AbstractGenerateDerivative.  Add
 utility function to add a form element (or other array entry) at a specific
 position.

---
 .../Plugin/Action/GenerateAudioDerivative.php |  1 -
 .../config/schema/islandora_image.schema.yml  |  3 +++
 .../Plugin/Action/GenerateImageDerivative.php | 27 ++++++++++++++++---
 .../Action/GenerateImageDerivativeFile.php    | 24 ++++++++++++++---
 .../Plugin/Action/GenerateOCRDerivative.php   |  1 -
 .../Action/GenerateOCRDerivativeFile.php      |  1 -
 .../Plugin/Action/GenerateVideoDerivative.php |  1 -
 src/IslandoraUtils.php                        | 22 +++++++++++++++
 .../Action/AbstractGenerateDerivative.php     |  9 -------
 9 files changed, 69 insertions(+), 20 deletions(-)

diff --git a/modules/islandora_audio/src/Plugin/Action/GenerateAudioDerivative.php b/modules/islandora_audio/src/Plugin/Action/GenerateAudioDerivative.php
index 3f7ad896..904d05e6 100644
--- a/modules/islandora_audio/src/Plugin/Action/GenerateAudioDerivative.php
+++ b/modules/islandora_audio/src/Plugin/Action/GenerateAudioDerivative.php
@@ -36,7 +36,6 @@ class GenerateAudioDerivative extends AbstractGenerateDerivative {
     $form = parent::buildConfigurationForm($form, $form_state);
     $form['mimetype']['#description'] = $this->t('Mimetype to convert to (e.g. audio/mpeg, audio/m4a, etc...)');
     $form['args']['#description'] = $this->t('Additional command line parameters for FFMpeg');
-    unset($form['inputargs']);
     return $form;
   }
 
diff --git a/modules/islandora_image/config/schema/islandora_image.schema.yml b/modules/islandora_image/config/schema/islandora_image.schema.yml
index 687e7c11..e5910870 100644
--- a/modules/islandora_image/config/schema/islandora_image.schema.yml
+++ b/modules/islandora_image/config/schema/islandora_image.schema.yml
@@ -23,6 +23,9 @@ action.configuration.generate_image_derivative:
     args:
       type: text
       label: 'Convert Arguments'
+    inputargs:
+      type: text
+      label: 'Input arguments for convert'
     scheme:
       type: text
       label: 'Flysystem scheme'
diff --git a/modules/islandora_image/src/Plugin/Action/GenerateImageDerivative.php b/modules/islandora_image/src/Plugin/Action/GenerateImageDerivative.php
index 758c7375..8e49617e 100644
--- a/modules/islandora_image/src/Plugin/Action/GenerateImageDerivative.php
+++ b/modules/islandora_image/src/Plugin/Action/GenerateImageDerivative.php
@@ -23,7 +23,8 @@ class GenerateImageDerivative extends AbstractGenerateDerivative {
     $config = parent::defaultConfiguration();
     $config['mimetype'] = 'image/jpeg';
     $config['path'] = '[date:custom:Y]-[date:custom:m]/[node:nid].jpg';
-    $config['destination_media_type'] = 'image';
+    $config['destination_media_type'] = 'image';  
+    $config['inputargs'] = '';
     return $config;
   }
 
@@ -34,11 +35,22 @@ class GenerateImageDerivative extends AbstractGenerateDerivative {
     $form = parent::buildConfigurationForm($form, $form_state);
     $form['mimetype']['#description'] = $this->t('Mimetype to convert to (e.g. image/jpeg, image/png, etc...)');
 
-    $form['inputargs']['#title'] = $this->t('Additional input arguments');
-    $form['inputargs']['#description'] = $this->t('Additional input options for ImageMagick convert (e.g. -density 144).<br>Check the <a target="_blank" href="https://manpages.ubuntu.com/manpages/trusty/man1/convert.im6.1.html">man page</a> to see which options are input options.');
-
+    // adjust args title and description for better clarity
     $form['args']['#title'] = $this->t('Additional output arguments');
     $form['args']['#description'] = $this->t('Additional output options for ImageMagick convert (e.g. -resize 50% -unsharp 0x.5).<br>See <a target="_blank" href="https://imagemagick.org/script/convert.php">documentation</a> for available options.');
+
+    $new = [
+      'inputargs' => [
+        '#type' => 'textfield',
+        '#title' => $this->t('Additional input arguments'),
+        '#default_value' => $this->configuration['inputargs'],
+        '#rows' => '8',
+        '#description' => $this->t('Additional input options for ImageMagick convert (e.g. -density 144).<br>Check the <a target="_blank" href="https://manpages.ubuntu.com/manpages/trusty/man1/convert.im6.1.html">man page</a> to see which options are input options.'),
+      ]
+    ];
+    $form = $this->utils->array_insert_after($form, 'mimetype', $new);
+
+
     return $form;
   }
 
@@ -58,4 +70,11 @@ class GenerateImageDerivative extends AbstractGenerateDerivative {
     }
   }
 
+  /**
+   * {@inheritdoc}
+   */
+  public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
+    parent::submitConfigurationForm($form, $form_state);
+    $this->configuration['inputargs'] = $form_state->getValue('inputargs');
+  }
 }
diff --git a/modules/islandora_image/src/Plugin/Action/GenerateImageDerivativeFile.php b/modules/islandora_image/src/Plugin/Action/GenerateImageDerivativeFile.php
index 8a9d7355..dd7aa373 100644
--- a/modules/islandora_image/src/Plugin/Action/GenerateImageDerivativeFile.php
+++ b/modules/islandora_image/src/Plugin/Action/GenerateImageDerivativeFile.php
@@ -26,6 +26,7 @@ class GenerateImageDerivativeFile extends AbstractGenerateDerivativeMediaFile {
     $config['queue'] = 'islandora-connector-houdini';
     $config['destination_media_type'] = 'file';
     $config['scheme'] = $this->config->get('default_scheme');
+    $config['inputargs'] = '';
     return $config;
   }
 
@@ -38,12 +39,29 @@ class GenerateImageDerivativeFile extends AbstractGenerateDerivativeMediaFile {
     $form['mimetype']['#value'] = 'image/jpeg';
     $form['mimetype']['#type'] = 'hidden';
 
-    $form['inputargs']['#title'] = $this->t('Additional input arguments');
-    $form['inputargs']['#description'] = $this->t('Additional input options for ImageMagick convert (e.g. -density 144).<br>Check the <a target="_blank" href="https://manpages.ubuntu.com/manpages/trusty/man1/convert.im6.1.html">man page</a> to see which options are input options.');
-
+    // adjust args title and description for better clarity
     $form['args']['#title'] = $this->t('Additional output arguments');
     $form['args']['#description'] = $this->t('Additional output options for ImageMagick convert (e.g. -resize 50% -unsharp 0x.5).<br>See <a target="_blank" href="https://imagemagick.org/script/convert.php">documentation</a> for available options.');
+
+
+    $new = [
+      'inputargs' => [
+        '#type' => 'textfield',
+        '#title' => $this->t('Additional input arguments'),
+        '#default_value' => $this->configuration['inputargs'],
+        '#rows' => '8',
+        '#description' => $this->t('Additional input options for ImageMagick convert (e.g. -density 144).<br>Check the <a target="_blank" href="https://manpages.ubuntu.com/manpages/trusty/man1/convert.im6.1.html">man page</a> to see which options are input options.'),
+      ]
+    ];
+    $form = $this->utils->array_insert_after($form, 'mimetype', $new);
     return $form;
   }
 
+  /**
+   * {@inheritdoc}
+   */
+  public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
+    parent::submitConfigurationForm($form, $form_state);
+    $this->configuration['inputargs'] = $form_state->getValue('inputargs');
+  }
 }
diff --git a/modules/islandora_text_extraction/src/Plugin/Action/GenerateOCRDerivative.php b/modules/islandora_text_extraction/src/Plugin/Action/GenerateOCRDerivative.php
index 19417ec4..745c5772 100644
--- a/modules/islandora_text_extraction/src/Plugin/Action/GenerateOCRDerivative.php
+++ b/modules/islandora_text_extraction/src/Plugin/Action/GenerateOCRDerivative.php
@@ -38,7 +38,6 @@ class GenerateOCRDerivative extends AbstractGenerateDerivative {
     $form['mimetype']['#type'] = 'textfield';
 
     unset($form['args']);
-    unset($form['inputargs']);
     return $form;
   }
 
diff --git a/modules/islandora_text_extraction/src/Plugin/Action/GenerateOCRDerivativeFile.php b/modules/islandora_text_extraction/src/Plugin/Action/GenerateOCRDerivativeFile.php
index 578f1b0c..f6b8034a 100644
--- a/modules/islandora_text_extraction/src/Plugin/Action/GenerateOCRDerivativeFile.php
+++ b/modules/islandora_text_extraction/src/Plugin/Action/GenerateOCRDerivativeFile.php
@@ -58,7 +58,6 @@ class GenerateOCRDerivativeFile extends AbstractGenerateDerivativeMediaFile {
     $form = array_merge($first, $middle, $last);
 
     unset($form['args']);
-    unset($form['inputargs']);
     return $form;
   }
 
diff --git a/modules/islandora_video/src/Plugin/Action/GenerateVideoDerivative.php b/modules/islandora_video/src/Plugin/Action/GenerateVideoDerivative.php
index d5fb710d..7c861992 100644
--- a/modules/islandora_video/src/Plugin/Action/GenerateVideoDerivative.php
+++ b/modules/islandora_video/src/Plugin/Action/GenerateVideoDerivative.php
@@ -35,7 +35,6 @@ class GenerateVideoDerivative extends AbstractGenerateDerivative {
     $form = parent::buildConfigurationForm($form, $form_state);
     $form['mimetype']['#description'] = $this->t('Mimetype to convert to (e.g. video/mp4, video/quicktime, etc...)');
     $form['args']['#description'] = $this->t('Additional command line parameters for FFMpeg');
-    unset($form['inputargs']);
     return $form;
   }
 
diff --git a/src/IslandoraUtils.php b/src/IslandoraUtils.php
index f81cb747..43f2fb78 100644
--- a/src/IslandoraUtils.php
+++ b/src/IslandoraUtils.php
@@ -751,4 +751,26 @@ class IslandoraUtils {
     return $parents;
   }
 
+  /**
+    * Insert a value or key/value pair after a specific key in an array.  If key doesn't exist, value is appended
+    * to the end of the array.
+    *
+    * This is not islandora specific, but a useful function that neither PHP nor Drupal provide.
+    * (is there still hope after 16 years?  https://www.drupal.org/project/drupal/issues/66183 )
+    *
+    * @param array $array
+    * @param string $key
+    * @param array $new
+    *
+    * @return array
+    *
+    * Credit: https://gist.github.com/wpscholar/0deadce1bbfa4adb4e4c
+    */
+  function array_insert_after( array $array, $key, array $new ) {
+	$keys = array_keys( $array );
+	$index = array_search( $key, $keys );
+	$pos = false === $index ? count( $array ) : $index + 1;
+	return array_merge( array_slice( $array, 0, $pos ), $new, array_slice( $array, $pos ) );
+  }
+
 }
diff --git a/src/Plugin/Action/AbstractGenerateDerivative.php b/src/Plugin/Action/AbstractGenerateDerivative.php
index a2e44a65..b22201e1 100644
--- a/src/Plugin/Action/AbstractGenerateDerivative.php
+++ b/src/Plugin/Action/AbstractGenerateDerivative.php
@@ -21,7 +21,6 @@ class AbstractGenerateDerivative extends AbstractGenerateDerivativeBase {
       'source_term_uri' => '',
       'derivative_term_uri' => '',
       'mimetype' => '',
-      'inputargs' => '',
       'args' => '',
       'destination_media_type' => '',
       'scheme' => $this->config->get('default_scheme'),
@@ -131,13 +130,6 @@ class AbstractGenerateDerivative extends AbstractGenerateDerivativeBase {
       '#rows' => '8',
       '#description' => $this->t('Mimetype to convert to (e.g. image/jpeg, video/mp4, etc...)'),
     ];
-    $form['inputargs'] = [
-      '#type' => 'textfield',
-      '#title' => $this->t('Additional input arguments'),
-      '#default_value' => $this->configuration['inputargs'],
-      '#rows' => '8',
-      '#description' => $this->t('Additional command line options related to the source file'),
-    ];
     $form['args'] = [
       '#type' => 'textfield',
       '#title' => $this->t('Additional arguments'),
@@ -207,7 +199,6 @@ class AbstractGenerateDerivative extends AbstractGenerateDerivativeBase {
     $this->configuration['derivative_term_uri'] = $this->utils->getUriForTerm($term);
 
     $this->configuration['mimetype'] = $form_state->getValue('mimetype');
-    $this->configuration['inputargs'] = $form_state->getValue('inputargs');
     $this->configuration['args'] = $form_state->getValue('args');
     $this->configuration['scheme'] = $form_state->getValue('scheme');
     $this->configuration['path'] = trim($form_state->getValue('path'), '\\/');

From 6ae0cb035dc2ee49c56922cbd29358e8b2c98434 Mon Sep 17 00:00:00 2001
From: Jason Hildebrand <jason@peaceworks.ca>
Date: Mon, 24 Oct 2022 12:38:44 -0500
Subject: [PATCH 3/3] Removing extra whitespace.

---
 .../src/Plugin/Action/GenerateImageDerivative.php               | 2 --
 .../src/Plugin/Action/GenerateImageDerivativeFile.php           | 2 +-
 2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/modules/islandora_image/src/Plugin/Action/GenerateImageDerivative.php b/modules/islandora_image/src/Plugin/Action/GenerateImageDerivative.php
index 8e49617e..dec55659 100644
--- a/modules/islandora_image/src/Plugin/Action/GenerateImageDerivative.php
+++ b/modules/islandora_image/src/Plugin/Action/GenerateImageDerivative.php
@@ -49,8 +49,6 @@ class GenerateImageDerivative extends AbstractGenerateDerivative {
       ]
     ];
     $form = $this->utils->array_insert_after($form, 'mimetype', $new);
-
-
     return $form;
   }
 
diff --git a/modules/islandora_image/src/Plugin/Action/GenerateImageDerivativeFile.php b/modules/islandora_image/src/Plugin/Action/GenerateImageDerivativeFile.php
index dd7aa373..a18f076e 100644
--- a/modules/islandora_image/src/Plugin/Action/GenerateImageDerivativeFile.php
+++ b/modules/islandora_image/src/Plugin/Action/GenerateImageDerivativeFile.php
@@ -43,7 +43,6 @@ class GenerateImageDerivativeFile extends AbstractGenerateDerivativeMediaFile {
     $form['args']['#title'] = $this->t('Additional output arguments');
     $form['args']['#description'] = $this->t('Additional output options for ImageMagick convert (e.g. -resize 50% -unsharp 0x.5).<br>See <a target="_blank" href="https://imagemagick.org/script/convert.php">documentation</a> for available options.');
 
-
     $new = [
       'inputargs' => [
         '#type' => 'textfield',
@@ -54,6 +53,7 @@ class GenerateImageDerivativeFile extends AbstractGenerateDerivativeMediaFile {
       ]
     ];
     $form = $this->utils->array_insert_after($form, 'mimetype', $new);
+
     return $form;
   }