Hello Tran Minh,
Welcome to the Microsoft Q&A and thank you for posting your questions here.
I understand that you are having "Image file is truncated" error when using Azure Document Intelligence.
The "image file is truncated" error always occur when the image data is incomplete or corrupted however, there should be more information in the response that will indicate the reason the image data is incomplete.
To resolve the error, after you affirm that your code logic read the entire response from the generator object, then you will need to validate by making sure image data you are receiving is valid and complete. For example:
from PIL import Image
from io import BytesIO
image = Image.open(BytesIO(image_data))
image.verify() # This will raise an exception if the image is not valid
Secondly, implement retry mechanism in your code should there be any network issues or temporary service disruptions that can cause incomplete data retrieval.
Also, if you are using azure-storage-blob library to upload the image data, make sure it's upload correctly, the below is a sample code implementation.
from azure.storage.blob import BlobServiceClient
blob_service_client = BlobServiceClient.from_connection_string("your_connection_string")
blob_client = blob_service_client.get_blob_client(container="your_container", blob=f"{fig_fill}.jpg")
blob_client.upload_blob(image_data, overwrite=True)
I hope this is helpful! Do not hesitate to let me know if you have any other questions.
Please don't forget to close up the thread here by upvoting and accept it as an answer if it is helpful.