Skip to content

HEIC/SVG/TIFF/PDF preview generation broken in 34.0.2~ynh1 — IMagickSupport hardcoded to return false #898

Description

@brzeziniol

I’m very sorry, but I’m not tech-savvy or skilled in programming; however, it seems to me that there’s an error preventing the preview of certain files from being generated.
Below, I’ll describe how the issue looks from Cloude AI’s perspective:

Environment

  • Nextcloud version: 34.0.2~ynh1
  • YunoHost version: 12.1.40.1
  • OS: Debian 12 (bookworm)
  • PHP: 8.4, imagick extension 3.8.1 installed and loaded (confirmed via php8.4 -m | grep imagick)
  • ImageMagick 6.9.11.60 with libheif 1.15.1 — HEIC coder confirmed present via identify -list format | grep -i heic

Summary

No preview/thumbnail is generated for any file type that depends on the Imagick-based
preview providers (HEIC, SVG, TIFF, PDF-via-Imagick, AI, PSD, EPS, TTF, TGA, SGI), even
though every prerequisite is in place:

  • enabledPreviewProviders in config.php correctly includes OC\Preview\HEIC
  • ImageMagick + libheif on the host fully support HEIC (manual convert/identify on a
    real file succeeds instantly, correct dimensions, valid JPEG output)
  • Imagick::queryFormats('HEI*') returns ['HEIC'] as expected
  • OC\Preview\HEIC::isAvailable() returns true when tested in isolation via php -r
  • The file's mimetype in oc_filecache/oc_mimetypes is correctly image/heic
  • File permissions are correct (owned by the nextcloud system user, readable/convertible
    by it directly)
  • Non-Imagick providers (JPEG, PNG, etc.) generate previews normally on the exact same
    folder/mount

occ preview:generate <fileid> consistently reports:
No preview generator available for file of type image/heic

Root cause

Traced to /var/www/nextcloud/lib/private/Preview/IMagickSupport.php. Both
hasExtension() and supportsFormat() have an unconditional return false; as their
first statement, before any real logic:

public function hasExtension(): bool {
    return false;
    return !is_null($this->imagick);
}

public function supportsFormat(string $format): bool {
    return false;
    if (is_null($this->imagick)) {
        return false;
    }
    ...
}

This makes the real logic permanently unreachable. As a result,
PreviewManager::registerCoreProviders() never registers any of the Imagick-gated
providers, since they're all conditioned on if ($this->imagickSupport->hasExtension())
— regardless of enabledPreviewProviders, and regardless of whether Imagick/libheif
actually support the format.

This may be an intentional (if very blunt) mitigation related to the HEIC/Imagick
security concerns discussed in nextcloud/server#58393 and the older HackerOne report
referenced in nextcloud/server#28077. If so, it would help a lot to have this documented
somewhere (release notes, or a warning in the admin overview page) — currently it fails
completely silently, with no indication to the admin that Imagick support was disabled
at the package level.

Secondary bug noticed

Independent of the above, in supportsFormat() the caching line looks like a
copy-paste mistake:

$formatSupported = count($this->imagick->queryFormats($format)) === 1;
$this->cache->set($format, $cached); // should probably be $formatSupported, not $cached (still null here)
return $formatSupported;

Steps to reproduce

  1. Fresh/updated install on 34.0.2~ynh1 with the imagick PHP extension installed and
    HEIC support confirmed via libheif.
  2. Add OC\Preview\HEIC to enabledPreviewProviders in config.php.
  3. occ preview:generate <fileid_of_a_heic_file> → "No preview generator available",
    despite the format being fully supported by the underlying stack.

Suggested fix

Remove the two stray return false; lines, or replace them with a real,
documented config flag if disabling Imagick previews by default is intentional.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions