How can I retrieve the data from the UTG_Texture node in TextureGraph and save it as a PNG file?

I use FinalizeBlob to retrieve the image data and then export it as a PNG file. These are part of my code,

I think I used the wrong method to retrieve the texture data. So, how can I safely and reliably retrieve the data from the UTG_Texture node and save it as a PNG file?

If needed, I can provide the complete Gaea node code.

`void UTG_Expression_Gaea::Evaluate(FTG_EvaluationContext* InContext)
{
Super::Evaluate(InContext);

TArray<FName> Keys;
InContext->Inputs.VarArguments.GetKeys(Keys);
InputVars.Empty();

for (FName Key : Keys)
{
    FTG_Var* Var = InContext->Inputs.GetVar(Key);
    const FTG_Argument* VarArgument = InContext->Inputs.GetVarArgument(Key);

    if (VarArgument->IsTexture())
    {
        FString FilePath;
        if (Var && !Var->IsEmpty())
        {
            FTG_Texture& ParamValue = Var->EditAs<FTG_Texture>();
            FilePath = TEXT("\"") + GetNodeInputTexture(Key.ToString(), ParamValue) + TEXT("\"");  // Export the input texture as a PNG file and return the file path.
        }
        else
        {
            //...
        }
        InputVars.Add(Key.ToString(), FilePath);
    }
}

//...

}

AsyncBool UTG_Expression_Gaea::FinalizeBlob(BlobPtr TargetBlob)
{
auto TiledOutput = std::static_pointer_cast(TargetBlob);
return TiledOutput->OnFinalise().then([=]
{
return true;
});
}

FString UTG_Expression_Gaea::GetNodeInputTexture(FString MaskName,FTG_Texture InputTexture)
{
if (!InputTexture.RasterBlob)
{
UE_LOG(LogTemp, Warning, TEXT("Invalid RasterBlob! "));
return FString();
}

FString LevelName = FPaths::GetBaseFilename(GWorld->GetCurrentLevel()->GetFullName());
FString TexturePath = FPaths::ConvertRelativePathToFull(FPaths::Combine(FPaths::AutomationTransientDir(), LevelName));

FinalizeBlob(InputTexture.RasterBlob)
.then([this,InputTexture]() {
    if (InputTexture->GetTiles()[0][0] == NULL)
        return cti::make_ready_continuable(0);
    InputTexture->CombineTiles(false, false);
    return cti::make_ready_continuable(1);
})
.then([this,InputTexture]() {
    DeviceBufferRef Buffer = InputTexture->GetBufferRef();
    if (Buffer->IsNull())
        return this->GetNullBufferPtr();// cti::make_ready_continuable(0);
    return Buffer->Raw();
})
.then([this, TexturePath, MaskName](RawBufferPtr RawObj) {
    if (!RawObj || RawObj->GetData() == nullptr)
    {
        UE_LOG(LogTexture, Warning, TEXT("Can't export with invalid RawBuffer: %s"), *(RawObj->GetName()));
        return;
    }
    
    //ExportTexture2D...
    
});
return FPaths::Combine(TexturePath, MaskName + TEXT(".png"));

}`

Steps to Reproduce
I’ve created a Gaea node within TextureGraph in Unreal Engine. This node saves the input image as a PNG file locally and then calls Gaea through the command line. After Gaea finishes processing, the result is also saved as a PNG locally, and I read the processed image back into Unreal for display.

[Image Removed]

Additionally, I have implemented a custom Blueprint node in C++ to render the RenderTargets generated by TextureGraph.

[Image Removed]

However, I’m encountering an occasional crash. After investigating for several days, I’ve identified the main issue to be related to saving the input image as a PNG. The issue may arise from a conflict between reading the image resource via FinalizeBlob and the engine’s read/write operations.

Hello,

Thank you for reaching out to us!

We have escalated your query to the relevant department.

Please allow us some time to get back to you!

Is there any progress on the issue?