Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!
put specialfolderpath("home") & "/Pictures/plane.jpg" into tImagefile // 446,502 bytes in finder get info panel
set the filename of img "holder" to tImagefile // put the image into temp placeholder
put the imagedata of image "holder" into tData
put the number of bytes of tData into field "test" // shows 2124036 why..?????
As you can see i would have expected the total bytes output to field "test" to be 446,502
I dont think counting the bytes on screen will tell you the actual filesize!
But you can get the real filesize with Livecode, check (long or detailed) "files" in the dictionary for more info.
Here is a function of mine that I use to get the filesize of any given file on disk:
tFilepath = abolute pathname of the file
function fFileSize tFilePath
set itemdel to "/"
put item -1 of tFilePath into tFile
delete item -1 of tFilePath
put the folder into OldDir
set folder to tFilePath
## Checking the LONG files is the trick!
put the long files into tLF
## the actual filename is URLENCODED in "the long files"
put line(lineoffset(urlencode(tFile),tLF)) of tLF into tLine
set itemdel to ","
set folder to OldDir
## ITEM 2 in that line is the filesize in BYTES
return item 2 of tLine
end fFileSize
you look at the filsize in the finder for a jpeg image. Jpeg images are most of the time compressed. If you check the size of the imageData you have the uncompressed size of the image.
Also imageData is not all there is sizewise. It is only a representation of the pixel, i.e. 4 bytes per pixel. Additionally you have alphaData and maskData.
To see the size of the image when expanded in liveCode you could put
put image "xyz" into tTotalImage /or/ put the text of image "xyz" into tTotalImage
put length of tTotalImage
That would have been neater for the code i presented.
But i was only really expanding the image in LC to get the size.
Now with Klaus solution i don't ever need to expand the image. I can just get the size, and move on (looping).
Your solution provides another little wrinkle in my brain though.. cheers