You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@tika.apache.org by Peter Maier <ac...@gmail.com> on 2022/06/02 19:02:18 UTC

Fwd: image/jpx recognition in java code

Hello

I somehow doesn't get my java application to recognise the mimetype
"image/jpx", it always gets recognised as "image/jpm" by Tika.

Simple Code:

final InputStream resourceAsStream1 =
ClassLoaderUtils.getResourceAsStream("jpx.jpf", Tika.class);
final BodyContentHandler handler = new BodyContentHandler();
final Metadata metadata = new Metadata();
final AutoDetectParser autoDetectParser = new AutoDetectParser();
try {
    autoDetectParser.parse(resourceAsStream1, handler, metadata);
} catch (IOException | TikaException | SAXException e) {
    throw new RuntimeException(e);
}

metadata:
X-TIKA: Parsed-By: EmptyParser
X-TIKA: Parsed-By-Full-Set: EmptyParser
Content-Type: image/jpm

Only dependency:

<dependency>
    <groupId>org.apache.tika</groupId>
    <artifactId>tika-core</artifactId>
    <version>2.4.0</version>
</dependency>


I've thrown the same file against "tika-app-2.4.0.jar" and they both give
the correct Content-Type.
Content-Type: image/jpx
X-TIKA:Parsed-By: org.apache.tika.parser.EmptyParser
X-TIKA:Parsed-By-Full-Set: org.apache.tika.parser.EmptyParser
resourceName: jpx.jpf

Are there some parsers that I need to configure additionally, so that the
correct Mimetype is recognised in my code?

Regards
Peter

Re: Fwd: image/jpx recognition in java code

Posted by Peter Maier <ac...@gmail.com>.
Thanks, with that addition it recognizes the file.

Am Fr., 3. Juni 2022 um 23:37 Uhr schrieb Tim Allison <ta...@apache.org>:

> Should have looked at your code more closely earlier.  The difference btwn
> the app and your code is that the app adds the filename to the metadata
> object.  The detector does byte detection and then sees if the file
> extension can help refine the file type further.
>
> Add this to your metadata object before the detection and you should be
> good:
>
> metadata.set(TikaCoreProperties.RESOURCE_NAME_KEY, path.getFileName().toString());
>
>
> On Fri, Jun 3, 2022 at 5:22 PM Peter Maier <ac...@gmail.com> wrote:
>
>> I mean yes, they are hard to distinguish, but somehow the
>> "tika-app-2.4.0.jar" is able to do so, therefore I'm questioning if there
>> is something that it does different to what I try.
>>
>> Am Fr., 3. Juni 2022 um 10:27 Uhr schrieb Tilman Hausherr <
>> THausherr@t-online.de>:
>>
>>> Tricky
>>>
>>> https://www.iana.org/assignments/media-types/image/jpx
>>>
>>> https://www.iana.org/assignments/media-types/image/jpm
>>>
>>>

Re: Fwd: image/jpx recognition in java code

Posted by Tim Allison <ta...@apache.org>.
Should have looked at your code more closely earlier.  The difference btwn
the app and your code is that the app adds the filename to the metadata
object.  The detector does byte detection and then sees if the file
extension can help refine the file type further.

Add this to your metadata object before the detection and you should be
good:

metadata.set(TikaCoreProperties.RESOURCE_NAME_KEY,
path.getFileName().toString());


On Fri, Jun 3, 2022 at 5:22 PM Peter Maier <ac...@gmail.com> wrote:

> I mean yes, they are hard to distinguish, but somehow the
> "tika-app-2.4.0.jar" is able to do so, therefore I'm questioning if there
> is something that it does different to what I try.
>
> Am Fr., 3. Juni 2022 um 10:27 Uhr schrieb Tilman Hausherr <
> THausherr@t-online.de>:
>
>> Tricky
>>
>> https://www.iana.org/assignments/media-types/image/jpx
>>
>> https://www.iana.org/assignments/media-types/image/jpm
>>
>>

Re: Fwd: image/jpx recognition in java code

Posted by Peter Maier <ac...@gmail.com>.
I mean yes, they are hard to distinguish, but somehow the
"tika-app-2.4.0.jar" is able to do so, therefore I'm questioning if there
is something that it does different to what I try.

Am Fr., 3. Juni 2022 um 10:27 Uhr schrieb Tilman Hausherr <
THausherr@t-online.de>:

> Tricky
>
> https://www.iana.org/assignments/media-types/image/jpx
>
> https://www.iana.org/assignments/media-types/image/jpm
>
>

Re: Fwd: image/jpx recognition in java code

Posted by Tilman Hausherr <TH...@t-online.de>.
Tricky

https://www.iana.org/assignments/media-types/image/jpx

https://www.iana.org/assignments/media-types/image/jpm