# Use base64 encoded images

**URL:** <https://community.thunkable.com/t/use-base64-encoded-images/35254>\
**Category:** Questions about Thunkable X\
**Created:** [July 11, 2018, 9:51am UTC](https://community.thunkable.com/t/use-base64-encoded-images/35254 "2018-07-11T09:51:22Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![actech](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@actech](https://community.thunkable.com/u/actech)\
**Post date:** [July 17, 2018, 1:57pm UTC](https://community.thunkable.com/t/use-base64-encoded-images/35254/6 "2018-07-17T13:57:52Z")

</div>

You can ask, why should I encode images in base64 format, if I can add many files to the project at once? Because in some cases it’s more convenient to work with base64 - you can quickly update a huge amount of images in the project and get additional information about them (width, height, color depth, type, etc., that you want to add using the script).

Below is a php script that displays in the browser window text in base64 format for all graphics files in the specified (“sourceimages”) directory.

```
<?
$DirPath="sourceimages\\";
$Dir=opendir($DirPath);
$list = array();

while ($File=readdir($Dir)):
	if (is_dir($File)==false)
		{
			$path = $DirPath.$File;
			$data = file_get_contents($path);
			$fileInfo = getimagesize($path);
			$base64 = 'data:'.$fileInfo["mime"].';base64,' . base64_encode($data);
			array_push($list,basename($File)."#".$fileInfo[0]."#".$fileInfo[1]."#".$base64);
		}
endwhile;
echo implode('#', $list);
?>

```

After that, you can copy the base64 text into a text block “base54List” and turn it into a list for further work, as shown below.

![%D0%B8%D0%B7%D0%BE%D0%B1%D1%80%D0%B0%D0%B6%D0%B5%D0%BD%D0%B8%D0%B5](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/3/7/37428a1841862735f1e3a6f2a3194d640a9e7273.png)

---

_[View the full topic](https://community.thunkable.com/t/use-base64-encoded-images/35254)._
