size of image file
이전 댓글 표시
hi. I want to ask about: how can we get the size of an image file (in Byte/kByte)? Because i want to put it in the edit box/text. thanks.
답변 (2개)
Walter Roberson
2012년 3월 6일
0 개 추천
Use dir() and look at the "size" field that is returned; that will be in bytes.
댓글 수: 4
Ju
2012년 3월 6일
Walter Roberson
2012년 3월 6일
The other options are much worse to write, and are not portable.
fileinfo = dir(ImageFileName);
filesize = fileinfo(1).size;
Ju
2012년 3월 6일
Jan
2012년 3월 6일
@Walter, a small typo: filesize = fileinfo(1).bytes, not ".size".
Jan
2012년 3월 6일
"dir is not defined for 'uint8' input"
This mean that you call DIR with an UINT8 variable like:
a = uint8(rand(10));
b = dir(a);
I assume you read an image file into a variable and use this variable instead of the filename afterwards.
A general recommendation: It is efficient to post the code, which causes the problem, and the complete error message. Then assisting is easier and efficient.
카테고리
도움말 센터 및 File Exchange에서 Environment and Settings에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!