# Bypassing Overwrite Message

**URL:** <https://forum.inductiveautomation.com/t/bypassing-overwrite-message/12345>\
**Category:** Ignition\
**Created:** [November 10, 2016, 7:22pm UTC](https://forum.inductiveautomation.com/t/bypassing-overwrite-message/12345 "2016-11-10T19:22:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ryanastiefes](https://avatars.discourse-cdn.com/v4/letter/r/47e85d/32.png) [@ryanastiefes](https://forum.inductiveautomation.com/u/ryanastiefes)\
**Post date:** [November 10, 2016, 7:22pm UTC](https://forum.inductiveautomation.com/t/bypassing-overwrite-message/12345/1 "2016-11-10T19:22:07Z")

</div>

My customer has an existing HMI which his IT guy is printing a Screen from the HMI every thirty seconds and saving it to a Cloud server as a .JPG. His end users are than able to view these .JPG’s on a web page without compromising his internets bandwidth. I am in the process of upgrading his HMI to Ignition and am looking at doing pretty much the same thing, but I am stuck. Here’s where I’m at:

I am using a script from a simple pushbutton to test. My script is as followed:

path = “C:\ktwd\Screen1.jpg”  
system.print.printToImage(event.source.parent, path)

Works great, but my end product will be a gateway script happening every thirty seconds, which is where my problem is. If I push this pushbutton again I get the “Overwrite File?” box. I need to overwrite this file automatically without answering this message.

Any thoughts. I have dug through all the scripting functions and cannot find anything that would allow me to delete “C:\ktwd\Sceen1.jpg” than save “C:\ktwd\Sceen1.jpg”

---

<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:** [November 10, 2016, 7:49pm UTC](https://forum.inductiveautomation.com/t/bypassing-overwrite-message/12345/2 "2016-11-10T19:49:27Z")

</div>

This isn’t going to work in a gateway script - there won’t be any screen to print.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [November 10, 2016, 9:47pm UTC](https://forum.inductiveautomation.com/t/bypassing-overwrite-message/12345/3 "2016-11-10T21:47:52Z")

</div>

Ryan,  
You’ll have to use [system.print.createImage](https://docs.inductiveautomation.com/display/DOC79/system.print.createImage) to create a BufferedImage object, then get the binary data from it and use [system.file.writeFile](https://docs.inductiveautomation.com/display/DOC79/system.file.writeFile) to actually save it to disk - since writeFile overwrites by default.

[code]from [java.io](http://java.io) import ByteArrayOutputStream  
from javax.imageio import ImageIO

image = system.print.createImage(event.source.parent.getComponent(‘Chart’))  
baos = ByteArrayOutputStream()  
ImageIO.write(image, “png”, baos)  
baos.flush()  
imageInByte = baos.toByteArray()  
baos.close()

system.file.writeFile(r"C:\Users\pgriffith\Documents\Test.png", imageInByte)  
[/code]

---

<div class="post-metadata">

**Author:** ![ryanastiefes](https://avatars.discourse-cdn.com/v4/letter/r/47e85d/32.png) [@ryanastiefes](https://forum.inductiveautomation.com/u/ryanastiefes)\
**Post date:** [November 11, 2016, 5:13pm UTC](https://forum.inductiveautomation.com/t/bypassing-overwrite-message/12345/4 "2016-11-11T17:13:28Z")

</div>

Where is the BufferedImage stored?
