Convert a PHP image resource to a new Asset 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-&gt;avoidFilenameConflicts = true;
$newAsset-&gt;setScenario(Asset::SCENARIO_CREATE);
$newAsset-&gt;tempFilePath = $tempPath;
Craft::$app-&gt;getElements()-&gt;saveElement($newAsset);
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