Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typo3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Typo3 使用“sys\u file\u reference”中的裁剪值创建裁剪图像`_Typo3_Typo3 9.x - Fatal编程技术网

Typo3 使用“sys\u file\u reference”中的裁剪值创建裁剪图像`

Typo3 使用“sys\u file\u reference”中的裁剪值创建裁剪图像`,typo3,typo3-9.x,Typo3,Typo3 9.x,我从表sys\u file\u reference中获得了以下裁剪值 {"default":{"cropArea":{"height":0.7157894736842105,"width":1,"x":0,"y":0},"selectedRatio":"1:1","focusArea":null}} 我如何使用这些值来创建裁剪图像(如果您想知道的话,我正在调度程序任务中使用它)?我想GraphicalFunctions->imageMagickConvert()就是我要找的,但我似乎不知道哪个

我从表
sys\u file\u reference
中获得了以下裁剪值

{"default":{"cropArea":{"height":0.7157894736842105,"width":1,"x":0,"y":0},"selectedRatio":"1:1","focusArea":null}}
我如何使用这些值来创建裁剪图像(如果您想知道的话,我正在调度程序任务中使用它)?我想
GraphicalFunctions->imageMagickConvert()
就是我要找的,但我似乎不知道哪个参数去了哪里。

最好使用“ImageService”

有关如何使用它的示例可以在图像ViewHelper中看到,例如uri.Image ViewHelper:\TYPO3\CMS\Fluid\Viewhelpers\uri\ImageViewHelper

简化的示例如下所示:

/**@var\TYPO3\CMS\Core\Resource\FileReference$fileOrFileReference*/
$fileOrFileReference=/*需要是文件或FileReference*/;
$cropString='{…}';
//也可以直接从FileReference获取
//$cropString=$fileOrFileReference->getProperty('crop');
$cropVariantCollection=cropVariantCollection::create($cropString);
$cropArea=$cropVariantCollection->getCropArea('default');//农变
$processingInstructions=[
'crop'=>$cropera->isEmpty()?null:$cropera->makeAbsoluteBasedOnFile($fileOrFileReference)
];
$imageService=$this->objectManager->get(\TYPO3\CMS\Extbase\Service\imageService::class);
$processedFile=$imageService->applyProcessingInstructions(
$fileOrFileReference,
$processingInstructions
);
$cropString
是原始json编码裁剪配置,$fileOrFileReference是一个文件或FileReference(core,而不是extbase)对象,它引用要应用裁剪的文件

注意:如果您有来自sys\u file\u引用表的裁剪字符串,则最好直接使用ResourceFactory获取FileReference对象:

$resourceFactory=$this->objectManager->get(\TYPO3\CMS\Core\Resource\resourceFactory::class);
$fileReference=$resourceFactory->getFileReferenceObject($uid);
然后完成上面的步骤

编辑: 如果您不在如上所示的objectManager可用的上下文中(例如,在extbase控制器中),则可以使用GeneralUtility获取objectManager:

$objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager::class);
最好使用“ImageService”

有关如何使用它的示例可以在图像ViewHelper中看到,例如uri.Image ViewHelper:\TYPO3\CMS\Fluid\Viewhelpers\uri\ImageViewHelper

简化的示例如下所示:

/**@var\TYPO3\CMS\Core\Resource\FileReference$fileOrFileReference*/
$fileOrFileReference=/*需要是文件或FileReference*/;
$cropString='{…}';
//也可以直接从FileReference获取
//$cropString=$fileOrFileReference->getProperty('crop');
$cropVariantCollection=cropVariantCollection::create($cropString);
$cropArea=$cropVariantCollection->getCropArea('default');//农变
$processingInstructions=[
'crop'=>$cropera->isEmpty()?null:$cropera->makeAbsoluteBasedOnFile($fileOrFileReference)
];
$imageService=$this->objectManager->get(\TYPO3\CMS\Extbase\Service\imageService::class);
$processedFile=$imageService->applyProcessingInstructions(
$fileOrFileReference,
$processingInstructions
);
$cropString
是原始json编码裁剪配置,$fileOrFileReference是一个文件或FileReference(core,而不是extbase)对象,它引用要应用裁剪的文件

注意:如果您有来自sys\u file\u引用表的裁剪字符串,则最好直接使用ResourceFactory获取FileReference对象:

$resourceFactory=$this->objectManager->get(\TYPO3\CMS\Core\Resource\resourceFactory::class);
$fileReference=$resourceFactory->getFileReferenceObject($uid);
然后完成上面的步骤

编辑: 如果您不在如上所示的objectManager可用的上下文中(例如,在extbase控制器中),则可以使用GeneralUtility获取objectManager:

$objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager::class);