# Export Images Using Scripting

**URL:** <https://forum.inductiveautomation.com/t/export-images-using-scripting/46533>\
**Category:** Ignition\
**Created:** [May 10, 2021, 1:55pm UTC](https://forum.inductiveautomation.com/t/export-images-using-scripting/46533 "2021-05-10T13:55:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![meredithj](https://avatars.discourse-cdn.com/v4/letter/m/cc9497/32.png) [@meredithj](https://forum.inductiveautomation.com/u/meredithj)\
**Post date:** [May 10, 2021, 1:55pm UTC](https://forum.inductiveautomation.com/t/export-images-using-scripting/46533/1 "2021-05-10T13:55:59Z")

</div>

I have been using some of the javadocs that ignition provides to add more functionality to my ignition projects such as importing and exporting images on the client side. I currently have the importing of images working fine but I am stuck trying to get images to export correctly from the client side.

How I am currently doing this is using a gateway message in order for me to grab Igniton gateway context. Once I grab context I get the image manager and use the getImage method to get the image. This then returns me a ImageRecord object that I have to go and grab the BlobData, width, height, etc. from.

From there I know that I have to extract the value from the TypeField object types that Ignition has. This is where it is giving me an issue. No matter how I try to extract this data, it always gives me either a value / type of None or it gives me an array(‘b’) in the case of the BlobField type. I have tried a bunch of different ways to try to get this working using variables and methods that these

My code is as follows. Please let me know what I am missing in order to extract the images from the internal database.

```auto
	from com.inductiveautomation.ignition.gateway import IgnitionGateway
	from com.inductiveautomation.ignition.gateway.images import ImageRecord
	from com.inductiveautomation.ignition.gateway.localdb.persistence import StringField
	from com.inductiveautomation.ignition.gateway.localdb.persistence import IntField
	from com.inductiveautomation.ignition.gateway.images import ImageFormat

	context = IgnitionGateway.get()
	image = context.getImageManager()
		
	imageData = image.getImage(payload['path'])
	system.util.getLogger("get_Image log").infof("after getImage function: %s", str(imageData))
	data= imageData.Data
	default = imageData.Data.getDefault()
	system.util.getLogger("get_Image log").infof("after getImage function: %s", str(data))
	system.util.getLogger("get_Image log").infof("after getImage function: %s", str(type(data)))

	system.util.getLogger("get_Image log").infof("after getImage function: %s", str(default))
	system.util.getLogger("get_Image log").infof("after getImage function: %s", str(type(default)))

	test = {"data":default,
			'description':'',
			'height':'',
			'path':'',
			'width':''}

```

The logs that go with this script. (oldest logs first)

```auto
after getImage function: [ImageRecord folsom.png]
after getImage function: [F ImageRecord.Width]
after getImage function: <type 'com.inductiveautomation.ignition.gateway.localdb.persistence.IntField'>
after getImage function: None
after getImage function: <type 'NoneType'>

```

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [May 10, 2021, 2:06pm UTC](https://forum.inductiveautomation.com/t/export-images-using-scripting/46533/2 "2021-05-10T14:06:47Z")

</div>

I think you want to do something like this:

```auto
imageBytes = imageData.getBytes(ImageRecord.Data)

```

This should give you a byte array, which it sounds like in one attempt you already had (array(‘b’)), which is the only thing I can imagine you’d want.

---

<div class="post-metadata">

**Author:** ![meredithj](https://avatars.discourse-cdn.com/v4/letter/m/cc9497/32.png) [@meredithj](https://forum.inductiveautomation.com/u/meredithj)\
**Post date:** [May 10, 2021, 7:36pm UTC](https://forum.inductiveautomation.com/t/export-images-using-scripting/46533/3 "2021-05-10T19:36:55Z")

</div>

That was the fix. Thank you.
