OK.. came up with the following based on a StackOverflow answer on doing this
in C. Anyone have anything better?:
function imageDataExtension pData
if char 1 to 4 of pData is "GIF8" then
return "gif"
else if byteToNum(char 1 of pData) is 255 and byteToNum(char 2 of pData) is
216 then
return "jpg"
else if byteToNum(char 1 of pData) is 137 and byteToNum(char 2 of pData) is
80 and \
byteToNum(char 1 of pData) is 78 and byteToNum(char 2 of pData) is 71
then
return "png"
else if byteToNum(char 1 of pData) is 46 and byteToNum(char 2 of pData) is
77 then
return "bmp"
else
return "image"
end if
end imageDataExtension
On 23/02/2013, at 7:40 AM, Monte Goulding <[email protected]> wrote:
> Hi
>
> Has anyone got a handler that works out the image type from the text of the
> image. I want to save the text of an image but I want to do so with the
> correct extension. I don't want to use the export command because of the risk
> of some quality loss from the image.
>
> This is for the VCS stuff I'm working on so it would need to have some open
> source license.
>
> Cheers
>
> Monte
> --
> Monte Goulding
>
> M E R Goulding - software development services
> mergExt - There's an external for that!
>
>
>
>
>
> _______________________________________________
> use-livecode mailing list
> [email protected]
> Please visit this url to subscribe, unsubscribe and manage your subscription
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
--
Monte Goulding
M E R Goulding - software development services
mergExt - There's an external for that!
_______________________________________________
use-livecode mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode