Generates previews
package |
OCA\Gallery\Service |
---|
__construct(string $appName, \OCA\Gallery\Environment\Environment $environment, \OCP\ILogger $logger)
createPreview(\OCP\Files\File $file, integer $maxX, integer $maxY, boolean $keepAspect = true, boolean $base64Encode = false) : array
Example logger $this->logger->debug( "[PreviewService] Path : {path} / mime: {mimetype} / fileid: {fileid}", [ 'path' => $preview['data']['path'], 'mimetype' => $preview['data']['mimetype'], 'fileid' => $preview['fileid'] ] );
todo |
Get the max size from the settings |
---|---|
Throws |
|
\OCP\Files\File
integer
asked width for the preview
integer
asked height for the preview
boolean
boolean
array
<string,\OC_Image|string>|false preview data
encode(\OC_Image|string $previewData) : string
Using base64_encode for files which are downloaded (cached Thumbnails, SVG, GIFs) and using __toStrings for the previews which are instances of \OC_Image
\OC_Image|string
string
getFile(integer $nodeId) : \OCP\Files\Node
Throws |
|
---|
integer
ID of the resource to locate
\OCP\Files\Node
getNode(integer $nodeId) : \OCP\Files\Node
Throws |
|
---|
integer
ID of the resource to locate
\OCP\Files\Node
isFileReadable(\OCP\Files\File $file) : resource
We can't use something like $node->isReadable() as it's too unreliable Some storage classes just check for the presence of the file
Throws |
|
---|
\OCP\Files\File
resource
isGifAnimated(\OCP\Files\File $file) : boolean
An animated gif contains multiple "frames", with each frame having a header made up of:
We read through the file until we reach the end of the file, or we've found at least 2 frame headers
link |
http://php.net/manual/en/function.imagecreatefromgif.php#104473 |
---|
\OCP\Files\File
boolean
isGifPreviewRequired(\OCP\Files\File $file, boolean $animatedPreview) : boolean
GIFs are downloaded if they're animated and we want to show animations
\OCP\Files\File
boolean
boolean
isMimeSupported(string $mimeType = '*') : boolean
In case of a failure, we just return that the media type is not supported
string
boolean
isPreviewRequired(\OCP\Files\File $file, boolean $animatedPreview) : boolean
\OCP\Files\File
boolean
boolean
isSvgPreviewRequired() : boolean
SVGs are downloaded if the SVG converter is disabled Files of any media type are downloaded if requested by the client
boolean
validateNode(\OCP\Files\Node $node)
Throws |
|
---|
\OCP\Files\Node
previewManager : \OCA\Gallery\Preview\Preview
appName : string
var |
---|
string
environment : \OCA\Gallery\Environment\Environment
logger : \OCP\ILogger
var |
---|
\OCP\ILogger