How can I convert .img (disk image) to .jpg?

447 views Asked by At

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

1

There are 1 answers

2
Joel Peltonen On

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.