App-BlurFill

 view release on metacpan or  search on metacpan

META.json  view on Meta::CPAN

{
   "abstract" : "Blurred background fill image processor",
   "author" : [
      "dave@perlhacks.com"
   ],
   "dynamic_config" : 1,
   "generated_by" : "ExtUtils::MakeMaker version 7.70, CPAN::Meta::Converter version 2.150010",
   "license" : [
      "perl_5"
   ],
   "meta-spec" : {
      "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",

META.yml  view on Meta::CPAN

---
abstract: 'Blurred background fill image processor'
author:
  - dave@perlhacks.com
build_requires:
  ExtUtils::MakeMaker: '0'
configure_requires:
  ExtUtils::MakeMaker: '0'
dynamic_config: 1
generated_by: 'ExtUtils::MakeMaker version 7.70, CPAN::Meta::Converter version 2.150010'
license: perl
meta-spec:

Makefile.PL  view on Meta::CPAN

use ExtUtils::MakeMaker;

WriteMakefile(
    NAME         => 'App::BlurFill',
    VERSION_FROM => 'lib/App/BlurFill.pm',
    LICENSE      => 'perl',
    AUTHOR       => 'dave@perlhacks.com',
    ABSTRACT     => 'Blurred background fill image processor',
    PREREQ_PM    => {
        'Imager'         => 0,
        'File::Basename' => 0,
        'File::Temp'     => 0,
        'Test::More'     => 0,
        'Dancer2'        => 0,
        'Plack'          => 0,
        'Starman'        => 0,
    },
    MIN_PERL_VERSION => '5.040',

README.md  view on Meta::CPAN

# App::BlurFill

A simple Perl class for generating blurred background fills for images. Suitable for use in video formatting, social posts, and more.

## Usage from Perl

```perl
use App::BlurFill;

my $blur = App::BlurFill->new(file => 'input.jpg');
$blur->process;  # writes input_blur.jpg
```

bin/blurfill  view on Meta::CPAN

#!/usr/bin/env perl

=head1 NAME

blurfill - A simple command line tool to create a blurred background image

=head1 SYNOPSIS

  blurfill [--width w] [--height h] [--output o] image_file

=head1 DESCRIPTION

blurfill is a simple command line tool to create a blurred background image
from a given image. It scales the image to a specified width and height, applies
a Gaussian blur, and saves the result as a new image.
It is a wrapper around the App::BlurFill module.
It accepts the following command line options:

=over 4

=item * --width

The width of the output image. Default is 650 pixels.

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

=head1 NAME

App::BlurFill - A simple command line tool to create a blurred background image

=head1 SYNOPSIS

  use App::BlurFill;

  my $blur_fill = App::BlurFill->new(
    file    => 'path/to/image.jpg',
    width   => 650,
    height  => 350,
  );

  my $output = $blur_fill->process;
  print "Blurred image saved to: $output\n";

=head1 DESCRIPTION

App::BlurFill is a simple command line tool to create a blurred background image
from a given image. It scales the image to a specified width and height, applies
a Gaussian blur, and saves the result as a new image.

=head1 METHODS

=head2 new

  my $blur_fill = App::BlurFill->new(
    file    => 'path/to/image.jpg',
    width   => 650,

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

    my $dir = caller eq 'App::BlurFill::CLI' ? $path : tempdir(CLEANUP => 1);

    my $filename = "${name}_blur$ext";

    "$dir/$filename";
  };

  field $imager  :param = Imager->new(file => $file);

  method process {
    my $background = $imager->copy;

    $background = $background->scale(xpixels => $width);
    my $bg_height = $background->getheight;
    $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;
  }
}

=pod

=head1 AUTHOR

Dave Cross <dave@perlhacks.com>

lib/App/BlurFill/CLI.pm  view on Meta::CPAN


  use App::BlurFill::CLI;

  my $blur_fill = App::BlurFill::CLI->new;

  my $output = $blur_fill->process;
  print "Blurred image saved to: $output\n";

=head1 DESCRIPTION

App::BlurFill::CLI is a simple command line tool to create a blurred background image
from a given image. It scales the image to a specified width and height, applies
a Gaussian blur, and saves the result as a new image file.

=head1 METHODS

=head2 new

  my $blur_fill = App::BlurFill::CLI->new();

Creates a new App::BlurFill object. The no parameters are required.

lib/App/BlurFill/Web.pm  view on Meta::CPAN

sub _get_css {
  return <<'CSS';
    * {
      margin: 0;
      padding: 0;
      box-sizing: border-box;
    }
    
    body {
      font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
      background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
      min-height: 100vh;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 20px;
    }
    
    .container {
      background: white;
      border-radius: 16px;
      box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
      max-width: 600px;
      width: 100%;
      padding: 40px;
    }
    
    h1 {
      color: #333;
      font-size: 32px;

lib/App/BlurFill/Web.pm  view on Meta::CPAN

      margin-bottom: 8px;
      font-size: 14px;
    }
    
    input[type="file"] {
      display: block;
      width: 100%;
      padding: 12px;
      border: 2px dashed #667eea;
      border-radius: 8px;
      background: #f8f9ff;
      cursor: pointer;
      transition: all 0.3s ease;
    }
    
    input[type="file"]:hover {
      border-color: #764ba2;
      background: #f0f1ff;
    }
    
    input[type="number"] {
      width: 100%;
      padding: 12px 16px;
      border: 2px solid #e0e0e0;
      border-radius: 8px;
      font-size: 16px;
      transition: all 0.3s ease;
    }

lib/App/BlurFill/Web.pm  view on Meta::CPAN

    
    .dimensions {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 16px;
    }
    
    button, .button {
      width: 100%;
      padding: 16px;
      background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
      color: white;
      border: none;
      border-radius: 8px;
      font-size: 18px;
      font-weight: 600;
      cursor: pointer;
      transition: all 0.3s ease;
      box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
      text-decoration: none;
      display: inline-block;

lib/App/BlurFill/Web.pm  view on Meta::CPAN

    button:hover, .button:hover {
      transform: translateY(-2px);
      box-shadow: 0 6px 16px rgba(102, 126, 234, 0.5);
    }
    
    button:active, .button:active {
      transform: translateY(0);
    }
    
    .info {
      background: #f8f9ff;
      border-left: 4px solid #667eea;
      padding: 16px;
      margin-top: 24px;
      border-radius: 4px;
    }
    
    .info p {
      color: #555;
      font-size: 14px;
      line-height: 1.6;

lib/App/BlurFill/Web.pm  view on Meta::CPAN

      box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    }

    .result-image img {
      max-width: 100%;
      height: auto;
      display: block;
    }

    .success-message {
      background: #f0fdf4;
      border-left: 4px solid #10b981;
      padding: 16px;
      margin-bottom: 24px;
      border-radius: 4px;
      color: #065f46;
    }

    .action-buttons {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 16px;
      margin-top: 24px;
    }

    .button-secondary {
      background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
    }
    
    @media (max-width: 640px) {
      .container {
        padding: 24px;
      }
      
      h1 {
        font-size: 24px;
      }

lib/App/BlurFill/Web.pm  view on Meta::CPAN

      <img src="/download/$out_name" alt="Resized image preview">
    </div>
    
    <div class="action-buttons">
      <a href="/download/$out_name" class="button" download>Download image</a>
      <a href="/" class="button button-secondary">Create another</a>
    </div>
    
    <div class="info">
      <p><strong>What's next?</strong></p>
      <p>• Click "Download image" to save your resized background</p>
      <p>• Click "Create another" to process a new image</p>
    </div>
  </div>
</body>
</html>
HTML
};

get '/download/:filename' => sub {
  my $filename = route_parameters->get('filename');



( run in 1.138 second using v1.01-cache-2.11-cpan-d8267643d1d )