fix: link old

This commit is contained in:
hashbro
2026-09-14 02:23:56 +08:00
parent f85aa3654a
commit b5af8a3748
3 changed files with 77 additions and 28 deletions
+17 -26
View File
@@ -190,18 +190,17 @@ class PhotoPreview
]);
continue;
}
if (! $result->successful()) {
Log::warning('heic preview convert cmd failed', [
'path' => $absPath,
'cmd' => implode(' ', $cmd),
'stderr' => trim($result->errorOutput()),
]);
continue;
}
$bytes = $this->readConvertedJpeg($dst);
if ($bytes !== null) {
return $bytes;
}
Log::warning('heic preview convert cmd failed', [
'path' => $absPath,
'cmd' => implode(' ', $cmd),
'exit' => $result->exitCode(),
'stdout' => trim($result->output()),
'stderr' => trim($result->errorOutput()),
]);
}
return null;
@@ -237,22 +236,16 @@ class PhotoPreview
if (PHP_OS_FAMILY === 'Darwin' && $this->isSafeExecutable('/usr/bin/sips')) {
$cmds[] = ['/usr/bin/sips', '-s', 'format', 'jpeg', '--out', $dst, $src];
}
foreach (['heif-convert', 'heif-dec'] as $bin) {
$path = $this->resolveBinary($bin);
if ($path === null) {
continue;
$heif = $this->resolveBinary('heif-convert');
if ($heif !== null) {
$cmds[] = [$heif, $src, $dst];
$cmds[] = [$heif, '-q', '85', $src, $dst];
}
if (PHP_OS_FAMILY === 'Darwin') {
$magick = $this->resolveBinary('magick');
if ($magick !== null) {
$cmds[] = [$magick, $src, '-quality', '85', $dst];
}
$cmds[] = [$path, $src, $dst];
$cmds[] = [$path, '-q', '85', $src, $dst];
$cmds[] = [$path, $src, '-o', $dst];
}
$magick = $this->resolveBinary('magick');
if ($magick !== null) {
$cmds[] = [$magick, $src, '-quality', '85', $dst];
}
$convert = $this->resolveBinary('convert');
if ($convert !== null) {
$cmds[] = [$convert, $src, '-quality', '85', $dst];
}
return $cmds;
@@ -262,9 +255,7 @@ class PhotoPreview
{
$candidates = match ($name) {
'magick' => [base_path('bin/magick'), '/opt/homebrew/bin/magick', '/usr/local/bin/magick', '/usr/bin/magick', 'magick'],
'convert' => [base_path('bin/convert'), '/usr/bin/convert', 'convert'],
'heif-convert' => [base_path('bin/heif-convert'), '/usr/bin/heif-convert', '/usr/local/bin/heif-convert', 'heif-convert'],
'heif-dec' => [base_path('bin/heif-dec'), '/usr/bin/heif-dec', '/usr/local/bin/heif-dec', 'heif-dec'],
'heif-convert' => [base_path('bin/heif-convert'), '/usr/bin/heif-convert', '/usr/bin/heif-dec', '/usr/local/bin/heif-convert', 'heif-convert'],
default => [$name],
};
$outside = null;