# PNG file save (SOLVED)

**URL:** <https://forum.defold.com/t/png-file-save-solved/12005>\
**Category:** Questions\
**Created:** [September 29, 2017, 6:45am UTC](https://forum.defold.com/t/png-file-save-solved/12005 "2017-09-29T06:45:26Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![HG17](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/hg17/32/4757_2.png) [@HG17](https://forum.defold.com/u/HG17)\
**Post date:** [October 11, 2017, 5:43am UTC](https://forum.defold.com/t/png-file-save-solved/12005/6 "2017-10-11T05:43:47Z")

</div>

Thank you for all your help. @britzl!! 😁  
I downloaded png, saved it, and loaded it. But I also have two questions…

- The first is the ‘WARNING: GUI: Failed to create dynamic gui texture (-6)’ issue in gui.new\_texture. I’m developing the action to bring the stored image when I touch it. The first touch will be gui.set\_texture, but it will not work after that.

> WARNING:GUI: Failed to create dynamic gui texture (-6)  
> DEBUG:SCRIPT: ICON NEW TEXTURE ERROR!

```lua
local path = sys.get_save_file("image_speaker", icon .. ".png")
	local f = io.open(path, "rb")
	local s = f:read("*a")
		
	f:close()
	local img = image.load(s)
	
	if gui.new_texture("icon", img.width, img.height, "rgba", img.buffer) then -- error here
		
		gui.set_texture(node, "icon")
		
	else
		print("ICON NEW TEXTURE ERROR!")
	end

```

- The second is about the image type. I downloaded a png file with an alpha value, but the type of the saved png file is rgb. Is there a problem saving the image?

 ![1005601](https://forum-defold-uploads.b-cdn.net/original/2X/e/eff933feda40885a2d9b583f1d7264cadd3b9853.jpg)  
(my image)  
 ![image](https://forum-defold-uploads.b-cdn.net/original/2X/d/d78177fff10a48d703d9eea09bbaa649e4c9a5e4.jpg)  
(in game image)

This is a image save code.

```lua
http.request(URL .. "images/speaker/" .. speaker_data[i].name .. ".png", "GET", function(self, _, response) 
				
		if response.status >= 200 or response.status < 300 then
					
			local path = sys.get_save_file("image_speaker", speaker_data[i].name .. ".png")
			local f = assert(io.open(path, "wb"))
					
			f:write(response.response)
			f:flush()
			f:close()
					
			self.currentdownload = self.currentdownload + 1
			print(self.currentdownload)
					
		end
	end, headers)

```

---

_[View the full topic](https://forum.defold.com/t/png-file-save-solved/12005)._
