You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Marcono1234 (Jira)" <ji...@apache.org> on 2023/10/13 01:36:00 UTC

[jira] [Updated] (IMAGING-366) Publicly expose Util.getImageParser / Allow easily getting ImageParser for ImageFormat

     [ https://issues.apache.org/jira/browse/IMAGING-366?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Marcono1234 updated IMAGING-366:
--------------------------------
    Summary: Publicly expose Util.getImageParser / Allow easily getting ImageParser for ImageFormat  (was: Publicly expose Util.getImageParser)

> Publicly expose Util.getImageParser / Allow easily getting ImageParser for ImageFormat
> --------------------------------------------------------------------------------------
>
>                 Key: IMAGING-366
>                 URL: https://issues.apache.org/jira/browse/IMAGING-366
>             Project: Commons Imaging
>          Issue Type: Improvement
>    Affects Versions: 1.0-alpha3
>            Reporter: Marcono1234
>            Priority: Minor
>
> h3. Suggestion
> The internal class {{org.apache.commons.imaging.internal.Util}} contains the method {{getImageParser}} for obtaining a parser from binary data of unknown format.
> What do you think about exposing some variant of this {{getImageParser}} method publicly, for example in the {{Imaging}} class?
> Or in general making it easier to obtain for unknown binary data first the {{ImageFormat}} and then based on that the {{ImageParser}}?
> h3. Use case
> A situation where this can be useful is if you have binary data of an image of unknown format, and you want to obtain metadata from it (therefore having to use {{ImageParser}}). But you only want to support certain image formats such as JPEG and PNG, and not all image formats Commons Imaging supports.
> In that case having first the {{ImageParser}} would allow you to check its type (e.g. if it is {{PngImageParser}}) before calling any of its methods.
> h3. Workaround
> A workaround might be to first use {{Imaging.guessFormat}}, then check if you want to support the format, and afterwards call one of the other {{Imaging}} methods which internally delegate to {{ImageParser}}, such as {{Imaging.getMetadata}}.
> However, this feels a bit brittle because you have to make two separate calls to {{Imaging}}, and have to trust that the second call determines the format in the same way {{guessFormat}} does (which should probably be always the case).



--
This message was sent by Atlassian Jira
(v8.20.10#820010)