Conversation
sbreker
left a comment
There was a problem hiding this comment.
Hi Daniel - thank you so much for this code contribution! I have added some additional feedback regarding the memcache change, and the logic to fall back to using ImageMagick via exec(). Please let me know if there is anything I should be considering with respect to these requests. Interested to hear your thoughts.
lib/model/QubitDigitalObject.php
Outdated
| $pages = sfImageMagickAdapter::getPdfinfoPageCount($filename); | ||
| } else { | ||
| $command = 'identify '.$filename; | ||
| } elseif (sfImageMagickAdapter::isImageMagickAvailable()) { |
There was a problem hiding this comment.
I've been thinking about the logic to fall back to using ImageMagick in the event that the Imagick PHP extension is not present. I think that while this may provide some convenience with respect to AtoM upgrade requirements, I think it is more important to completely remove the original way of calling ImageMagick with exec() calls and rely solely on your new work to introduce Imagick. Removing the calls to exec() entirely will avoid triggering alerts in future security scans and remove the risk associated with these calls. In this case, if we remove all dependency on sfImageMagickAdapter.class.php, then we might be able to delete sfImageMagickAdapter.class.php entirely (I have not checked if there are other locations where it is referenced - but removing it would have implications for the PDF page count methods in there).
There was a problem hiding this comment.
That would certainly simplify things in the code. One issue I can see with that change is that we'll want to ensure the upgrade instructions are up to date for whichever version of AtoM this ends up in since php8.3-imagick will be a dependency requirement , and imagemagick will no longer be required.
The imagick adapter handles PDF page counts without the use of Poppler (i.e., pdfinfo), having spent some time with this part of the code, I think completely removing sfImageMagickAdapter shouldn't be an issue at all.
lib/model/om/BaseDigitalObject.php
Outdated
| try | ||
| { | ||
| return call_user_func_array('QubitObject::__get', $args); | ||
| return parent::__get(...$args); |
There was a problem hiding this comment.
I think this file is generated by Symfony. Was this change the result of running a php symfony commands?
There was a problem hiding this comment.
I can't remember why I made that change initially, but things are still working with that change reverted.
This is based on the sfImageMagickAdapter. I opted not to use pdfinfo so that there is no exec() going on in this new adapter.
This has to be set *before* reading an image.
I needed to remove it from three places:
1. From the digital object derivatives setting action. imagick handles
PDF page extraction, not pdfinfo any more. So I changed the error
message to reflect that.
2. From the QubitDigitalObject class. I was using the
sfImageMagickAdapter as a fallback for sfImagickAdapter, so I removed
those fallback cases.
3. From the lime unit tests in the sfThumbnailPlugin.
The unit tests do run successfully in the sfThumbnailPlugin class, but
it's tedious to run them.
In case you want to run them, you need to run these commands in the
Docker container to install gd.
apk add libpng-dev libjpeg-turbo-dev
docker-php-ext-configure gd --with-jpeg
docker-php-ext-install gd
This is because the tests *require* you to have gd installed, and gd is
not installed in the base AtoM image.
And then to run the tests, you invoke the test file directly:
php plugins/sfThumbnailPlugin/test/unit/sfThumbnailTest.php
You'll see this when the tests run:
# Looks like everything went fine.
# Looks like everything went fine.
It's no longer needed! Also, added a note to the README of the plugin since the way the plugin works has changed a lot.
f413650 to
49302a5
Compare
apps/qubit/modules/settings/templates/digitalObjectDerivativesSuccess.php
Outdated
Show resolved
Hide resolved
| */ | ||
| class sfImagickAdapter | ||
| { | ||
| protected const string PDF_EXTRACT_BACKGROUND = 'white'; |
There was a problem hiding this comment.
I would suggest omitting the type here since this would break in PHP 8.1 and PHP 8.2, which our documentation still lists as being supported in AtoM 2.10.x
There was a problem hiding this comment.
Good catch, I removed the types in a36230a
lib/model/QubitDigitalObject.php
Outdated
| public const string MULTI_PAGE_ASSET_EXTRACT_BACKGROUND = 'white'; | ||
| public const string MULTI_PAGE_ASSET_EXTRACT_FORMAT = 'jpeg'; | ||
| public const int MULTI_PAGE_ASSET_EXTRACT_QUALITY = 100; | ||
| public const int MULTI_PAGE_ASSET_EXTRACT_RESOLUTION = 300; // This controls the DPI |
There was a problem hiding this comment.
We should omit the types here as well since this would break in PHP 8.1 and PHP 8.2.

Closes #2163
sfImagickAdapterthat can be used with thesfThumbnailclass.Adds deprecation warnings to methods using(Removed sfImageMagickAdapter)pdfinfo,convert, oridentifywithsfImageMagickAdapter. The old adapter still works, but the new adapter is used ifimagickis installed.imagickif it's installed.Things that are not complete:
Unit tests.(Tests added)Copyright block at the top of the new adapter? I added a new file to a plugin that was not developed at Artefactual, not sure what sort of copyright case that falls under. I'd guess the regular AtoM copyright block but I'm not sure whether the licenses are compatible.(Added the default AtoM copyright block based on CODE_OF_CONDUCT.md)Also of note, I did not implement the fancy thumbnail method that
sfImageMagickAdapterdoes since I couldn't see any place where those custom methods were being used.