[IMGREC-88] JPG image is not recognised by local or amazon Created: 21/Apr/20  Updated: 12/Dec/23

Status: Open
Project: Image Recognition
Component/s: None
Affects Version/s: 1.2
Fix Version/s: None

Type: Bug Priority: Neutral
Reporter: Edwin Guilbert Assignee: Unassigned
Resolution: Unresolved Votes: 3
Labels: maintenance
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Magnolia 6.2


Attachments: JPEG File 396796-boat.jpg     JPEG File OIG.hyZy0z.jpg     Text File exception.txt     PNG File image-2023-12-12-13-29-36-828.png     PNG File image-2023-12-12-13-29-48-286.png    
Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled
Date of First Response:
Team: AuthorX

 Description   

When I try to recognise the following JPG image: with the Run recognition action, I get the following exception:

2020-04-21 11:57:47,414 ERROR nolia.ui.contentapp.browser.ActionExecutionService: An error occurred while executing action [recognize]
info.magnolia.ui.api.action.ActionExecutionException: Action execution failed for action: recognize
...
Caused by: com.machinezoo.noexception.WrappedException: javax.jcr.RepositoryException: Image format is not supported.

Full exception: exception.txt.

This image doesn't work with either local or amazon recognition.



 Comments   
Comment by Marvin Boie [ 12/Dec/23 ]

I also stumbled across it and took a closer look. There java.net.URLConnection#guessContentTypeFromStream is used to recognize the MimeType. This does not seem to work reliably for JPG. ImageInfo and Tika are able to recognize the image.

I set a breakpoint in the image recognition call in java.net.URLConnection#guessContentTypeFromStream and then tried some methods via the IntelliJ debugger to get the MimeType:

I noticed that WEBP images are also not supported and that the method currently used to determine the MimeType returns something completely wrong:

The ImageInfo class which I use here cannot do WEBP either, which is also known under this ticket: https://jira.magnolia-cms.com/browse/MGNLIMG-335 

Edit: Here is the JPG I encountered this bug with:

This image is generated with the Microsoft Bing Image Creator

Edit: I used Magnolia 6.2.40 and image-recognition 1.2.5

Generated at Mon Feb 12 02:09:25 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.