Jeff Higgins said:
Vikram said:
I have the binary representation of an image ( byte[] ). Can I
get the content type in the form "image/xxx" from it ?
It's not clear to me what you are asking. I can think of
several interpretations of your question. So for now the
short answer has to be; yes, and the long answer; no.
I think it's quite clear, that the OP wants the mime-type
for an image that is stored in a byte-array.
On linux (or other systems with GNU-file installed), he could
feed the byte-array as input to the system command "file -bi -"
and read back the result.
Probably there exist easier or more platform-neural ways to
do it, but I don't know them, either.
Anyway, there is no 100% sure way of knowing. Type-recognition
by content is somewhat safer than by filename-extension, but
still has it's error-cases. (mostly false positives, where a
filetype is detected, for which the byte-array doesn't contain
legal data)