I've set up an API where you can upload images. In the event the image is a HEIC
heif = pillow_heif.read_heif(file)
temp = Image.frombytes(
heif.mode,
heif.size,
heif.data,
"raw")
jpeg_file = SpooledTemporaryFile()
temp.save(jpeg_file, format='JPEG')
image = Image.open(jpeg_file)
The images are uploaded to an S3 bucket. Late on an API generates a presigned url for the image and provides it to an HTTP client.
For some reason, whenever it's a HEIF/HEIC image that was uploaded, the client doesn't download any information from the url. If I manually enter the URL in the browser, it downloads correctly and I can open it fine.
I've checked the image.format/format_description/mode of the images, and after the HEIC transformation the HEIC and non-HEIC images have the same values, so I don't think it's there. When looking at the requests the client makes both have the same headers. HOWEVER- Under the network->preview tab in the inspector, I noticed that the non-heic images at the bottom say "size kB | width x height | aspect ratio | binary/octet-stream". The HEIC requests however just say "0 kB ||| binary/octet-stream". It's getting a 200 response though which is adding to my confusion.
Additionally, if I try to download the file directly from the URL and then reupload the generated jpg it still refuses to work, which makes me believe something about my file transformation is going wrong- but I can't see what.
Is there something that I'm missing that is causing the HEIC files to behave differently after my transformation? I'm somewhat overwhelmed trying to figure out if this has to do with the client request to U3 url, if it's how I'm transforming them, if it's something else I'm missing, or what is going on here.
Any advice would be appriciated.