The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Mojolicious::Plugin::Images::Service

VERSION

version 0.007

SYNOPSIS

  my $service = $c->helper->service_by_moniker;

DESCRIPTION

Base class for service objects (helpers).

ATTRIBUTES

namespace

url_prefix Url prefix. Used to atomatically calculate static path. i</images> by defaults

ext

dir Directory of images, i<public/images> by default

suffix suffix, a moniker by default

write_options write options for Imager

read_options read options for Imager

transform Transformation

  # transform to clousure
  sub { my $t = shift; return $t->image->scale(xpixels => 100) };

  # transform to {namespace}::Trans::action
  trans#action
  
  # perfom a couple of transformations
  [scale => {xpixels => 100}, crop => {width => 100}];

For the subroutines an object Mojolicious::Plugin::Images::Transformer will be passed. Must return an Imager object

controller

Documentation will be available soon

METHODS

write ($self, $id, $img)

writes an image

url ($self, $id)

returns url of an image

abs_path ($self, $id)

If path is absolute, return it. Returns absolute path to app->home otherwise

canonpath ($self, $id)

returns a full normalized fs path of an image

exists ($self, $id)

returns true if an image with given id exists

read ($self, $id)

reads an image and returns an Imager object

AUTHOR

alexbyk <alexbyk@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2014 by alexbyk.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.