question

ANNAPAREDDYPranavCORPORATE-5619 avatar image
0 Votes"
ANNAPAREDDYPranavCORPORATE-5619 asked GiftA-MSFT edited

InvalidImageSize error for 9600x7200 size image

Hi, we are a small team trying to extract data from engineering drawings using Python (These diagrams are fairly dense with lines with sparse information). We have encountered an error where the HTTP error code we get for our request is 400 when sending the whole raw image but breaking the image into smaller chunks seems to work.

My question is why does the error prompt for a file of this resolution, which is within the 10000x10000 limit? If it has to do with the file size (storage), I have noticed the same error on a similar resolution image but a smaller size (https://i.redd.it/dp0j5cjx76d51.jpg)

{'code': 'InvalidImageSize',
'requestId': '',
'message': 'The height or width of the image is outside the supported range.'}

Please let me know if the code is required.

azure-computer-vision
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

GiftA-MSFT avatar image
0 Votes"
GiftA-MSFT answered GiftA-MSFT edited

Hi, what API and version are you using? Can you verify using the Analyze Image API v3.2 reference? Using the sample url that you provided, I was able to make a successful request. Regarding file size, ensure that the file size is less than 4MB. If you are using OCR API, image dimensions must be between 50 x 50 and 4200 x 4200 pixels, and the image cannot be larger than 10 megapixels.

92930-image.png
93041-image.png



image.png (6.7 KiB)
image.png (4.9 KiB)
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

To clarify we are trying to use the OCR, not analyze. The error occurs even when we use a file much smaller than 4MB.

The code:

 subscription_key = "KEY"
 endpoint = "ENDPOINT"
 ocr_url = endpoint + "vision/v3.2/ocr"
    
 #image_url = "https://i.redd.it/dp0j5cjx76d51.jpg"
 imgFile = 'reddit.jpg'
 image_path = fr"C:\Scripts\TagVision\{imgFile}"
 image_data = open(image_path, "rb").read()
    
 headers = {'Ocp-Apim-Subscription-Key': subscription_key, 'Content-Type': 'application/octet-stream'}
 response = requests.post(ocr_url, headers=headers, data = image_data)
 analysis = response.json()


0 Votes 0 ·
GiftA-MSFT avatar image GiftA-MSFT ANNAPAREDDYPranavCORPORATE-5619 ·

Please review my updated answer. For OCR API, ensure that your image is between 50 x 50 and 4200 x 4200 pixels, less than 4MB, and less than 10 megapixels. Hope this helps!

0 Votes 0 ·