# Downloading Image from Database

**URL:** <https://forum.inductiveautomation.com/t/downloading-image-from-database/79043>\
**Category:** Ignition\
**Created:** [September 12, 2023, 9:02pm UTC](https://forum.inductiveautomation.com/t/downloading-image-from-database/79043 "2023-09-12T21:02:19Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![beckya](https://avatars.discourse-cdn.com/v4/letter/b/b5a626/32.png) [@beckya](https://forum.inductiveautomation.com/u/beckya)\
**Post date:** [September 12, 2023, 9:02pm UTC](https://forum.inductiveautomation.com/t/downloading-image-from-database/79043/1 "2023-09-12T21:02:19Z")

</div>

I am using this script for downloading the image from a database: [Download and Upload Files - Ignition User Manual 8.1 - Ignition Documentation](https://docs.inductiveautomation.com/display/DOC81/Download+and+Upload+Files)

I am able to download it but the type is file and I cannot open it. How do I get it to save as an image that can be viewed on the computer once downloaded?

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/5/752a21796d28ec2efc091856cd8ad6cb700326fd.png)

---

<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:** [September 12, 2023, 9:04pm UTC](https://forum.inductiveautomation.com/t/downloading-image-from-database/79043/2 "2023-09-12T21:04:24Z")

</div>

Try adding a file extension and/or using the `contentType` parameter with `system.perspective.download`.

---

<div class="post-metadata">

**Author:** ![beckya](https://avatars.discourse-cdn.com/v4/letter/b/b5a626/32.png) [@beckya](https://forum.inductiveautomation.com/u/beckya)\
**Post date:** [September 12, 2023, 9:30pm UTC](https://forum.inductiveautomation.com/t/downloading-image-from-database/79043/3 "2023-09-12T21:30:52Z")

</div>

Yes, I attempted this but I don’t know what to put in the contentType, do you know?

---

<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:** [September 12, 2023, 9:36pm UTC](https://forum.inductiveautomation.com/t/downloading-image-from-database/79043/4 "2023-09-12T21:36:59Z")

</div>

Depends on the image type. Try `image/jpeg` or `image/png`.

---

<div class="post-metadata">

**Author:** ![beckya](https://avatars.discourse-cdn.com/v4/letter/b/b5a626/32.png) [@beckya](https://forum.inductiveautomation.com/u/beckya)\
**Post date:** [September 13, 2023, 12:39pm UTC](https://forum.inductiveautomation.com/t/downloading-image-from-database/79043/5 "2023-09-13T12:39:11Z")

</div>

I verified the image is PNG. I added the following but it still downloaded as a file instead of png. I tried single quotes, no quotes and double quotes.

```
system.perspective.download(itemnumber, palletscan,["image/png"])

```

I am referencing this documentation [system.perspective.download - Ignition User Manual 8.1 - Ignition Documentation](https://docs.inductiveautomation.com/display/DOC81/system.perspective.download)

---

<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:** [September 13, 2023, 12:40pm UTC](https://forum.inductiveautomation.com/t/downloading-image-from-database/79043/6 "2023-09-13T12:40:47Z")

</div>

The square brackets used in the manual indicate it's optional, not that you need to pass a list.

Try this:

```python
system.perspective.download(filename=itemnumber, data=palletscan, contentType="image/png")

```

---

<div class="post-metadata">

**Author:** ![bschroeder](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bschroeder/32/13260_2.png) [@bschroeder](https://forum.inductiveautomation.com/u/bschroeder)\
**Post date:** [September 13, 2023, 12:42pm UTC](https://forum.inductiveautomation.com/t/downloading-image-from-database/79043/7 "2023-09-13T12:42:12Z")

</div>

Also, is the itemnumber just a value with no extension? Maybe do what @Kevin.Herron suggested but with a slight tweak:

```auto
system.perspective.download(filename='{}.png'.format(itemnumber), data=palletscan, contentType="image/png")

```

---

<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:** [September 13, 2023, 12:43pm UTC](https://forum.inductiveautomation.com/t/downloading-image-from-database/79043/8 "2023-09-13T12:43:46Z")

</div>

Yeah, still an open question as to whether an extension is necessary. He should definitely try it.
