Preview for PSD grabs first layer only

The PSD preview “thumbnail” works great if you only have one Photoshop layer or if your first layer makes a reasonable thumbnail. (Mine are mostly coming out as white boxes).

Has anyone messed with a way to have imagemagick “flatten” the PSD layers prior to generating the preview?

If I’m barking up the right tree, something in…
/var/www/owncloud/lib/private/Preview/Bitmap.php

I just haven’t found something that works yet.

Thanks in advance…

ST@Miami

I played with it some more and this works for me, if anyone else needs it:

private function getResizedPreview($stream, $maxX, $maxY) {
                $bp = new Imagick();

                $bp->readImageFile($stream);

                //Enables flattening multi-layer PSDs
                $bp->mergeImageLayers(Imagick::LAYERMETHOD_FLATTEN);
                //

                $bp = $this->resize($bp, $maxX, $maxY);

                $bp->setImageFormat('png');

                return $bp;
        }
/var/www/owncloud/lib/private/Preview/Bitmap.php

88,91d87
<               //Enables flattening multi-layer PSDs
<               $bp->mergeImageLayers(Imagick::LAYERMETHOD_FLATTEN);
<               //
< 

Caution:
Uses a lot of memory on large multi-layer PSDs.
Manage Imagick memusage in /etc/ImageMagick-X/policy.xml

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.