Prima::Image::Exif(3)
π¦ NAME π¦
Prima::Image::Exif β manipulate Exif records π
okay so this is the Prima::Image::Exif(3) page from the User Contributed Perl Documentation, and it's literally here to help you manipulate Exif records. bestie, we love a niche little icon.
β¨ DESCRIPTION β¨
The module lets you parse and create Exif records. The records could be read from JPEG files, and stored in these using the extra appdata hash field. slay β¨
π SYNOPSIS π
like, here's the whole group-chat demo, no cap:
use Prima qw(Image::Exif);
# load image with extras
my $jpeg = Prima::Image->load($ARGV[0], loadExtras => 1);
die $@ unless $jpeg;
my ( $data, $error ) = Prima::Image::Exif->read_extras($jpeg,
load_thumbnail => 1,
tag_as_string => 1
);
if ( $error eq 'XMP data' && defined $data ) {
require XML::LibXML;
my $xml = XML::LibXML->load_xml(string => $data);
for my $node ($xml->findnodes('//*')) {
my @p = $node->childNodes;
next unless @p == 1;
my $p = $node->nodePath;
$p =~ s{\/\b[-\w]+\:}{.}g;
$p =~ s{\.(xmpmeta|rdf)}{}ig;
$p =~ s{^\.}{};
print "$p: $p[0]\n";
}
($data, $error) = ({}, undef);
}
die "cannot read exif: $error\n" if defined $error;
for my $k ( sort keys %$data ) {
my $v = $data->{$k};
if ( $k eq 'thumbnail' ) {
if ( ref($v)) {
print "thumbnail ", $v->width, 'x', $v->height, "\n";
} else {
print "error loading thumbnail: $v\n";
}
next;
}
for my $dir ( @$v ) {
my ( $tag, $name, @data ) = @$dir;
print "$k.$tag $name @data\n";
}
}
# create new image
$jpeg->size(300,300);
# create a thumbnail - not too big as jpeg appdata max length is 64k
my $thumbnail = $jpeg->dup;
delete $thumbnail->{extras};
$thumbnail->size(150,150);
# compile an exif chunk
my $ok;
($ok, $error) = Prima::Image::Exif->write_extras($jpeg,
thumbnail => $thumbnail,
gpsinfo => $data->{gpsinfo},
);
die "cannot create exif data: $error\n" unless $ok;
$jpeg->save('new.jpg') or die $@;
π API π
π parse $CLASS, $EXIF_STRING
Returns two scalars: a data reference and an error. If there is no data reference, the error is fatal; otherwise it's a warning (i.e. assumed some data were parsed, but most probably not all). so yeah, fatal means fatal, bestie π«Ά
The data is a hash where the following keys may be set: image, photo, gpsinfo, thumbnail. These are individual categories containing the exif tags. Each hash value contains an array of tags, except "thumbnail" that contains a raw image data. Each tag is an array in the following format:
[ tag, format, @data ]
where the tag is a numeric tag value, the format is a type descriptor (such as int8 and ascii), and data is 1 or more scalars containing the data.
The module recognized some common tags that can be accessed via %Prima::Image::Exif::tags.
π¦ read_extras $CLASS, $IMAGE, %OPTIONS
Given a loaded Prima image, loads exif data from extras; returns two scalar, a data reference and an error.
Options supported:
load_thumbnailβ if set, tries to load thumbnail as a Prima image. In this case, replaces the thumbnail raw data with the image loaded, or in case of an error, with an error string.tag_as_stringβ if set, replaces known tag numeric values with their string names.
πΈ compile $CLASS, $DATA
Accepts DATA in the format described above, creates an exif string. Returns two scalars, an exif string and an error. If the string is not defined, the error is. that's the whole deal π
π₯ write_extras $CLASS, $IMAGE, %DATA
Checks if image codec is supported, creates Exif data and saves these in "$IMAGE->{extras}". Returns two scalars, a success flag and an error.
π SEE ALSO π
Prima::image-load
The module does not provide comprehensive support for tags and their values. For a more thorough dive see these modules: Image::ExifTool, Image::EXIF.
The module doesn't parse XMP records but warns if get supplied these. The XMP records are easily parsed by any XML parser, f ex XML::LibXML.
π AUTHOR π
Dmitry Karasik, <dmitry@karasik.eu.org>.
that's the whole page, bestie π«Ά β from the User Contributed Perl Documentation, Prima::Image::Exif(3), source/version perl v5.42.0, dated 2024-08-20. mwah πβ¨
π¦ where this page comes from
- opensuse-leap 16.0: perl-Prima 1.74000-bp160.1.13 Β· AGPL-3.0-only AND BSD-2-Clause
- opensuse-leap 16.0: perl-Prima 1.74000-bp160.1.13 Β· AGPL-3.0-only AND BSD-2-Clause
- opensuse-leap 16.0: perl-Prima 1.74000-bp160.1.13 Β· AGPL-3.0-only AND BSD-2-Clause
- opensuse-leap 16.0: perl-Prima 1.74000-bp160.1.13 Β· AGPL-3.0-only AND BSD-2-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms