1

I am trying to merge two images and save it as a new asset and I am using the PHP function called "imagecopymerge" (https://www.php.net/manual/en/function.imagecopymerge.php) however thats returning a "resource" and I have tried figuring out how I can turn that "resource" into something I can use to save using perhaps $tempath?

$newAsset = new Asset();
$newAsset->avoidFilenameConflicts = true;
$newAsset->setScenario(Asset::SCENARIO_CREATE);
$newAsset->tempFilePath = $tempPath;
Craft::$app->getElements()->saveElement($newAsset);

1 Answer 1

2

You'll need to save the image to the filesystem and use that path as $tempPath.

https://www.php.net/manual/en/image.examples.merged-watermark.php

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.