Re: get the width and height of an image file .png
Posted: Sun Jul 08, 2012 5:30 pm
Hi Klaus,
Yes. It is very useful to scale file .png in a constant rect
I have done a little function using the code of Richard:
Best
Jean-Marc
Yes. It is very useful to scale file .png in a constant rect
I have done a little function using the code of Richard:
Code: Select all
function GetWidthHeightPngFile pPathIm --
put empty into rGetWidthHeightPngFile
open file pPathIm for binary read
read from file pPathIm for 24
put it into tData
close file pPathIm
--
if byte 13 to 16 of tData <> "IHDR" then -- "Invalid PNG format"
return empty
exit GetWidthHeightPngFile
end if
--
local tWidth, tHeight
put binaryDecode("MM", byte 17 to 24 of tData, tWidth, tHeight)\
into tNumConvertedVals
if tNumConvertedVals <> 2 then -- Couldn't decode binary data
return empty
exit GetWidthHeightPngFile
end if
put tWidth & "," & tHeight into rGetWidthHeightPngFile
return rGetWidthHeightPngFile
end GetWidthHeightPngFileJean-Marc