line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
################################################################################################### |
2
|
|
|
|
|
|
|
# Copyright 2013/2014 by Marcel Greter |
3
|
|
|
|
|
|
|
# This file is part of OCBNET-WebSprite (GPL3) |
4
|
|
|
|
|
|
|
#################################################################################################### |
5
|
|
|
|
|
|
|
package OCBNET::Image; |
6
|
|
|
|
|
|
|
#################################################################################################### |
7
|
|
|
|
|
|
|
# implementation agnostic image library for OCBNET-WebSprite |
8
|
|
|
|
|
|
|
# will either use GD, Image::Magick or Graphics::Magick |
9
|
|
|
|
|
|
|
#################################################################################################### |
10
|
|
|
|
|
|
|
our $VERSION = '1.0.1'; |
11
|
|
|
|
|
|
|
#################################################################################################### |
12
|
|
|
|
|
|
|
|
13
|
4
|
|
|
4
|
|
122588
|
use Carp; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
280
|
|
14
|
4
|
|
|
4
|
|
21
|
use strict; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
117
|
|
15
|
4
|
|
|
4
|
|
19
|
use warnings; |
|
4
|
|
|
|
|
15
|
|
|
4
|
|
|
|
|
114
|
|
16
|
4
|
|
|
4
|
|
18
|
use vars qw(@ISA); |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
1265
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
#################################################################################################### |
19
|
|
|
|
|
|
|
# check if needed module is already loaded |
20
|
|
|
|
|
|
|
# otherwise we try to load an implementation |
21
|
|
|
|
|
|
|
#################################################################################################### |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# determine module |
24
|
|
|
|
|
|
|
my $module; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# check for pre-loaded module first |
27
|
|
|
|
|
|
|
if (eval { $OCBNET::Image::GD::VERSION }) { $module = "gd" } |
28
|
|
|
|
|
|
|
elsif (eval { $OCBNET::Image::GM::VERSION }) { $module = "gm" } |
29
|
|
|
|
|
|
|
elsif (eval { $OCBNET::Image::IM::VERSION }) { $module = "im" } |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# check for pre-loaded library next |
32
|
|
|
|
|
|
|
elsif (eval { $GD::VERSION }) { $module = "gd" } |
33
|
|
|
|
|
|
|
elsif (eval { $Graphic::Magick::VERSION }) { $module = "gm" } |
34
|
|
|
|
|
|
|
elsif (eval { $Image::Magick::VERSION }) { $module = "im" } |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# finally try to load an implementation on my own |
37
|
|
|
|
|
|
|
elsif (eval { require OCBNET::Image::GD }) { $module = "gd" } |
38
|
|
|
|
|
|
|
elsif (eval { require OCBNET::Image::GM }) { $module = "gm" } |
39
|
|
|
|
|
|
|
elsif (eval { require OCBNET::Image::IM }) { $module = "im" } |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# fatal error if no implementation was loaded |
42
|
|
|
|
|
|
|
else { die "no graphic implementation found" } |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# put the correct base class implementation into place |
45
|
|
|
|
|
|
|
if ($module eq "gd") { require OCBNET::Image::GD; push @ISA, qw(OCBNET::Image::GD) } |
46
|
|
|
|
|
|
|
elsif ($module eq "gm") { require OCBNET::Image::GM; push @ISA, qw(OCBNET::Image::GM) } |
47
|
|
|
|
|
|
|
elsif ($module eq "im") { require OCBNET::Image::IM; push @ISA, qw(OCBNET::Image::IM) } |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
#################################################################################################### |
50
|
|
|
|
|
|
|
#################################################################################################### |
51
|
|
|
|
|
|
|
1; |