Google-cloud-ruby: Google::Cloud::InvalidArgumentError: Bad image data.

Created on 4 May 2018  路  4Comments  路  Source: googleapis/google-cloud-ruby

I'm using Google::Cloud::Vision to perform a safe search operation on an image with an external url. I followed the docs for setup:

vision = Google::Cloud::Vision.new(project: project_id)
image = vision.image(url)

When I call image.safe_search, it throws Google::Cloud::InvalidArgumentError: Bad image data.. This is intermittent on some images I give it. This is the one of the problem urls. What is different about this photo that is causing it to throw an exception?

vision question

Most helpful comment

Yes, this was the issue. Thanks!

All 4 comments

Hi @murjax, thanks for the issue. It looks to me like you have a corrupted image file. When I view the image I see a large gray section at the bottom of the image. My assumption here is that that you are getting an invalid argument error because the image data is bad.

bad-image

I have been able to annotate other images using S3 URLs, but not the image URL you provided.

@murjax Does this also seem to you like a problem isolated to this single image? If so, can you close this issue?

Sorry, I meant: isolated to images with bad data.

Yes, this was the issue. Thanks!

Was this page helpful?
0 / 5 - 0 ratings