pillow_heif
pillow_heif copied to clipboard
Created jpg image is skewed diagonally, clearly incorrect
Describe the bug
I put in an heic that I know is not weird.
I run the example code below, and it saves a jpg that looks weird and skewed.
Steps/Code to Reproduce
# main.py
if __name__ == '__main__':
path = "C:\\Users\\whatever\\myimg.heic"
heif_file = pillow_heif.open_heif(path)
image = Image.frombytes(heif_file.mode, heif_file.size, heif_file.data, "raw")
image.save("hi.jpg")
Expected Results

Actual Results

Versions
Windows 10
0.7.0
{'version': {'libheif': '1.13.0', 'x265': 'x265 HEVC encoder (3.4+31-6722fce1f)', 'aom': 'AOMedia Project AV1 Encoder v3.4.0'}, 'decoders': {'HEVC': 1, 'AV1': 1, 'AVC': 0}, 'encoders': {'HEVC': 1, 'AV1': 1, 'AVC': 0}}
Using register_heif_opener instead fixed this problem. Still curious to know why.
You can use to_pillow method or look at it source:
image = Image.frombytes( self.mode, self.size, self.data, "raw", self.mode, self.stride, )
I think stride value will be different from width of image, and that is why such result when you not specified it.
@kevinlinxc
if __name__ == '__main__':
path = "C:\\Users\\whatever\\myimg.heic"
heif_file = pillow_heif.open_heif(path)
image = Image.frombytes(heif_file.mode, heif_file.size, heif_file.data, "raw", heif_file.mode, heif_file.stride)
image.save("hi.jpg")
will be the correct code. if it works, then it is just an invalid use.
This issue did not receive an update in the last 4 weeks. Please take a look again and update the issue with new details, otherwise it will be automatically closed in 2 weeks. Thank you!