-
-
Notifications
You must be signed in to change notification settings - Fork 36
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
PDFs causing failed queues #364
Comments
Any updates or thoughts on this @khalwat? is skipping the PDFs an option that you could write in? Thanks again! |
Yes, I think adding an option to allow PDFs to be ignored is a good way forward, for setups where PDFs are not rendering properly due to Imagick failing as shown in your stack trace. Probably it is running out of memory, due to complex or larger PDFs |
@khalwat awesome and thanks! Yeah we're not really running into these issues on production as that's a much beefier server. But it would still be nice to be able to skip PDFs from being optimized. I appreciate the response and will look for an update whenever you get to it. Happy Holidays Andrew and thanks again! I was certain that this would work:
|
This snippet lets you pick whether an optimize job gets queued or not depending on the extension. Works well for us. Craft::$app->getQueue()->on(
Queue::EVENT_BEFORE_PUSH,
function(PushEvent $event): void {
if (ResaveOptimizedImages::class !== $event->job::class) {
return; // Do not intervene. Not the optimize job.
}
$asset = Asset::findOne($event->job->criteria);
$unskippableExtensions = [
'jpg', 'jpeg', 'png', 'bmp', 'gif', 'webp',
];
if (in_array($asset->getExtension(), $unskippableExtensions, true)) {
return; // All good. Let it through.
}
$event->handled = true; // Short-circuit to skip.
}
); |
Addressed via the above commits. |
It appears that I/O is trying to optimize PDFs and when those fail/error-out the other optimizations don't run. I'm showing multiple failed "Optimizing images in X...."
Is there a way to skip PDFs? I know you added the Ignore SVGs/Gif option. Can we add PDFs to that as well? This would be handy as a global option in
config/image-optimize.php
or in the field settings.Screenshots
Versions
Thanks for the help!
Additional Info
I just got this reply back from Matt @ Servd and I'm not sure if this helps:
Hey Mark. It looks like image magick bailed when attempting to create a placeholder image. It doesn't specify why exactly, just that it hit a Runtime Error.
I've seen that before with PNG files that have been optimised previously. ImageMagick has a bug where it explodes when it tries to process them.
It seems to be the first image in the open graph images volume that it got upset about but I'm not 100% sure what order ImageOptimize processes them in.
The text was updated successfully, but these errors were encountered: