Skip to content

Commit

Permalink
fix: Use IPreview by default, then fall back to gd
Browse files Browse the repository at this point in the history
Signed-off-by: Marcel Klehr <[email protected]>
  • Loading branch information
marcelklehr committed Nov 19, 2023
1 parent e7b815e commit a669ee8
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lib/Classifiers/Classifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -275,15 +275,15 @@ private function getConvertedFilePath(Node $file): string {
try {
$this->logger->debug('generating preview of ' . $file->getId() . ' with dimension '.self::TEMP_FILE_DIMENSION);

$imageType = exif_imagetype($path); //To troubleshoot console errors, GD does not support all formats.
if (0 < $imageType) {
return $this->generatePrevieWithGD($path);
} else {
if (!$this->previewProvider->isAvailable($file)) {
if (!$this->previewProvider->isAvailable($file)) {
$imageType = exif_imagetype($path); //To troubleshoot console errors, GD does not support all formats.
if ($imageType > 0) {
return $this->generatePreviewWithGD($path);
} else {
return $path;
}
return $this->generatePreviewWithProvider($file);
}
return $this->generatePreviewWithProvider($file);
} catch(\Throwable $e) {
$this->logger->warning('Failed to generate preview of ' . $file->getId() . ' with dimension '.self::TEMP_FILE_DIMENSION . ': ' . $e->getMessage());
return $path;
Expand Down Expand Up @@ -347,7 +347,7 @@ public function generatePreviewWithProvider(File $file): string {
* @return string
* @throws \OCA\Recognize\Exception\Exception
*/
public function generatePrevieWithGD(string $path): string {
public function generatePreviewWithGD(string $path): string {
$image = imagecreatefromstring(file_get_contents($path));
$width = imagesx($image);
$height = imagesy($image);
Expand Down

0 comments on commit a669ee8

Please sign in to comment.