When we convert an image to binary data, (let’s say a .png image) is there a way to get the extension back while converting the binary to image again in .net?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Short answer, no. You can’t get the name either. The file name is not generally stored in image data.
If you know what the image format is you can use either a sensible, generally recognised extension or a file extension registered to that file type on your system. Hopefully, these will not differ.
If you don’t know the format perhaps you could read it before serialising to binary and prefix it to the representation.
For a less general answer please expand your question.
EDIT
I guess you could attempt to display the image using a set of potential formats, then visually assess all succesful decodes to choose the correct format. Somehow, it seems easier to just include the original extension in the binary serialization.