Browse Source

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).

pull/904/head
Jason Hildebrand 2 years ago
parent
commit
94bfdd0de1
  1. 1
      modules/islandora_audio/src/Plugin/Action/GenerateAudioDerivative.php
  2. 7
      modules/islandora_image/src/Plugin/Action/GenerateImageDerivative.php
  3. 6
      modules/islandora_image/src/Plugin/Action/GenerateImageDerivativeFile.php
  4. 1
      modules/islandora_text_extraction/src/Plugin/Action/GenerateOCRDerivative.php
  5. 1
      modules/islandora_text_extraction/src/Plugin/Action/GenerateOCRDerivativeFile.php
  6. 1
      modules/islandora_video/src/Plugin/Action/GenerateVideoDerivative.php
  7. 9
      src/Plugin/Action/AbstractGenerateDerivative.php
  8. 15
      src/Plugin/Action/AbstractGenerateDerivativeMediaFile.php

1
modules/islandora_audio/src/Plugin/Action/GenerateAudioDerivative.php

@ -36,6 +36,7 @@ class GenerateAudioDerivative extends AbstractGenerateDerivative {
$form = parent::buildConfigurationForm($form, $form_state); $form = parent::buildConfigurationForm($form, $form_state);
$form['mimetype']['#description'] = $this->t('Mimetype to convert to (e.g. audio/mpeg, audio/m4a, etc...)'); $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'); $form['args']['#description'] = $this->t('Additional command line parameters for FFMpeg');
unset($form['inputargs']);
return $form; return $form;
} }

7
modules/islandora_image/src/Plugin/Action/GenerateImageDerivative.php

@ -33,7 +33,12 @@ class GenerateImageDerivative extends AbstractGenerateDerivative {
public function buildConfigurationForm(array $form, FormStateInterface $form_state) { public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$form = parent::buildConfigurationForm($form, $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['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; return $form;
} }

6
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']['#description'] = $this->t('Mimetype to convert to (e.g. application/xml, etc...)');
$form['mimetype']['#value'] = 'image/jpeg'; $form['mimetype']['#value'] = 'image/jpeg';
$form['mimetype']['#type'] = 'hidden'; $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; return $form;
} }

1
modules/islandora_text_extraction/src/Plugin/Action/GenerateOCRDerivative.php

@ -38,6 +38,7 @@ class GenerateOCRDerivative extends AbstractGenerateDerivative {
$form['mimetype']['#type'] = 'textfield'; $form['mimetype']['#type'] = 'textfield';
unset($form['args']); unset($form['args']);
unset($form['inputargs']);
return $form; return $form;
} }

1
modules/islandora_text_extraction/src/Plugin/Action/GenerateOCRDerivativeFile.php

@ -58,6 +58,7 @@ class GenerateOCRDerivativeFile extends AbstractGenerateDerivativeMediaFile {
$form = array_merge($first, $middle, $last); $form = array_merge($first, $middle, $last);
unset($form['args']); unset($form['args']);
unset($form['inputargs']);
return $form; return $form;
} }

1
modules/islandora_video/src/Plugin/Action/GenerateVideoDerivative.php

@ -35,6 +35,7 @@ class GenerateVideoDerivative extends AbstractGenerateDerivative {
$form = parent::buildConfigurationForm($form, $form_state); $form = parent::buildConfigurationForm($form, $form_state);
$form['mimetype']['#description'] = $this->t('Mimetype to convert to (e.g. video/mp4, video/quicktime, etc...)'); $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'); $form['args']['#description'] = $this->t('Additional command line parameters for FFMpeg');
unset($form['inputargs']);
return $form; return $form;
} }

9
src/Plugin/Action/AbstractGenerateDerivative.php

@ -21,6 +21,7 @@ class AbstractGenerateDerivative extends AbstractGenerateDerivativeBase {
'source_term_uri' => '', 'source_term_uri' => '',
'derivative_term_uri' => '', 'derivative_term_uri' => '',
'mimetype' => '', 'mimetype' => '',
'inputargs' => '',
'args' => '', 'args' => '',
'destination_media_type' => '', 'destination_media_type' => '',
'scheme' => $this->config->get('default_scheme'), 'scheme' => $this->config->get('default_scheme'),
@ -130,6 +131,13 @@ class AbstractGenerateDerivative extends AbstractGenerateDerivativeBase {
'#rows' => '8', '#rows' => '8',
'#description' => $this->t('Mimetype to convert to (e.g. image/jpeg, video/mp4, etc...)'), '#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'] = [ $form['args'] = [
'#type' => 'textfield', '#type' => 'textfield',
'#title' => $this->t('Additional arguments'), '#title' => $this->t('Additional arguments'),
@ -199,6 +207,7 @@ class AbstractGenerateDerivative extends AbstractGenerateDerivativeBase {
$this->configuration['derivative_term_uri'] = $this->utils->getUriForTerm($term); $this->configuration['derivative_term_uri'] = $this->utils->getUriForTerm($term);
$this->configuration['mimetype'] = $form_state->getValue('mimetype'); $this->configuration['mimetype'] = $form_state->getValue('mimetype');
$this->configuration['inputargs'] = $form_state->getValue('inputargs');
$this->configuration['args'] = $form_state->getValue('args'); $this->configuration['args'] = $form_state->getValue('args');
$this->configuration['scheme'] = $form_state->getValue('scheme'); $this->configuration['scheme'] = $form_state->getValue('scheme');
$this->configuration['path'] = trim($form_state->getValue('path'), '\\/'); $this->configuration['path'] = trim($form_state->getValue('path'), '\\/');

15
src/Plugin/Action/AbstractGenerateDerivativeMediaFile.php

@ -27,6 +27,7 @@ class AbstractGenerateDerivativeMediaFile extends AbstractGenerateDerivativeBase
'event' => 'Generate Derivative', 'event' => 'Generate Derivative',
'source_term_uri' => $uri, 'source_term_uri' => $uri,
'mimetype' => '', 'mimetype' => '',
'inputargs' => '',
'args' => '', 'args' => '',
'path' => '[date:custom:Y]-[date:custom:m]/[media:mid].bin', 'path' => '[date:custom:Y]-[date:custom:m]/[media:mid].bin',
'source_field_name' => 'field_media_file', 'source_field_name' => 'field_media_file',
@ -69,6 +70,7 @@ class AbstractGenerateDerivativeMediaFile extends AbstractGenerateDerivativeBase
$allowed = [ $allowed = [
'queue', 'queue',
'event', 'event',
'inputargs',
'args', 'args',
'source_uri', 'source_uri',
'destination_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'), '#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'] = [ $form['args'] = [
'#type' => 'textfield', '#type' => 'textfield',
'#title' => $this->t('Additional arguments'), '#title' => $this->t('Additional output arguments'),
'#default_value' => $this->configuration['args'], '#default_value' => $this->configuration['args'],
'#rows' => '8', '#rows' => '8',
'#description' => $this->t('Additional command line arguments'), '#description' => $this->t('Additional command line options related to the output file (derivative)'),
]; ];
$form['mimetype'] = [ $form['mimetype'] = [
@ -170,6 +180,7 @@ class AbstractGenerateDerivativeMediaFile extends AbstractGenerateDerivativeBase
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) { public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
parent::submitConfigurationForm($form, $form_state); parent::submitConfigurationForm($form, $form_state);
$this->configuration['mimetype'] = $form_state->getValue('mimetype'); $this->configuration['mimetype'] = $form_state->getValue('mimetype');
$this->configuration['inputargs'] = $form_state->getValue('inputargs');
$this->configuration['args'] = $form_state->getValue('args'); $this->configuration['args'] = $form_state->getValue('args');
$this->configuration['scheme'] = $form_state->getValue('scheme'); $this->configuration['scheme'] = $form_state->getValue('scheme');
$this->configuration['path'] = trim($form_state->getValue('path'), '\\/'); $this->configuration['path'] = trim($form_state->getValue('path'), '\\/');

Loading…
Cancel
Save