# Load PNG Image from disk

**URL:** <https://forums.unrealengine.com/t/load-png-image-from-disk/680334>\
**Category:** C++\
**Tags:** unreal-engine, UE5-0, question, CPP\
**Created:** [October 30, 2022, 6:08pm UTC](https://forums.unrealengine.com/t/load-png-image-from-disk/680334 "2022-10-30T18:08:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![M411](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@M411](https://forums.unrealengine.com/u/M411)\
**Post date:** [October 30, 2022, 6:08pm UTC](https://forums.unrealengine.com/t/load-png-image-from-disk/680334/1 "2022-10-30T18:08:44Z")

</div>

Hello, I’m trying to load a image from a file in the disk and convert it to a UTexture2D but unreal keeps crashing.

I already tried to use LoadObject, but unreal keeps crashing.

Does anyone know a solution?

```auto
FString FullPath = FPlatformProcess::UserDir() + "Game/logos/countries/ad.png"
if(LoadObject<UTexture2D>(NULL, *FullPath)){

}

```

---

<div class="post-metadata">

**Author:** ![3dRaven](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/3draven/32/906552_2.png) [@3dRaven](https://forums.unrealengine.com/u/3dRaven)\
**Post date:** [October 30, 2022, 7:27pm UTC](https://forums.unrealengine.com/t/load-png-image-from-disk/680334/2 "2022-10-30T19:27:07Z")

</div>

I wrote this for my own library not long ago. This should work for you.

```auto

UTexture2D* UImageFunctionLibrary::FileToTexture2d(FString File) {

	FString contentPath = FPaths::ProjectContentDir();
	FString fullContentPath = FPaths::ConvertRelativePathToFull(contentPath);
	FString FullPath = fullContentPath + File;
	UTexture2D* texture = nullptr;
	if (FullPath.Len() > 0) {
		FullPath.ReplaceInline(TEXT("\\"), TEXT("/"), ESearchCase::CaseSensitive);
		FullPath.ReplaceInline(TEXT("//"), TEXT("/"), ESearchCase::CaseSensitive);
		FullPath.RemoveFromStart(TEXT("/"));
		FullPath.RemoveFromEnd(TEXT("/"));
		FPlatformMisc::NormalizePath(FullPath);
		texture = FImageUtils::ImportFileAsTexture2D(FullPath);
	}
	return texture;
}

```

---

<div class="post-metadata">

**Author:** ![M411](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@M411](https://forums.unrealengine.com/u/M411)\
**Post date:** [November 1, 2022, 1:42pm UTC](https://forums.unrealengine.com/t/load-png-image-from-disk/680334/3 "2022-11-01T13:42:35Z")

</div>

This worked.  
Many thanks mate \<3

---

<div class="post-metadata">

**Author:** ![ShadowBr0kerz](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/shadowbr0kerz/32/1201558_2.png) [@ShadowBr0kerz](https://forums.unrealengine.com/u/ShadowBr0kerz)\
**Post date:** [September 2, 2026, 7:41am UTC](https://forums.unrealengine.com/t/load-png-image-from-disk/680334/4 "2026-09-02T07:41:48Z")

</div>

yeah LoadObject wont work for disk file its for cooked uassets only thats why it crashes. you need ImageWrapper route.

quick c++ way:  
FString Path = FPaths::ProjectSavedDir() + TEXT(“logos/ad.png”);  
UTexture2D\* Tex = FImageUtils::ImportFileAsTexture2D(Path);  
if(Tex) MyMesh-\>SetTextureParam…

for bp just use Import File as Texture 2D node without file:// prefix, just normal path. also check file exists before you read it, if its still copying you get empty bytes and crash.

dont do it on game thread for big pngs — decode async or you hitch

btw runtime directory watcher from fab [Runtime Directory Watcher — Hot-Folder File Events & Async Texture Loader | Fab](https://www.fab.com/listings/98c9d662-202c-4e78-aeb7-dbf52e7d6935) worked for me
