]> git.imager.perl.org - imager.git/commitdiff
[rt.cpan.org #65665] add the preload class method
authorTony Cook <tony@develop-help.com>
Sat, 12 Feb 2011 02:10:05 +0000 (13:10 +1100)
committerTony Cook <tony@develop-help.com>
Sat, 12 Feb 2011 02:10:05 +0000 (13:10 +1100)
Changes
Imager.pm
lib/Imager/Files.pod
t/x20spell.t

diff --git a/Changes b/Changes
index 2b189e25d75ec40980c001e1eea4a195532fc257..390e0fcf000904104d44ac9210a517b3fee0df93 100644 (file)
--- a/Changes
+++ b/Changes
@@ -12,6 +12,10 @@ Imager 0.81 - unreleased
  - split libt1 Type 1 font support into a sub-module
    https://rt.cpan.org/Ticket/Display.html?id=49616 (partial)
 
  - split libt1 Type 1 font support into a sub-module
    https://rt.cpan.org/Ticket/Display.html?id=49616 (partial)
 
+ - add a preload() class method for use in forking servers, and to
+   work around limitations in PAR.
+   https://rt.cpan.org/Ticket/Display.html?id=65665
+
 Bug fixes:
 
  - paletted writes to a masked image are now masked correctly.
 Bug fixes:
 
  - paletted writes to a masked image are now masked correctly.
index 0802663f38e67c665d67fe8ce6a128bfd6375255..fadac58fb5d0744f264434ae31644a7a73c96324 100644 (file)
--- a/Imager.pm
+++ b/Imager.pm
@@ -3908,6 +3908,24 @@ sub Inline {
 # threads shouldn't try to close raw Imager objects
 sub Imager::ImgRaw::CLONE_SKIP { 1 }
 
 # threads shouldn't try to close raw Imager objects
 sub Imager::ImgRaw::CLONE_SKIP { 1 }
 
+sub preload {
+  # this serves two purposes:
+  # - a class method to load the file support modules included with Image
+  #   (or were included, once the library dependent modules are split out)
+  # - something for Module::ScanDeps to analyze
+  # https://rt.cpan.org/Ticket/Display.html?id=6566
+  local $@;
+  eval { require Imager::File::GIF };
+  eval { require Imager::File::JPEG };
+  eval { require Imager::File::PNG };
+  eval { require Imager::File::SGI };
+  eval { require Imager::File::TIFF };
+  eval { require Imager::File::ICO };
+  eval { require Imager::Font::W32 };
+  eval { require Imager::Font::FT2 };
+  eval { require Imager::Font::T1 };
+}
+
 # backward compatibility for %formats
 package Imager::FORMATS;
 use strict;
 # backward compatibility for %formats
 package Imager::FORMATS;
 use strict;
@@ -4350,6 +4368,8 @@ polygon() - L<Imager::Draw/polygon>
 
 polyline() - L<Imager::Draw/polyline>
 
 
 polyline() - L<Imager::Draw/polyline>
 
+preload() - L<Imager::Files/preload>
+
 read() - L<Imager::Files> - read a single image from an image file
 
 read_multi() - L<Imager::Files> - read multiple images from an image
 read() - L<Imager::Files> - read a single image from an image file
 
 read_multi() - L<Imager::Files> - read multiple images from an image
index 244e850d3b06e63ebce5938f9f3a64a0634b2027..fa35a04a31e06aa6119c014d786e9bacc88f7c20 100644 (file)
@@ -1523,6 +1523,25 @@ If your module can only handle writing then you can name your module
 C<Imager::File::>I<your-format-name>C<Writer> and Imager will attempt
 to autoload it.
 
 C<Imager::File::>I<your-format-name>C<Writer> and Imager will attempt
 to autoload it.
 
+=head1 PRELOADING FILE MODULES
+
+=over
+
+=item preload
+
+This preloads the file support modules included with or that have been
+included with Imager in the past.  This is intended for use in forking
+servers such as mod_perl.
+
+If the module is not available no error occurs.
+
+Preserves $@.
+
+  use Imager;
+  Imager->preload;
+
+=back
+
 =head1 EXAMPLES
 
 =head2 Producing an image from a CGI script
 =head1 EXAMPLES
 
 =head2 Producing an image from a CGI script
index 6a1aaaae0f0242a180a7f6638e5f2b99c19fe432..11b0021a31427bc311cc524463d0c1684b94aaba 100644 (file)
@@ -9,45 +9,48 @@ my $manifest = maniread();
 my @pod = sort grep !/^inc/ && /\.(pm|pl|pod|PL)$/, keys %$manifest;
 plan tests => scalar(@pod);
 my @stopwords = qw/
 my @pod = sort grep !/^inc/ && /\.(pm|pl|pod|PL)$/, keys %$manifest;
 plan tests => scalar(@pod);
 my @stopwords = qw/
+API
+Arnar
+BMP
+Blit
+CGI
+CMYK
+CPAN
+FreeType
+GIF
+HSV
+Hrafnkelsson
+ICO
+IMAGER
 Imager
 Imager's
 Imager
 Imager's
-IMAGER
-GIF
 JPEG
 PNG
 JPEG
 PNG
-TIFF
-BMP
+PNM
+RGB
+RGBA
 SGI
 TGA
 SGI
 TGA
-RGB
-ICO
-PNM
+TIFF
+UTF-8
+Uncategorized
 bilevel
 bilevel
+const
 dpi
 dpi
-Arnar
-Hrafnkelsson
-API
-paletted
-guassian
-metadata
-CPAN
 eg
 eg
+guassian
 ie
 ie
-CMYK
-HSV
-CGI
-const
-varargs
-FreeType
-UTF-8
-RGBA
-postfix
 infix
 infix
-unary
+metadata
+paletted
+postfix
+preload
+preloading
+preloads
 renderer
 renderer
-Uncategorized
-Blit
 tuple
 tuple
+unary
+varargs
 /;
 
 local %Pod::Wordlist::Wordlist = %Pod::Wordlist::Wordlist;
 /;
 
 local %Pod::Wordlist::Wordlist = %Pod::Wordlist::Wordlist;