10up / classifai

Supercharge WordPress Content Workflows and Engagement with Artificial Intelligence.
https://classifaiplugin.com
GNU General Public License v2.0
559 stars 52 forks source link

fix/708: fixes issue with processing `.png` images with large file sizes. #754

Closed Sidsector9 closed 3 months ago

Sidsector9 commented 3 months ago

Description of the Change

This PR:

Closes #708

How to test the Change

This can be tested with the following sample images:

5mb-png-image 10mb-png-image

Changelog Entry

Added - filter hook 'classifai_ms_computer_vision_scan_image_timeout' to increase image processing timeout. Fixed - timeout issue with processing .png images of large file sizes.

Credits

Props @QAharshalkadu @Sidsector9

Checklist:

Sidsector9 commented 3 months ago

According to the API docs, the max image supported is 4MB. We have some code in place to return an error if the image size is larger than that so in theory, a 5MB image shouldn't even work, though it sounds like that's not the case.

@dkotter what you're saying is correct and the check we have is working as expected. When we upload an image size > 4MB, the check selects the largest image variant that is < 4MB to process.

This particular issue is a weird one pertaining to just the .png format. From what I am understanding, the AI service takes more time to process a .png compared to a .jpeg. So, even with a .png file which has a size of 3.5MB, it still fails.

This works well when the timeout is increased.