NC14 : Problems with preview TIF, AI, RAW images on new installation

Hi everybody,

Since i have migrated my Nextcloud 14 to Ubuntu 18.04 from Ubuntu 16.04 i cannot manage to make the images preview working on some extensions like TIF, RAW, or AI.

I tried a lot of things even launching my own php scripts with imagick which are working on the server.

It’s weird because it’s working with PNG or JPEG with Nextcloud.

Does someone encountered the same problems.

Nextcloud version : 14.0.4
Operating system and version : Ubuntu 18.04
Apache : 2.4
PHP version : 7.2

The output of your Nextcloud log in Admin > Logging:

OCP\Files\NotFoundException: 

    /var/www/nextcloud-14.0.4/lib/private/Preview/Generator.php - line 118:

    OC\Preview\Generator->getMaxPreview(OC\Files\Sim ... {}, OC\Files\Node\File {}, "image/x-dcraw")

    /var/www/nextcloud-14.0.4/lib/private/PreviewManager.php - line 205:

    OC\Preview\Generator->getPreview(OC\Files\Node\File {}, 200, 200, false, "fill", "image/x-dcraw")

    /var/www/nextcloud-14.0.4/apps/gallery/lib/Service/PreviewService.php - line 106:

    OC\PreviewManager->getPreview(OC\Files\Node\File {}, 200, 200, false)

    /var/www/nextcloud-14.0.4/apps/gallery/lib/Controller/Preview.php - line 167:

    OCA\Gallery\Service\PreviewService->createPreview(OC\Files\Node\File {}, 200, 200, true, false)

    /var/www/nextcloud-14.0.4/apps/gallery/lib/Controller/Preview.php - line 117:

    OCA\Gallery\Controller\PreviewController->getPreviewData(OC\Files\Node\File {}, true, 200, 200, true, false)

    /var/www/nextcloud-14.0.4/apps/gallery/lib/Controller/PreviewController.php - line 134:

    OCA\Gallery\Controller\PreviewController->getData(3623549, 200, 200)

    /var/www/nextcloud-14.0.4/lib/private/AppFramework/Http/Dispatcher.php - line 166:

    OCA\Gallery\Controller\PreviewController->getPreview(3623549, 200, 200)

    /var/www/nextcloud-14.0.4/lib/private/AppFramework/Http/Dispatcher.php - line 99:

    OC\AppFramework\Http\Dispatcher->executeController(OCA\Gallery\ ... {}, "getPreview")

    /var/www/nextcloud-14.0.4/lib/private/AppFramework/App.php - line 118:

    OC\AppFramework\Http\Dispatcher->dispatch(OCA\Gallery\ ... {}, "getPreview")

    /var/www/nextcloud-14.0.4/lib/private/AppFramework/Routing/RouteActionHandler.php - line 47:

    OC\AppFramework\App::main("PreviewController", "getPreview", OC\AppFramew ... {}, { fileId: "3 ... "})

    OC\AppFramework\Routing\RouteActionHandler->__invoke({ fileId: "3 ... "})

    /var/www/nextcloud-14.0.4/lib/private/Route/Router.php - line 297:

    call_user_func(OC\AppFramew ... {}, { fileId: "3 ... "})

    /var/www/nextcloud-14.0.4/lib/base.php - line 987:

    OC\Route\Router->match("/apps/gallery/preview/3623549")

    /var/www/nextcloud-14.0.4/index.php - line 42:

    OC::handleRequest()

Ok i have resolved some of the issues for the AI, EPS, PDF files changing policy for ImageMagick :

But i’m still struggling with the TIF format …

Edit : the same tif file renamed only by it’s extension in ‘.tiff’ is working … I’m missing something…

Still digging i have found that adding an imagickProvider in the PreviewManager.php for the tif files like this make a lot of files being generated :

                         $imagickProviders = [
                            'SVG'   => ['mimetype' => '/image\/svg\+xml/', 'class' => Preview\SVG::class],
                            'TIFF'  => ['mimetype' => '/image\/tiff/', 'class' => Preview\TIFF::class],
                            **'TIF'  => ['mimetype' => '/image\/tiff/', 'class' => Preview\TIFF::class],**
                            'PDF'   => ['mimetype' => '/application\/pdf/', 'class' => Preview\PDF::class],
                            'AI'    => ['mimetype' => '/application\/illustrator/', 'class' => Preview\Illustrator::class],
                            'PSD'   => ['mimetype' => '/application\/x-photoshop/', 'class' => Preview\Photoshop::class],
                            'EPS'   => ['mimetype' => '/application\/postscript/', 'class' => Preview\Postscript::class],
                            'TTF'   => ['mimetype' => '/application\/(?:font-sfnt|x-font$)/', 'class' => Preview\Font::class],
                            'HEIC'  => ['mimetype' => '/image\/hei(f|c)/', 'class' => Preview\HEIC::class],
                    ];

Now the preview for the images with extension tif are working if the mimetype is image/tiff for those recognize as x-dcraw is not working.

So each extension has only one mimetype but i need one for TIF and one for TIFF

I suppose two things changed in the code :

  1. each $imagickProviders works for only one extension

  2. the mimetype for the tif files can be recognized as image/x-dcraw

Maybe the imagick lib has changed also on the Ubuntu 18.04 version.

Still searching for the solution.

Finally i made it, adding the mimetype in the registerCoreProvider in the PreviewManager.php around the line 363

$this->registerCoreProvider(Preview\TIFF::class, '/image\/x-dcraw/');
$this->registerCoreProvider(Preview\TIFF::class, '/image\/tif/');

Do i have to submit the bug on the gitHub ?