I can't figure out if Pillow supports RGBA4444 as a pixel format. I have image data packed in this format which I need to convert to png.
The bmp test suite has a ./Tests/images/bmp/q/rgba16-4444.bmp file but I haven't found where that decoding is done.
If we have it, it would be listed in unpack.c somewhere.
If it is there, then you could use image.frombytes with the appropriate raw mode to read it into an image.
Using RBGA;4B this is what I get:

And this is (roughly) what I should be getting:

Why is it roughly what you should be getting? Is the second image the original file, which you've read in and saved in a different format to generate the first image?
The second image is an approximation of the expected output I got by resizing a different file.
The raw image data is extracted from Unity assets. Unity saved the 32x32 version as RGBA4444 and the 64x64 version as RGBA32.
Can you post the original somewhere?
Here's various pixel formats from unity:
https://leclan.ch/public/file-formats/
The RGBA4444 ones are the problematic ones.
This is raw image data of course.
It's an endian issue, somewhere. Reversing the bands gives a decent image.
with open('RGBA4444.raw', 'rb') as f:
im = Image.frombytes('RGBA', (16,16), f.read(), 'raw', 'RGBA;4B', 0, -1)
im = Image.merge('RGBA', im.split()[::-1])
im.show()
I'm seeing the bytes in the test file like this: (this is pixels 4-8, since the alpha on them is F).
1F 96 1F 96 2F 97 2F 85
I'm seeing alpha in the second position, so the file looks to be written BA RG
After reversing the bands as above, I'm seeing this for the same pixels when writing out:
99 66 11 FF 99 66 11 FF 99 77 22 FF 88 55 22 FF
So, I'm going to say that it's a little endian RGBA;4B file, not the bigendian file that one would expect from the format description.
Ok, will test it soon. I also have an ARGB4444 file, I believe that pixel format is not implemented in pillow.
Any 4444 file will be usable by switching the bands returned from the RGBA;4B unpacker.
Most helpful comment
It's an endian issue, somewhere. Reversing the bands gives a decent image.
I'm seeing the bytes in the test file like this: (this is pixels 4-8, since the alpha on them is F).
I'm seeing alpha in the second position, so the file looks to be written BA RG
After reversing the bands as above, I'm seeing this for the same pixels when writing out:
So, I'm going to say that it's a little endian RGBA;4B file, not the bigendian file that one would expect from the format description.