getLocalFile($file); try { $audio = new Mp3Info($tmpPath, true); /** @var string|null|false $picture */ $picture = $audio->getCover(); } catch (\Throwable $e) { logger('core')->info('Error while getting cover from mp3 file: ' . $e->getMessage(), [ 'fileId' => $file->getId(), 'filePath' => $file->getPath(), ]); return null; } finally { $this->cleanTmpFiles(); } if (is_string($picture)) { $image = new \OCP\Image(); $image->loadFromData($picture); if ($image->valid()) { $image->scaleDownToFit($maxX, $maxY); return $image; } } return null; } }