pillow_heif icon indicating copy to clipboard operation
pillow_heif copied to clipboard

Created jpg image is skewed diagonally, clearly incorrect

Open kevinlinxc opened this issue 3 years ago • 3 comments
trafficstars

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

image

Actual Results

image

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}}

kevinlinxc avatar Sep 30 '22 21:09 kevinlinxc

Using register_heif_opener instead fixed this problem. Still curious to know why.

kevinlinxc avatar Sep 30 '22 21:09 kevinlinxc

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.

bigcat88 avatar Sep 30 '22 23:09 bigcat88

@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.

bigcat88 avatar Oct 02 '22 00:10 bigcat88

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!

github-actions[bot] avatar Nov 27 '22 10:11 github-actions[bot]