How to render a UE asset thumbnail in a non-UE application

I got the following from a colleague. I have not used it myself, but it comes from a reliable source.
I hope it will help you.

This method will save a UTexture2D as a PNG in the content directory as “MyImage.png”. If you go into HighResScreenshotConfig.SaveImage you can see its using FImageWriter and FArchive to get the job done.

void SaveTexture2D(UTexture2D* PTexture) {
PTexture->UpdateResource();
FTexture2DMipMap* MM = &PTexture->PlatformData->Mips[0];

TArray<FColor> OutBMP;
int sz = MM->SizeX * MM->SizeY;
OutBMP.AddUninitialized(sz);
FColor* FormatedImageData = static_cast<FColor*>(MM->BulkData.Lock(LOCK_READ_ONLY));
FMemory::Memcpy(OutBMP.GetData(), FormatedImageData, sz * sizeof(FColor));
MM->BulkData.Unlock();

// SaveImage knows how to save the bitmap as PNG - saves to disk file
FHighResScreenshotConfig& HighResScreenshotConfig = GetHighResScreenshotConfig();
HighResScreenshotConfig.SetHDRCapture(false);
FString filename = FPaths::Combine(*FPaths::ProjectContentDir(), TEXT("MyImage.png"));
bool bSaved = HighResScreenshotConfig.SaveImage(filename, OutBMP, FIntPoint(MM->SizeX, MM->SizeY));
}