NAME

EBook::Ishmael::ImageID - Identify image data format

SYNOPSIS

use EBook::Ishmael::ImageID;

my $format = image_id($img);

DESCRIPTION

EBook::Ishmael::ImageID is a module that provides the image_id() subroutine, which identifies the image format of a given buffer. This is developer documentation, for ishmael user documentation you should consult its manual.

Currently, the following formats are supported:

jpg
png
gif
webp
bmp
tif
svg
avif
jxl

SUBROUTINES

$f = image_id($img)

Returns a string of the image format of the given image buffer. Returns undef if the image's format could not be identified.

[$x, $y] = image_size($img, [$fmt])

Returns an $x/$y pair representing the image data's size. $fmt is an optional argument specifying the format to use for the image data. If not specified, image_size will identify the format itself. If the image size could not be determined, returns undef.

This subroutine does not support the following formats (yet):

webp
tif
avif
jxl
$bool = is_image_path($path)

Returns true if $path looks like an image path name.

$f = mimetype_id(($mime)

Identifies the image format based on the given mimetype. Returns undef if $mime is not recognized.

$f = image_path_id($path)

Identifies the image format based on the given file path based on its suffix. Returns undef if the file's format cannot be recognized.

AUTHOR

Written by Samuel Young, <samyoung12788@gmail.com>.

This project's source can be found on its Codeberg Page. Comments and pull requests are welcome!

COPYRIGHT

Copyright (C) 2025-2026 Samuel Young

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.