0

I have many .img(disk image) files. they are images and need to be converted to .jpg format. I tried to implement it in Python. it outputs ValueError: embedded null byte What do I missing?

from PIL import Image

rawData  = open('./1990016479_0001.img', 'rb').read()
pil_img = Image.open(rawData)
pil_img.save('./1990016479_0001.jpg', 'JPEG')

Example Image (.img disk image)

https://drive.google.com/file/d/1XYqQJTrbT2Y-4hhrLYKR3kuRIoxufy0o/view?usp=sharing

SKG
  • 21
  • 1
  • 2
  • 1
    Just because there's "image" in the name does not mean they're actual _images_, you know, pictures. What are you trying to do, exactly? What's in those disk images? – Etienne de Martel Jun 16 '21 at 15:05
  • thank you for your response. I am trying to extract image in the disk images. It contains one image file. – SKG Jun 16 '21 at 15:29

1 Answers1

2

Image files are not pictures and as such they cannot be converted to pictures such as .jpg files.

.img refers to binary files with the .img filename extension that store raw disk images of floppy disks, hard drives, and optical discs or a bitmap image – .img. https://en.wikipedia.org/wiki/IMG_(file_format)

To be a little more specific, I believe you are referring to binary disk images, because you specified (.img disk image).

Also, the binary file you linked doesn't look like a bitmap. The linux file utility didn't recognize it and neither did imagemagick.

Joel Peltonen
  • 13,025
  • 6
  • 64
  • 100
  • thank you for your response. I see. If the ```file``` utility cannot recognize it then, is it impossible to extract image in the disk images? – SKG Jun 16 '21 at 15:31
  • @SKG At least I don't know how to mount / open that file, it could be that someone else has some way to open or to get more informatioin about the file but I don't, sorry! – Joel Peltonen Jun 17 '21 at 08:42