Image-APNG

 view release on metacpan or  search on metacpan

Build.PL  view on Meta::CPAN

	dist_version_from       => 'lib/Image/APNG.pm',
	dist_abstract           => 'Generate Animated PNG (APNG) files from individual PNG images',
	configure_requires      =>
		{
		'Module::Build' => '0.42',
		},
	
	requires => 
		{
		'perl'          => '5.010',
		'Image::Magick' => '0',
		'strict'        => 0,
		'warnings'      => 0,
		},
	
	test_requires => 
		{
		'Test::More' => '0.98',
		'File::Temp' => 0,
		},
	

INSTALL  view on Meta::CPAN


    perl Build.PL
    ./Build
    ./Build test
    ./Build install

DEPENDENCIES

Required:
    - Perl 5.10 or higher
    - Image::Magick 6.0 or higher

Build/Test:
    - Module::Build 0.42 or higher
    - Test::More 0.98 or higher

Optional (for testing):
    - Test::Pod
    - Test::Pod::Coverage

INSTALLING IMAGE::MAGICK

Image::Magick can be challenging to install. Here are platform-specific instructions:

Debian/Ubuntu:
    apt-get install libimage-magick-perl

RedHat/CentOS/Fedora:
    yum install perl-Image-Magick
    # or
    dnf install perl-Image-Magick

macOS (with Homebrew):
    brew install imagemagick
    cpan Image::Magick

Windows (with Strawberry Perl):
    cpan Image::Magick

From CPAN:
    cpan Image::Magick
    # or
    cpanm Image::Magick

INSTALLATION FROM CPAN

The easiest way to install this module is via CPAN:

    cpan Image::APNG

Or using cpanminus:

    cpanm Image::APNG

INSTALL  view on Meta::CPAN

Then add to your shell profile (~/.bashrc or ~/.profile):

    export PERL5LIB=~/perl5/lib/perl5:$PERL5LIB
    export PATH=~/perl5/bin:$PATH

MANUAL DEPENDENCIES INSTALLATION

If automatic dependency resolution fails, install dependencies manually:

    cpan Module::Build
    cpan Image::Magick
    cpan Test::More

TROUBLESHOOTING

If tests fail:
    - Ensure Image::Magick is properly installed
    - Check that you have write permissions in /tmp
    - Try running tests with verbose output:
        ./Build test verbose=1

If installation fails:
    - Check that you have write permissions to Perl library directories
    - Try installing to a local directory (see above)
    - Ensure all dependencies are installed

For Image::Magick installation issues:
    - Ensure ImageMagick C library is installed first
    - Check ImageMagick version compatibility
    - See: https://imagemagick.org/script/perl-magick.php

SUPPORT

For bugs and issues:
    https://github.com/username/Image-APNG/issues

CPAN rating:

META.json  view on Meta::CPAN

   },
   "name" : "Image-APNG",
   "prereqs" : {
      "configure" : {
         "requires" : {
            "Module::Build" : "0.42"
         }
      },
      "runtime" : {
         "requires" : {
            "Image::Magick" : "0",
            "perl" : "5.010",
            "strict" : "0",
            "warnings" : "0"
         }
      },
      "test" : {
         "requires" : {
            "File::Temp" : "0",
            "Test::More" : "0.98"
         }

META.yml  view on Meta::CPAN

license: perl
meta-spec:
  url: http://module-build.sourceforge.net/META-spec-v1.4.html
  version: '1.4'
name: Image-APNG
provides:
  Image::APNG:
    file: lib/Image/APNG.pm
    version: v1.0.0
requires:
  Image::Magick: '0'
  perl: '5.010'
  strict: '0'
  warnings: '0'
resources:
  bugtracker: https://github.com/nkh/Image-APNG/issues
  license: http://dev.perl.org/licenses/
  repository: https://github.com/nkh/Image-APNG
version: v1.0.0
x_serialization_backend: 'CPAN::Meta::YAML version 0.018'

Makefile.PL  view on Meta::CPAN

# Note: this file was auto-generated by Module::Build::Compat version 0.4234
require 5.010;
use ExtUtils::MakeMaker;
WriteMakefile
(
  'NAME' => 'Image::APNG',
  'VERSION_FROM' => 'lib/Image/APNG.pm',
  'PREREQ_PM' => {
                   'Image::Magick' => '0',
                   'strict' => 0,
                   'warnings' => 0
                 },
  'INSTALLDIRS' => 'site',
  'EXE_FILES' => [],
  'PL_FILES' => {}
)
;

README.md  view on Meta::CPAN

## Files

- **APNGGenerator.pm** - Main module with POD documentation
- **APNGGenerator_Documentation.md** - Comprehensive documentation
- **example_usage.pl** - Example script demonstrating usage
- **README.md** - This file

## Requirements

- Perl 5.10+
- Image::Magick

## Documentation

See `APNGGenerator_Documentation.md` for complete documentation including:

- Installation instructions
- Detailed API reference
- All configuration options
- Error handling guide
- Performance considerations

lib/Image/APNG.pm  view on Meta::CPAN

package Image::APNG ;

use strict ;
use warnings ;
use Image::Magick ;

our $VERSION = '1.0.0' ;

=head1 NAME

Image::APNG - Generate Animated PNG (APNG) files from individual PNG images

=head1 SYNOPSIS

	use Image::APNG;

lib/Image/APNG.pm  view on Meta::CPAN

sub load_frames
{
my ($frames, $errors, $options) = @_ ;

my ($loaded, $previous_valid) = ([]) ;

for my $frame_data (@$frames)
	{
	my ($filename, $delay_ms) = @$frame_data ;
	
	my $image  = Image::Magick->new() ;
	my $status = $image->Read($filename) ;
	
	if ($status)
		{
		push @$errors, "Failed to load $filename: $status" ;
		
		if ($previous_valid)
			{
			my $blank = $previous_valid->Clone() ;
			$blank->Quantize(colorspace => 'Transparent') ;

lib/Image/APNG.pm  view on Meta::CPAN

		$bg_color->[0],
		$bg_color->[1],
		$bg_color->[2],
		$bg_color->[3] / 255.0
		) ;

for my $frame (@$frames)
	{
	next if $frame->{width} == $max_width && $frame->{height} == $max_height ;
	
	my $canvas = Image::Magick->new(size => "${max_width}x${max_height}") ;
	$canvas->Read("xc:$bg_string") ;
	
	my $x_offset = int(($max_width - $frame->{width}) / 2) ;
	my $y_offset = int(($max_height - $frame->{height}) / 2) ;
	
	$canvas->Composite
			(
			image   => $frame->{image},
			x       => $x_offset,
			y       => $y_offset,

t/01-basic.t  view on Meta::CPAN

#!/usr/bin/env perl

use strict;
use warnings;
use Test::More;
use File::Temp qw(tempfile tempdir);
use Image::APNG;

plan skip_all => 'Image::Magick required for testing' unless eval { require Image::Magick; 1 } ;

plan tests => 8;

my $tempdir = tempdir(CLEANUP => 1) ;

sub create_test_png
{
my ($filename, $width, $height, $color) = @_ ;

my $image = Image::Magick->new(size => "${width}x${height}") ;
$image->Read("xc:$color") ;
$image->Write(filename => $filename) ;

return $filename ;
}

my $frame1 = create_test_png("$tempdir/frame1.png", 100, 100, 'red') ;
my $frame2 = create_test_png("$tempdir/frame2.png", 100, 100, 'blue') ;
my $frame3 = create_test_png("$tempdir/frame3.png", 100, 100, 'green') ;

t/02-options.t  view on Meta::CPAN

#!/usr/bin/env perl

use strict;
use warnings;
use Test::More;
use File::Temp qw(tempfile tempdir);
use Image::APNG;

plan skip_all => 'Image::Magick required for testing' unless eval { require Image::Magick; 1 } ;

plan tests => 10;

my $tempdir = tempdir(CLEANUP => 1) ;

sub create_test_png
{
my ($filename, $width, $height, $color) = @_ ;

my $image = Image::Magick->new(size => "${width}x${height}") ;
$image->Read("xc:$color") ;
$image->Write(filename => $filename) ;

return $filename ;
}

my $frame1 = create_test_png("$tempdir/frame1.png", 100, 100, 'red') ;
my $frame2 = create_test_png("$tempdir/frame2.png", 150, 150, 'blue') ;
my $frame3 = create_test_png("$tempdir/frame3.png", 120, 80, 'green') ;



( run in 2.467 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )