public function preview($attachmentId = null)
    {
        // FIXME cache previews
        $attachment = $this->Attachments->get($attachmentId);
        $this->_checkAuthorization($attachment);

        switch ($attachment->filetype) {
            case 'image/png':
            case 'image/jpg':
            case 'image/jpeg':
            case 'image/gif':
                $image = new \Imagick($attachment->getAbsolutePath());
                if (Configure::read('Attachments.autorotate')) {
                    $this->_autorotate($image);
                }
                break;
            case 'application/pdf':
                // Will render a preview of the first page of this PDF
                $image = new \Imagick($attachment->getAbsolutePath() . '[0]');
                break;
            default:
                $image = new \Imagick(Plugin::path('Attachments') . '/webroot/img/file.png');
                break;
        }

        $image->setImageFormat('png');
        $image->thumbnailImage(80, 80, true, false);
        $image->setImageCompression(\Imagick::COMPRESSION_JPEG);
        $image->setImageCompressionQuality(75);
        $image->stripImage();

        header('Content-Type: image/' . $image->getImageFormat());
        echo $image;

        $image->destroy();
        exit;
    }