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

Add support for HEIC/HEIF/TIFF #365

Merged
merged 5 commits into from
Oct 12, 2022
Merged
Changes from 1 commit
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
8 changes: 6 additions & 2 deletions lib/Classifiers/Classifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,13 @@ private function getConvertedFilePath(Node $file): string {
$tmpname = $this->tempManager->getTemporaryFile('.jpg');

try {
// Downscale into a temporary JPEG file
// Convert to a temporary JPEG file optionally downscaling
$imagick = new \Imagick($path);
$imagick->scaleImage(4096, 4096, true);
$dimensions = $imagick->getImageGeometry();
if ($dimensions['width'] > 4096 || $dimensions['height'] > 4096) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Imagick before 3.0.0 used to leave the image untouched if it was smaller than the specified scaling; I didn't know the behavior had changed.

// downscale
$imagick->scaleImage(4096, 4096, true);
}
$imagick->setImageFormat('jpeg');
$imagick->writeImage($tmpname);
} catch (\ImagickException $e) {
Expand Down