Packages
PNGObject

PNGObject

The PNG Object enables a developer to write Roblox's flat RGBA array into a PNG file format, allowing developers to export the contents of EditableImage:ReadPixels, which could come in handy for things such as Plugins.

Most of the work is done upon creating this class, essentially all you have to do as a dev is call :ToString to get the binary blob, the image itself.

TL;DR, this is a PNG encoder.

ℹ️

Any PNG file created through this encoder will export an image w/o compression, true color with alpha.


I do want to credit the following people for both a resource and reference for this impl;

Properties

Methods

ToString

PNGObject:ToString() -> string (opens in a new tab)

Returns the binary blob for the PNG file, this is essentially the content you'd find under a object.png file.


Functions

new

PNGObject.new( size Vector2 (opens in a new tab), rgba { [number]: number } ) -> PNGObject

Constructor function that creates a new PNG file, when this function is called, the binary data for the RGBA array will be generated alongside this call.

	local pixels = EditableImage:ReadPixels()
	local pngObject = RGBA.PNG.new(EditableImage.Size, pixels)
 
	HttpService:PostAsync("https://some-image-uploading-site/upload", pngObject:ToString())