/** * Tells the ImageService to render the resource of this ImageVariant according to the existing adjustments. * * @return void */ protected function renderResource() { $processedImageInfo = $this->imageService->processImage($this->originalAsset->getResource(), $this->adjustments->toArray()); $this->resource = $processedImageInfo['resource']; $this->width = $processedImageInfo['width']; $this->height = $processedImageInfo['height']; $this->persistenceManager->whiteListObject($this->resource); }
/** * @param Image $image * @return array */ protected function getImagePreviewData(Image $image) { $imageProperties = ['originalImageResourceUri' => $this->resourceManager->getPublicPersistentResourceUri($image->getResource()), 'originalDimensions' => ['width' => $image->getWidth(), 'height' => $image->getHeight(), 'aspectRatio' => $image->getAspectRatio()], 'mediaType' => $image->getResource()->getMediaType()]; $thumbnail = $this->thumbnailService->getThumbnail($image, $this->thumbnailService->getThumbnailConfigurationForPreset('TYPO3.Neos:Preview')); if ($thumbnail !== null) { $imageProperties['previewImageResourceUri'] = $this->thumbnailService->getUriForThumbnail($thumbnail); $imageProperties['previewDimensions'] = ['width' => $thumbnail->getWidth(), 'height' => $thumbnail->getHeight()]; } return $imageProperties; }
/** * Import resources to asset management * * This command detects Flow "Resource" objects which are not yet available as "Asset" objects and thus don't appear * in the asset management. The type of the imported asset is determined by the file extension provided by the * Resource object. * * @param boolean $simulate If set, this command will only tell what it would do instead of doing it right away * @return void */ public function importResourcesCommand($simulate = false) { $this->initializeConnection(); $sql = ' SELECT r.persistence_object_identifier, r.filename, r.mediatype FROM typo3_flow_resource_resource r LEFT JOIN typo3_media_domain_model_asset a ON a.resource = r.persistence_object_identifier LEFT JOIN typo3_media_domain_model_thumbnail t ON t.resource = r.persistence_object_identifier WHERE a.persistence_object_identifier IS NULL AND t.persistence_object_identifier IS NULL '; $statement = $this->dbalConnection->prepare($sql); $statement->execute(); $resourceInfos = $statement->fetchAll(); if ($resourceInfos === array()) { $this->outputLine('Found no resources which need to be imported.'); $this->quit(); } foreach ($resourceInfos as $resourceInfo) { $mediaType = $resourceInfo['mediatype']; if (substr($mediaType, 0, 6) === 'image/') { $resource = $this->persistenceManager->getObjectByIdentifier($resourceInfo['persistence_object_identifier'], 'TYPO3\\Flow\\Resource\\Resource'); if ($resource === null) { $this->outputLine('Warning: Resource for file "%s" seems to be corrupt. No resource object with identifier %s could be retrieved from the Persistence Manager.', array($resourceInfo['filename'], $resourceInfo['persistence_object_identifier'])); continue; } if (!$resource->getStream()) { $this->outputLine('Warning: Resource for file "%s" seems to be corrupt. The actual data of resource %s could not be found in the resource storage.', array($resourceInfo['filename'], $resourceInfo['persistence_object_identifier'])); continue; } $image = new Image($resource); if ($simulate) { $this->outputLine('Simulate: Adding new image "%s" (%sx%s px)', array($image->getResource()->getFilename(), $image->getWidth(), $image->getHeight())); } else { $this->assetRepository->add($image); $this->outputLine('Adding new image "%s" (%sx%s px)', array($image->getResource()->getFilename(), $image->getWidth(), $image->getHeight())); } } } }
/** * @param Image $image * @return array */ protected function getImagePreviewData(Image $image) { $thumbnail = $image->getThumbnail(600, 600); $imageProperties = array('originalImageResourceUri' => $this->resourceManager->getPublicPersistentResourceUri($image->getResource()), 'previewImageResourceUri' => $this->resourceManager->getPublicPersistentResourceUri($thumbnail->getResource()), 'originalDimensions' => array('width' => $image->getWidth(), 'height' => $image->getHeight(), 'aspectRatio' => $image->getAspectRatio()), 'previewDimensions' => array('width' => $thumbnail->getWidth(), 'height' => $thumbnail->getHeight()), 'mediaType' => $image->getResource()->getMediaType()); return $imageProperties; }