How?
So I can predict and avoid app crashes?
Because doing type(myImage) only tell me that it is userdata.
I could run through all elements in userdata and check if all of them are {r, g, b, a}, but since i'm implementing support for CMYK and HSV colors, it would be too much time invested for just that.
Thanks in advance.
Knowing if userdata is really an image
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Knowing if userdata is really an image
Assuming we're talking about Image objects, does this work?
Code: Select all
if image:typeOf("Image") then
Re: Knowing if userdata is really an image
No.Santos wrote:Assuming we're talking about Image objects, does this work?
Code: Select all
if image:typeOf("Image") then
It is in fact ImageData type of object.
And when doing type() it just returns "userdata".
But I need to know if it really contains data that is image data or not.
- ejmr
- Party member
- Posts: 302
- Joined: Fri Jun 01, 2012 7:45 am
- Location: South Carolina, U.S.A.
- Contact:
Re: Knowing if userdata is really an image
If you want there to be zero doubt about the nature of the data I don't see any other option besides reading the entire file and verifying it, byte-by-byte if you have to. Popular image formats have header metadata you could look at, but if you base the test just on that you're trusting the rest of the data to be uncorrupted.Ubermann wrote:But I need to know if it really contains data that is image data or not.
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 9 guests