Have image - but what type is it?

Klaus Major klaus at major-k.de
Sun Jul 8 09:50:27 EDT 2007


Hi David,

> Is there a way of telling if the contents of an image is a png or  
> jpeg etc?
> Tha is if a stack has an image and you do not know what type of  
> image is
> embedded:
>
> put image id 1234
>>
>
> Result is some data being put into the message box - eg
>
> âPNG

Yes, you can get the header (first 10 bytes/chars) of an image and  
check the content.

...
put char 1 to 10 of img id 1234 into image_type
...


If it is a JPEG file, then "image_type" will contain "JFIF",
"PNG" -> PNG file and
"GIF89" -> GIF file.

Hope that helps.

> IHDR

Regards

Klaus Major
klaus at major-k.de
http://www.major-k.de




More information about the use-livecode mailing list