How does JPEG nodule matter in encoding?

I am currently working on a large project that includes photographs. One of the big problems I ran into is the image continent (jpeg to be clearer). I always, although in our modern world we did not have to chat about this subject, but now I'm not sure.

What am I doing:

  • I make an HTTP request to the IP camera, the camera returns an array of bytes to me.
  • I parse this byte in an Image object in .NET using Image.FromStream.
  • I take an Image object and do Save to a physical file on the hard drive.

These images are then used in another module from my application, which uses a third-party "viewer" that performs some manipulation of the image. The viewer works with the entire image created using the computer in Windows XP and Windows Vista. But when an image is created using a Windows 7 machine, all images are mixed up.

Let's say that the image created in Windows XP will be called PictureXP, and the image created using Windows 7 will be called Picture7. I checked the files with exiftools and found that there were two fields between PictureXP and Picture7.

PictureXP: Exif Byte Order: Little-endian Picture7: Exif Byte Order: Big-endian Picture7 also has an additional field: User comment :.

Two pictures can usually be opened in any photo viewer application, only in this third-party view that the image is displayed everywhere, and the only difference between the three images is these fields.

What I want to know:

  • Is it possible that a third party needs to add additional code to their software in order to deal with image content? I assume that the entire image program there works with this?
  • Is it possible for me to change the essence of my jpeg to be always small? I read somewhere that the contents of a jpeg file should always be in the same form, but it seems that it does not take into account exif data. If possible, I would like the solution in .NET ...
  • Anything that can help solve this situation will also be seen as an answer.

Thank you so much!

EDIT 1 : I found this article confirming that the endiannes found in the exif header applies only to the exif header and that the jpeg file is always in big-endian mode. So, is there a way to change the exif header so that third-party software can read what it needs?

+8
c # endianness
source share
2 answers

Ok, so I found my answer by asking a question to Phil, the exiftool author

You can see the stream that I had with him here.

  • Yes it is possible. The third-party SDK did not know that the exif header could be encoded using little-endian or big-endian and was only read using little-endian. The problem with changing my entire picture to obscure.
  • The answer is in 2 parts: firstly, jpeg data is always large, as my editing said. Secondly, the exif header can be either in little-endian or big-endian, and it can be changed using exiftool.

At the command line:

exiftool -all= -tagsfromfile test.jpg -all:all -unsafe -exifbyteorder=little-endian test.jpg

You can also find a tool wrapper in almost any language on this page .

Thank you very much for your interest in the question and the answer I received.

+6
source share

I think maybe the problem is with the user comments field. I read somewhere that Windows Vista (and probably Windows 7) saves the user's comment field as Unicode in byte order, regardless of the byte order of the EXIF ​​information. Since the only difference between PictureXP and Picture7 lies in the content of the exif information and in the user comment field, perhaps you should look like this.

Good luck.

+1
source share

All Articles