Import image resource after imagejpeg

64 Views Asked by At

I am trying to import a resource which I persisted via 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());

But doing echo 'Resized: <img src="' .$resourceUri. '"/>';

Returns: image path not found

What am I doing wrong?

1

There are 1 best solutions below

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

this imports only resource by path not with filename only. so

$imageFileName = "tmp_image_path.jpg"; 

should be written as :

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

Pls try this, should work with resource path