App-Gallery

 view release on metacpan or  search on metacpan

META.json  view on Meta::CPAN

      },
      "configure" : {
         "requires" : {
            "ExtUtils::MakeMaker" : "0"
         }
      },
      "runtime" : {
         "requires" : {
            "File::Slurp" : "0",
            "HTML::Template::Compiled" : "0",
            "Image::Magick" : "0",
            "perl" : "5.014000"
         }
      }
   },
   "release_status" : "stable",
   "resources" : {
      "repository" : {
         "url" : "https://git.ieval.ro/?p=app-gallery.git"
      }
   },

META.yml  view on Meta::CPAN

  url: http://module-build.sourceforge.net/META-spec-v1.4.html
  version: '1.4'
name: App-Gallery
no_index:
  directory:
    - t
    - inc
requires:
  File::Slurp: '0'
  HTML::Template::Compiled: '0'
  Image::Magick: '0'
  perl: '5.014000'
resources:
  repository: https://git.ieval.ro/?p=app-gallery.git
version: '0.001001'
x_serialization_backend: 'CPAN::Meta::YAML version 0.018'

Makefile.PL  view on Meta::CPAN

	VERSION_FROM      => 'lib/App/Gallery.pm',
	ABSTRACT_FROM     => 'lib/App/Gallery.pm',
	AUTHOR            => 'Marius Gavrilescu <marius@ieval.ro>',
	EXE_FILES         => ['gallery.pl'],
	MIN_PERL_VERSION  => '5.14.0',
	LICENSE           => 'perl',
	SIGN              => 1,
	PREREQ_PM         => {
		qw/File::Slurp              0
		   HTML::Template::Compiled 0
		   Image::Magick            0/,
	},
	META_ADD         => {
		dynamic_config => 0,
		resources      => {
			repository   => 'https://git.ieval.ro/?p=app-gallery.git',
		},
	}
);

README  view on Meta::CPAN

   make
   make test
   make install

DEPENDENCIES

This module requires these other modules and libraries:

* File::Slurp
* HTML::Template::Compiled
* Image::Magick

COPYRIGHT AND LICENCE

Copyright (C) 2017 by Marius Gavrilescu

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself, either Perl version 5.24.2 or,
at your option, any later version of Perl 5 you may have available.


lib/App/Gallery.pm  view on Meta::CPAN

use 5.014000;
use strict;
use warnings;

use File::Basename qw/fileparse/;
use File::Copy qw/cp/;
use File::Path qw/make_path/;
use File::Slurp;
use File::Spec::Functions qw/catdir catfile/;
use HTML::Template::Compiled;
use Image::Magick;

our $VERSION = '0.001001';

my $default_template;
my %default_args = (tmpl => '', title => 'Gallery', width => 600, height => 600);

sub run {
	my (undef, $args, @images) = @_;
	my %args = (%default_args, %$args);
	my $full = catfile $args{out}, 'full';

lib/App/Gallery.pm  view on Meta::CPAN

	);
	make_path $full, $thumb;

	for my $path (@images) {
		my $basename = fileparse $path;
		my $thumb_path = catfile $thumb, $basename;
		my $dest_path = catfile $full, $basename;

		link $path, $dest_path or cp $path, $dest_path or die "$!";

		my $img = Image::Magick->new;
		$img->Read($path);
		my ($width, $height) = $img->Get('width', 'height');
		my $aspect_ratio = $width / $height;
		if ($width > $args{width}) {
			$width = $args{width};
			$height = $width / $aspect_ratio;
		}
		if ($height > $args{height}) {
			$height = $args{height};
			$width = $height * $aspect_ratio;

t/App-Gallery.t  view on Meta::CPAN

#!/usr/bin/perl
use strict;
use warnings;

use File::Temp qw/tempdir/;
use File::Slurp;
use File::Spec::Functions;
use Image::Magick;

use Test::More tests => 11;
BEGIN { use_ok('App::Gallery') };

sub test_img_size {
	my ($width, $height, $file) = @_;
	my $image = Image::Magick->new;
	$image->Read($file);
	my ($actual_width, $actual_height) = $image->Get(qw/width height/);
	is $width, $actual_width, 'image width';
	is $height, $actual_height, 'image height';
}

my @imgs = <t/*.png>;
my $dir = tempdir ('app-gallery.XXXX', TMPDIR => 1, CLEANUP => 1);
my $dir1 = catdir $dir, 'test1';
my $dir2 = catdir $dir, 'test2';



( run in 0.389 second using v1.01-cache-2.11-cpan-beeb90c9504 )