App-CopyrightImage
view release on metacpan or search on metacpan
lib/App/CopyrightImage.pm view on Meta::CPAN
if (! $data->{force} && ($cp || $cr)){
my $set = "Copyright is already set;" if $cp;
$set .= " Creator is already set;" if $cr;
$errors{$img} = $set;
next;
}
$et->SetNewValue('Copyright', "Copyright (C) $data->{year} by $data->{name}");
my $creator_string = $data->{name};
$creator_string .= " ($data->{email})" if $data->{email};
$et->SetNewValue('Creator', $creator_string);
my $ci_img = (fileparse($img))[0];
$ci_img = "$dst/ci_$ci_img";
# write out the new image
$et->WriteInfo($img, $ci_img);
# updated
$et->ExtractInfo($ci_img);
$errors{$img} = "failed to add Copyright; "
if ! $et->GetValue('Copyright');
$errors{$img} .= "failed to add Creator"
if ! $et->GetValue('Creator');
}
return %errors;
}
sub _check {
my $data = shift;
my $et = Image::ExifTool->new;
for (@{ $data->{images} }){
$et->ExtractInfo($_);
my $cp = $et->GetValue('Copyright');
my $cr = $et->GetValue('Creator');
my $err_str;
$err_str .= " missing Copyright; " if ! $cp;
$err_str .= " missing Creator; " if ! $cr;
print "$_: $err_str\n" if $err_str;
}
return ();
}
1;
__END__
=head1 NAME
App::CopyrightImage - Easily add Copyright information to your images
=for html
<a href="http://travis-ci.org/stevieb9/p5-app-copyrightimage"><img src="https://secure.travis-ci.org/stevieb9/p5-app-copyrightimage.png"/></a>
<a href="https://ci.appveyor.com/project/stevieb9/p5-app-copyrightimage"><img src="https://ci.appveyor.com/api/projects/status/br01o72b3if3plsw/branch/master?svg=true"/></a>
<a href='https://coveralls.io/github/stevieb9/p5-app-copyrightimage?branch=master'><img src='https://coveralls.io/repos/stevieb9/p5-app-copyrightimage/badge.svg?branch=master&service=github' alt='Coverage Status' /></a>
=head1 SYNOPSIS
Modified copy of images will be placed into a new C<ci> directory within the
directory you specify. If no directory is specified, we'll create it in the
current working directory. All new images will be prefixed with C<ci_>.
# set copyright
imgcopyright -i picture.jpg -n "Steve Bertrand" -e "steveb@cpan.org"
# all pics in a directory
imgcopyright -i /home/user/Pictures -n "Steve Bertrand"
# find images without copyright info
imgcopyright -i /home/user/Pictures -c
# specify an alternate output directory
imgcopyright -i /home/user/Pictures -n "steve" -d ~/mypics
# replace a previous copyright
imgcopyright -i picture.jpg -n "steve" -f
=head1 DESCRIPTION
This C<imgcopyright> application allows you to add copyright information to
the EXIF data within image files. It also allows you to check images for
missing copyright info and remove info.
It works on individual files, as well as recurses (top-level only) of a
supplied directory.
It does NOT modify the original file (except for C<remove>). We create a
subdirectory named C<ci> in whatever path you specify (current working
directory if a path is not sent in), and we then take a copy of each original
file, modify it, prefix the filename with a C<ci_>, and place it into the
new C<ci> directory.
=head1 ARGUMENTS
=head2 -i, --image
Mandatory in all cases.
Name of a single image file, or a directory containing image files. In the case
of a directory, we'll iterate over the top level, and work on all image files
found.
=head2 -n, --name
Mandatory, unless using C<--check>.
This is the name that will be used in the copyright string for the C<Copyright>
EXIF tag, as well as the C<Creator> tag.
( run in 1.126 second using v1.01-cache-2.11-cpan-df04353d9ac )