在imagejpeg之后导入图像资源

时间:2016-10-27 17:46:04

标签: php fluid typo3-flow

我正在尝试导入一个我通过imagejpeg持久保存的资源......

$imageFileName = "tmp_image_path.jpg"; 
imagejpeg($thumb, $imageFileName); 
$newResource = $this->resourceManager->importResource($imageFileName);
$image = new \TYPO3\Media\Domain\Model\Image($newResource);
$project->setPicture($image);
$this->projectRepository->update($project);
$resourceUri = $this->resourceManager->getPublicPersistentResourceUri($project->getPicture()->getResource());

但要做echo 'Resized: <img src="' .$resourceUri. '"/>';

返回:找不到图像路径

我做错了什么?

1 个答案:

答案 0 :(得分:0)

$newResource = $this->resourceManager->importResource($imageFileName);

这仅按路径导入资源,而不仅使用文件名。 所以

$imageFileName = "tmp_image_path.jpg"; 

应写成:

$imageFileName = "resource://<Package.Name>/Public/tmp_image_path.jpg"; 

请尝试这个,应该使用资源路径