App-BlurFill
view release on metacpan or search on metacpan
lib/App/BlurFill.pm
lib/App/BlurFill/CLI.pm
Makefile.PL
MANIFEST This list of files
README.md
t/00-basic.t
t/01-cli.t
t/pod.t
t/pod_coverage.t
t/test.jpg
t/test.png
META.yml Module YAML meta-data (added by MakeMaker)
META.json Module JSON meta-data (added by MakeMaker)
## Command line program - `blurfill`
The `blurfill` program is a standard command line program. You run it like
this:
blurfill [-w width] [-h height] [-o output_filename] image_filename
If width or height are omitted, they default to 650 pixels and 350 pixels
respectively. If the output filename is omitted, then one will be generated
for you. For example, if you start with `picture.png`, then your output will
be written to `picture_blur.png`.
## Docker container
The `davorg/app-blurfill` image contains the Perl API and the `blurfill`
command, without a web framework. Mount a directory containing an image and
run the command explicitly:
docker run --rm -v "$PWD:/work" davorg/app-blurfill:0.1.0 \
blurfill /work/picture.png
The web application is distributed separately as
[App::BlurFill::Web](https://metacpan.org/dist/App-BlurFill-Web) and as the
`davorg/app-blurfill-web` container image.
docker/DOCKER.md view on Meta::CPAN
# Docker Usage
The `davorg/app-blurfill` image contains the App::BlurFill Perl API and the
`blurfill` command-line program. It intentionally contains no web framework.
```bash
docker build -f docker/Dockerfile -t davorg/app-blurfill:0.1.0 .
docker run --rm -v "$PWD:/work" davorg/app-blurfill:0.1.0 \
blurfill /work/picture.png
```
The image is also the base for `davorg/app-blurfill-web`.
docker/Dockerfile view on Meta::CPAN
FROM perl:5.40-slim
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
libfreetype6-dev \
libgif-dev \
libjpeg-dev \
libpng-dev \
libtiff-dev \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /opt/app-blurfill
COPY . .
RUN cpanm --notest --installdeps . \
&& perl Makefile.PL \
&& make install \
&& rm -rf /root/.cpanm /opt/app-blurfill/blib
lib/App/BlurFill.pm view on Meta::CPAN
$background = $background->crop(
top => ($bg_height / 2) - ($height / 2),
bottom => ($bg_height / 2) + ($height / 2),
);
$background->filter(type => 'gaussian', stddev => 15);
my $img = $imager->scale(ypixels => $height);
my $img_width = $img->getwidth;
$background->compose(src => $img, left => ($width / 2) - ($img_width / 2));
$background->write(file => $output, type => 'png') or die $background->errstr;
return $output;
}
}
=head1 WEB INTERFACE
The web interface previously included in this distribution was moved to the
separate L<App::BlurFill::Web> distribution in version 0.0.6. Installing
App::BlurFill now provides only the Perl API and the C<blurfill> command-line
use strict;
use warnings;
use Test::More;
use File::Temp qw(tempdir);
use File::Basename;
use App::BlurFill::CLI;
my $image = "t/test.png";
plan skip_all => "Test image $image not found" unless -e $image;
# Simulate @ARGV as CLI would receive it
local @ARGV = ($image);
# Run the CLI logic
App::BlurFill::CLI->new->run;
# Check for the expected output file
my ($name, $path, $ext) = fileparse($image, qr/\.[^.]*$/);
( run in 1.215 second using v1.01-cache-2.11-cpan-788537b7465 )