0

my JPEG file have been encrypted first 153605 bytes and it don't have header. But I need to get image dimension to repair this file. Does anyone know how to get it, such as get it from raw data?

  • Yes, you can read the raw data if you understand the file schema, but without the header you are missing a lot of information, so it's going to take you a lot of trial and error and visual user input to understand the bytes and produce a usable image. You can find the latest JPEG specification here: https://www.iso.org/standard/54989.html or using your favourite search engine you can likely find snippets of the standard or relevant parts of the file schema that will be enough for what you need to read in the bytes. – sorifiend Jun 13 '22 at 04:55
  • For example, take a look here for some of the markers you can look for in the file: https://docs.fileformat.com/image/jpeg/ also see here https://stackoverflow.com/questions/4550296/how-to-identify-contents-of-a-byte-is-a-jpeg – sorifiend Jun 13 '22 at 04:56
  • @sorifiend Thank for your helping, but I only need to get width and height of the image file. Then I can easily take the jpeg back by create new header. But as I said, how about if we can get the dimension from raw data or MCU ? I have read a lot of documentation but nothing can help me. – Bảo Hoàng Jun 13 '22 at 05:28
  • It's a very hard thing to do. If you are missing the header then you can't get the width and height without first attempting to read the whole file to extract the image data, find the valid contents then reconstruct the image with trial and error and visual input. One option if you are sure that the image itself is fine, and you have a similar image from the same soure that is not broken (same camera etc), then you can copy the header from one image to the other. See this post for a specification: https://stackoverflow.com/a/12350815 – sorifiend Jun 13 '22 at 06:07
  • Oh, if the file is encrypted then ignore all my comments above, that will only work if you have a regular encoded JPEG with a missing header. For an encrypted file, there is nothing you can do other than first decrypting it. – sorifiend Jun 13 '22 at 06:23

0 Answers0