Inheritance: extends Asset, implements Neos\Media\Domain\Model\ImageInterface, implements Neos\Media\Domain\Model\VariantSupportInterface, use trait DimensionsTrait
 /**
  * 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);
 }
    /**
     * Import resources to asset management
     *
     * This command detects Flow "PersistentResource"s 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
     * PersistentResource.
     *
     * @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'], \Neos\Flow\ResourceManagement\PersistentResource::class);
                if ($resource === null) {
                    $this->outputLine('Warning: PersistentResource 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: PersistentResource 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)
 {
     $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('Neos.Media.Browser:Preview'));
     if ($thumbnail !== null) {
         $imageProperties['previewImageResourceUri'] = $this->thumbnailService->getUriForThumbnail($thumbnail);
         $imageProperties['previewDimensions'] = ['width' => $thumbnail->getWidth(), 'height' => $thumbnail->getHeight()];
     }
     return $imageProperties;
 }