File Coverage

blib/lib/Image/BoxModel.pm
Criterion Covered Total %
statement 18 53 33.9
branch 0 8 0.0
condition 0 3 0.0
subroutine 6 8 75.0
pod 0 2 0.0
total 24 74 32.4


line stmt bran cond sub pod time code
1             package Image::BoxModel;
2              
3 1     1   26745 use 5.006000;
  1         3  
  1         38  
4 1     1   5 use warnings;
  1         2  
  1         28  
5 1     1   5 use strict;
  1         6  
  1         55  
6             our $VERSION = '0.50';
7 1     1   5 use Carp;
  1         2  
  1         1225  
8              
9 1     1   623 use Image::BoxModel::Lowlevel; #Lowlevel methods like boxes, text, graphic primitives
  1         2  
  1         37  
10 1     1   785 use Image::BoxModel::Text; #Automatically makes a fitting box and puts text on it. Uses Lowlevel methods
  1         13  
  1         748  
11              
12             our @ISA = ("Image::BoxModel::Text", "Image::BoxModel::Lowlevel");
13              
14             sub new{
15 0     0 0   my $class = shift;
16            
17             #Define a new image an preset some values before..
18 0           my $image ={
19             width => 400,
20             height => 300,
21             background => 'white',
22             lib=> 'GD', #IM or GD ;-)
23             PI => 3.14159265358979,
24             verbose => "0", #if we print many messages about what the programs do.
25             #.. adding the users parameters
26             @_
27             };
28 0           $image->{height}--; #Because a picture of 400 pixels height ranges from 0-399
29 0           $image->{width}--;
30            
31 0           $image->{free} = { #This is the standard-box. It will shrink when a new box is added. Now it fills the whole background.
32             top => 0,
33             bottom => $image->{height},
34             height => $image -> {height},
35             left => 0,
36             right => $image->{width},
37             width => $image->{width}
38             };
39            
40             # The preset Colors (see below are read in). This is not done with DATA on purpose.
41             # I had some strange errors when using Image::BoxModel while open Filehandles in calling programs
42 0           %{$image->{preset_colors}} = PresetColors();
  0            
43            
44             #Now follow the definitions of the backend-libraries
45             #Inheritance is granted by using the appropriate backend-modules.
46             #This means that if GD is used, then the image-object has ::Backend::GD as its parent, so therefore the appropriate methods in ::Backend::GD are found.
47             #I don't know if this is good software design..
48            
49 0 0         if ($image -> {lib} eq "IM"){
    0          
50 0           require Image::Magick;
51 0           require Image::BoxModel::Backend::IM;
52 0           push @ISA, "Image::BoxModel::Backend::IM";
53            
54 0           $image->{IM} = new Image::Magick;
55 0           $image->{IM} -> Set(size => ($image->{width}+1)."x".($image->{height}+1)); #IM calculates "human-style" 800x400 is from 0 to 799 and 0 to 399 :-) we do width-- and height-- because we don't do human style in this module.
56 0           $image->{IM} -> Read("xc:$image->{background}");
57             }
58             elsif ($image -> {lib} eq "GD"){
59 0           require GD;
60 0           require Image::BoxModel::Backend::GD;
61 0           push @ISA, "Image::BoxModel::Backend::GD";
62            
63            
64 0           $image->{GD} = new GD::Image($image->{width}+1,$image->{height}+1);
65 0           $image->{colors}{'#ffffff'} = $image->{GD}->colorAllocate(255,255,255); #allocate white to ensure white background. This is perhaps not a clever move, but otherwise it will be drawn with the first color allocated, which quite surely is seldom desired.
66            
67             #Fontconfig should not be enabled by default, even it is tempting to do so ;-). The examples will presumably produce many errors if fontconfig can't be enabled.
68            
69 0 0 0       if (exists $image->{fontconfig} and $image->{fontconfig} != 0){
70 0           my $a = $image->{GD}->useFontConfig(1);
71 0 0         if ($a == 0){
72 0           print "Fontconfig not available!";
73 0           $image->{fontconfig} = 0; #to get(!) errors later on. If loading fails, then we don't want to pretend we loaded it.
74             }
75             }
76             else{
77 0           $image->{fontconfig} = 0; #to avoid silly "uninitialized value"-errors later on
78             }
79             }
80            
81 0           bless $image, $class;
82            
83 0           return $image;
84             }
85              
86             1;
87              
88             =head1 NAME
89              
90             Image::BoxModel - Module for defining boxes on an image and putting things on them
91              
92             =head1 SYNOPSIS
93              
94             use Image::BoxModel;
95            
96             #Define an object
97             my $image = new Image::BoxModel (
98             width => 800,
99             height => 400,
100             lib => 'GD', #[IM|GD]
101             precise => '1' #IM only: IM-backend will draw antialiased lines instead of rounding to integers before drawing.
102             #I don't know, if this is of interest to anyone..
103             verbose => '1', #If you want to see which modules and submodules do what.
104             #Be prepared to see many messages :-)
105             );
106            
107             #Define a box named "title" on the upper border
108             print $image -> Box(position =>"top", height=>120, name=>"title", background =>'red');
109            
110             #Put some rotated text on the "title"-box and demonstrate some options.
111             #(verdana.ttf needs to be present in the same directory)
112             print $image -> Text(
113             box => "title",
114             text =>"Hello World!\nAligned right, positioned in the center (default)\nslightly rotated.",
115             textsize=>"16",
116             rotate => "10" ,
117             font => './FreeSans.ttf', #must be present in the same directory. See PORTABILITY below.
118             fill => "yellow",
119             background=>"green",
120             align =>"Right"
121             );
122            
123             print $image -> Box(position =>"left", width=>200, name=>"text_1", background =>'blue');
124             print $image -> Text(
125             box => "text_1", text =>"Some 'North-West'-aligned text.\n:-)",
126             textsize => "12",
127             background =>"yellow",
128             position =>"NorthWest"
129             );
130            
131             print $image -> Text(text => "Some more text on the free space.",textsize => 12, rotate=> "-30");
132            
133             #Save image to file
134             $image -> Save(file=> "01_hello_world_$image->{lib}.png");
135              
136             More examples are in examples/
137              
138             =head1 DESCRIPTION
139              
140             =head2 OBJECTIVES
141              
142             Have a way to draw things on images using the same code with different libraries.
143              
144             Use OO-style design to make the implementation of new library backends (library wrappers) easy. Image::Magick and GD present at the moment.
145              
146             Use a box model to cut the original image into smaller rectangles. Afterwards objects can be drawn onto these boxes.
147              
148             =head2 ANOTHER IMAGING / CHARTING / WHATEVER MODULE?
149              
150             There are many Charting Modules and many Font Modules as well.
151             There are many concepts about how to layout elements on an image / page.
152              
153             This module will try hard to make the life of the user easier and the life of the developer more fun.
154              
155             It has backends for graphic libraries so that you can draw images using the same code with different libraries.
156              
157             Example: One user (me ;-) starts writing a perl script which produces some charts.
158             Because Image::Magick is common to me, I use it. After some time I find out that GD would be much faster and is able to do everything I need.
159             I have to rewrite much of my code because GD does many things different from how IM does them.
160             ..And now someone tells me about the Imager-module from the CPAN!
161              
162             With this module it is (should be) possible to just replace $image->{lib} in the constructor method and keep the rest of the code.
163              
164             =head2 PORTABILITY
165              
166             If you want to write portable code, you have to stick with the following things: (Portability between OSes and between backend libs)
167              
168             =head3 Don't use fontconfig
169              
170             You can profit from the wonderful possibilties offered by fontconfig, if you use this module on a system with fontconfig and GD as backend lib.
171             Anyhow, if you change the backend to Image::Magick later or take your code to a system without fontconfig, it will produce errors.
172              
173             Perhaps these considerations will lead to removing fontconfig support from Image::BoxModel. Perhaps 'font' will be mandatory for 'Text' and 'Annotate'.
174             Perhaps there will be a possibilty to specify a default font.
175              
176             =head3 Copy the font files into your projects directory tree
177              
178             There is never a guarantee that fonts are present on a different system or on a different machine. You don't know if they are in the same place.
179              
180             =head3 Always use the 'font' parameter with 'Text' and 'Annotate'
181              
182             To be safe that the font is found (or an error is displayed), use
183              
184             font=>'path/to/my/font.ttf'
185              
186             as a parameter with every 'Text' or 'Annotate' call.
187              
188             Of course, it is much more conventient to rely on the default settings of fontconfig or some libraries internal magic, but it beaks portability very easily.
189              
190             =head3 Don't use absolute paths
191              
192             Yes, of course not. ;-)
193              
194             It is tempting to use absolute paths to find fonts. Don't. Don't repeat my mistakes. :-)
195              
196             =head3 Don't use library-methods
197              
198             It is possible to use every method of the chosen library through the objects library-object:
199              
200             $image->{IM} -> Edge(radius => "10");
201              
202             This of course only works with Image::Magick. First, because there will be no {IM} if using GD und second, because GD doesn't know about 'Edge'.
203             On the other hand, this code will only work with GD:
204              
205             $image->{GD} -> arc(50,50,95,75,0,360,$image->Colors(color=>'blue'));
206              
207             There may be cases in which you will want to use library-specific code. Image::BoxModel doesn't implement all features of all libraries. Besides, this would be quite difficult.
208              
209             =head2 FUTURE
210              
211             Charts: being done
212              
213             More graphic primitives
214              
215             Vector graphic backend
216             (The problem is, the module "thinks" in bitmaps, so it is not completely clear to me how to transfer this into vectors..)
217              
218             Imager backend
219              
220             Any more ideas?
221              
222             =head2 QUESTIONS
223              
224             Would it make sense to be able and cut off nonrectangular boxes? / Would it be desirable to cut off boxes which result in a nonrectangular remaining free space?
225             (Define a rectangle in the upper left corner. Then the free field would be a concave hexagon. This produces some problems later: defining new boxes / find out if object is in the box)
226              
227             How to translate the used bitmap model into the vector model?
228             In the bitmap model the smallest unit is one pixel, which defines rather a area of the image with a certain size.
229             In the world of vectors there is no smallest unit (is there?) and a point has no size.
230              
231              
232             =head2 EXAMPLES
233              
234             There is a growing set of sample programs in the examples/ directory together with their respective images.
235             This should allow you to understand how things work and verify if your copy of the module works as expected.
236             To ensure they work even if you don't install the module into your system, they use a "use lib ("../lib"); Dunno if this is appropriate.
237              
238             =head2 SEE:
239              
240             README for installation & dependencies
241              
242             L - basic functionality
243              
244             L - direct and save drawing of text
245              
246             L - charts (incomplete)
247              
248             L - mini-tutorial on how to use colors
249              
250             =head1 BUGS
251              
252             oh, please ;-)
253              
254             Bug reports are welcome.
255              
256             =head1 AUTHOR
257              
258             Matthias Bloch, matthias at puffin ch
259              
260             =head1 COPYRIGHT AND LICENSE
261              
262             Copyright (C) 2008 by :m)
263              
264             This library is free software; you can redistribute it and/or modify
265             it under the same terms as Perl itself, either Perl version 5.8.8 or,
266             at your option, any later version of Perl 5 you may have available.
267              
268              
269             =cut
270              
271              
272             #~ __DATA__
273             sub PresetColors{
274 0     0 0   my $colors_text = '#FFFAFA snow
275             #FFFAFA snow1
276             #EEE9E9 snow2
277             #FFC1C1 RosyBrown1
278             #EEB4B4 RosyBrown2
279             #CDC9C9 snow3
280             #F08080 LightCoral
281             #FF6A6A IndianRed1
282             #CD9B9B RosyBrown3
283             #EE6363 IndianRed2
284             #BC8F8F RosyBrown
285             #FF4040 brown1
286             #FF3030 firebrick1
287             #EE3B3B brown2
288             #CD5C5C IndianRed
289             #CD5555 IndianRed3
290             #EE2C2C firebrick2
291             #8B8989 snow4
292             #CD3333 brown3
293             #FF0000 red
294             #FF0000 red1
295             #8B6969 RosyBrown4
296             #CD2626 firebrick3
297             #EE0000 red2
298             #B22222 firebrick
299             #A52A2A brown
300             #CD0000 red3
301             #8B3A3A IndianRed4
302             #8B2323 brown4
303             #8B1A1A firebrick4
304             #8B0000 DarkRed
305             #8B0000 red4
306             #800000 maroon
307             #FFAEB9 LightPink1
308             #CD8C95 LightPink3
309             #8B5F65 LightPink4
310             #EEA2AD LightPink2
311             #FFB6C1 LightPink
312             #FFC0CB pink
313             #DC143C crimson
314             #FFB5C5 pink1
315             #EEA9B8 pink2
316             #CD919E pink3
317             #8B636C pink4
318             #8B475D PaleVioletRed4
319             #DB7093 PaleVioletRed
320             #EE799F PaleVioletRed2
321             #FF82AB PaleVioletRed1
322             #CD6889 PaleVioletRed3
323             #FFF0F5 LavenderBlush
324             #FFF0F5 LavenderBlush1
325             #CDC1C5 LavenderBlush3
326             #EEE0E5 LavenderBlush2
327             #8B8386 LavenderBlush4
328             #B03060 maroon
329             #CD6090 HotPink3
330             #CD3278 VioletRed3
331             #FF3E96 VioletRed1
332             #EE3A8C VioletRed2
333             #8B2252 VioletRed4
334             #EE6AA7 HotPink2
335             #FF6EB4 HotPink1
336             #8B3A62 HotPink4
337             #FF69B4 HotPink
338             #FF1493 DeepPink
339             #FF1493 DeepPink1
340             #EE1289 DeepPink2
341             #CD1076 DeepPink3
342             #8B0A50 DeepPink4
343             #FF34B3 maroon1
344             #EE30A7 maroon2
345             #CD2990 maroon3
346             #8B1C62 maroon4
347             #C71585 MediumVioletRed
348             #D02090 VioletRed
349             #EE7AE9 orchid2
350             #DA70D6 orchid
351             #FF83FA orchid1
352             #CD69C9 orchid3
353             #8B4789 orchid4
354             #FFE1FF thistle1
355             #EED2EE thistle2
356             #FFBBFF plum1
357             #EEAEEE plum2
358             #D8BFD8 thistle
359             #CDB5CD thistle3
360             #DDA0DD plum
361             #EE82EE violet
362             #CD96CD plum3
363             #8B7B8B thistle4
364             #FF00FF fuchsia
365             #FF00FF magenta
366             #FF00FF magenta1
367             #8B668B plum4
368             #EE00EE magenta2
369             #CD00CD magenta3
370             #8B008B DarkMagenta
371             #8B008B magenta4
372             #800080 purple
373             #BA55D3 MediumOrchid
374             #E066FF MediumOrchid1
375             #D15FEE MediumOrchid2
376             #B452CD MediumOrchid3
377             #7A378B MediumOrchid4
378             #9400D3 DarkViolet
379             #9932CC DarkOrchid
380             #BF3EFF DarkOrchid1
381             #9A32CD DarkOrchid3
382             #B23AEE DarkOrchid2
383             #68228B DarkOrchid4
384             #A020F0 purple
385             #4B0082 indigo
386             #8A2BE2 BlueViolet
387             #912CEE purple2
388             #7D26CD purple3
389             #551A8B purple4
390             #9B30FF purple1
391             #9370DB MediumPurple
392             #AB82FF MediumPurple1
393             #9F79EE MediumPurple2
394             #8968CD MediumPurple3
395             #5D478B MediumPurple4
396             #483D8B DarkSlateBlue
397             #8470FF LightSlateBlue
398             #7B68EE MediumSlateBlue
399             #6A5ACD SlateBlue
400             #836FFF SlateBlue1
401             #7A67EE SlateBlue2
402             #6959CD SlateBlue3
403             #473C8B SlateBlue4
404             #F8F8FF GhostWhite
405             #E6E6FA lavender
406             #0000FF blue
407             #0000FF blue1
408             #0000EE blue2
409             #0000CD blue3
410             #0000CD MediumBlue
411             #00008B blue4
412             #00008B DarkBlue
413             #191970 MidnightBlue
414             #000080 navy
415             #000080 NavyBlue
416             #4169E1 RoyalBlue
417             #4876FF RoyalBlue1
418             #436EEE RoyalBlue2
419             #3A5FCD RoyalBlue3
420             #27408B RoyalBlue4
421             #6495ED CornflowerBlue
422             #B0C4DE LightSteelBlue
423             #CAE1FF LightSteelBlue1
424             #BCD2EE LightSteelBlue2
425             #A2B5CD LightSteelBlue3
426             #6E7B8B LightSteelBlue4
427             #6C7B8B SlateGray4
428             #C6E2FF SlateGray1
429             #B9D3EE SlateGray2
430             #9FB6CD SlateGray3
431             #778899 LightSlateGray
432             #778899 LightSlateGrey
433             #708090 SlateGray
434             #708090 SlateGrey
435             #1E90FF DodgerBlue
436             #1E90FF DodgerBlue1
437             #1C86EE DodgerBlue2
438             #104E8B DodgerBlue4
439             #1874CD DodgerBlue3
440             #F0F8FF AliceBlue
441             #36648B SteelBlue4
442             #4682B4 SteelBlue
443             #63B8FF SteelBlue1
444             #5CACEE SteelBlue2
445             #4F94CD SteelBlue3
446             #4A708B SkyBlue4
447             #87CEFF SkyBlue1
448             #7EC0EE SkyBlue2
449             #6CA6CD SkyBlue3
450             #87CEFA LightSkyBlue
451             #607B8B LightSkyBlue4
452             #B0E2FF LightSkyBlue1
453             #A4D3EE LightSkyBlue2
454             #8DB6CD LightSkyBlue3
455             #87CEEB SkyBlue
456             #9AC0CD LightBlue3
457             #00BFFF DeepSkyBlue
458             #00BFFF DeepSkyBlue1
459             #00B2EE DeepSkyBlue2
460             #00688B DeepSkyBlue4
461             #009ACD DeepSkyBlue3
462             #BFEFFF LightBlue1
463             #B2DFEE LightBlue2
464             #ADD8E6 LightBlue
465             #68838B LightBlue4
466             #B0E0E6 PowderBlue
467             #98F5FF CadetBlue1
468             #8EE5EE CadetBlue2
469             #7AC5CD CadetBlue3
470             #53868B CadetBlue4
471             #00F5FF turquoise1
472             #00E5EE turquoise2
473             #00C5CD turquoise3
474             #00868B turquoise4
475             #5F9EA0 cadet blue
476             #5F9EA0 CadetBlue
477             #00CED1 DarkTurquoise
478             #F0FFFF azure
479             #F0FFFF azure1
480             #E0FFFF LightCyan
481             #E0FFFF LightCyan1
482             #E0EEEE azure2
483             #D1EEEE LightCyan2
484             #BBFFFF PaleTurquoise1
485             #AFEEEE PaleTurquoise
486             #AEEEEE PaleTurquoise2
487             #97FFFF DarkSlateGray1
488             #C1CDCD azure3
489             #B4CDCD LightCyan3
490             #8DEEEE DarkSlateGray2
491             #96CDCD PaleTurquoise3
492             #79CDCD DarkSlateGray3
493             #838B8B azure4
494             #7A8B8B LightCyan4
495             #00FFFF aqua
496             #00FFFF cyan
497             #00FFFF cyan1
498             #668B8B PaleTurquoise4
499             #00EEEE cyan2
500             #528B8B DarkSlateGray4
501             #00CDCD cyan3
502             #008B8B cyan4
503             #008B8B DarkCyan
504             #008080 teal
505             #2F4F4F DarkSlateGray
506             #2F4F4F DarkSlateGrey
507             #48D1CC MediumTurquoise
508             #20B2AA LightSeaGreen
509             #40E0D0 turquoise
510             #458B74 aquamarine4
511             #7FFFD4 aquamarine
512             #7FFFD4 aquamarine1
513             #76EEC6 aquamarine2
514             #66CDAA aquamarine3
515             #66CDAA MediumAquamarine
516             #00FA9A MediumSpringGreen
517             #F5FFFA MintCream
518             #00FF7F SpringGreen
519             #00FF7F SpringGreen1
520             #00EE76 SpringGreen2
521             #00CD66 SpringGreen3
522             #008B45 SpringGreen4
523             #3CB371 MediumSeaGreen
524             #2E8B57 SeaGreen
525             #43CD80 SeaGreen3
526             #54FF9F SeaGreen1
527             #2E8B57 SeaGreen4
528             #4EEE94 SeaGreen2
529             #32814B MediumForestGreen
530             #F0FFF0 honeydew
531             #F0FFF0 honeydew1
532             #E0EEE0 honeydew2
533             #C1FFC1 DarkSeaGreen1
534             #B4EEB4 DarkSeaGreen2
535             #9AFF9A PaleGreen1
536             #98FB98 PaleGreen
537             #C1CDC1 honeydew3
538             #90EE90 LightGreen
539             #90EE90 PaleGreen2
540             #9BCD9B DarkSeaGreen3
541             #8FBC8F DarkSeaGreen
542             #7CCD7C PaleGreen3
543             #838B83 honeydew4
544             #00FF00 green1
545             #00FF00 lime
546             #32CD32 LimeGreen
547             #698B69 DarkSeaGreen4
548             #00EE00 green2
549             #548B54 PaleGreen4
550             #00CD00 green3
551             #228B22 ForestGreen
552             #008B00 green4
553             #008000 green
554             #006400 DarkGreen
555             #7CFC00 LawnGreen
556             #7FFF00 chartreuse
557             #7FFF00 chartreuse1
558             #76EE00 chartreuse2
559             #66CD00 chartreuse3
560             #458B00 chartreuse4
561             #ADFF2F GreenYellow
562             #A2CD5A DarkOliveGreen3
563             #CAFF70 DarkOliveGreen1
564             #BCEE68 DarkOliveGreen2
565             #6E8B3D DarkOliveGreen4
566             #556B2F DarkOliveGreen
567             #6B8E23 OliveDrab
568             #C0FF3E OliveDrab1
569             #B3EE3A OliveDrab2
570             #9ACD32 OliveDrab3
571             #9ACD32 YellowGreen
572             #698B22 OliveDrab4
573             #FFFFF0 ivory
574             #FFFFF0 ivory1
575             #FFFFE0 LightYellow
576             #FFFFE0 LightYellow1
577             #F5F5DC beige
578             #EEEEE0 ivory2
579             #FAFAD2 LightGoldenrodYellow
580             #EEEED1 LightYellow2
581             #CDCDC1 ivory3
582             #CDCDB4 LightYellow3
583             #8B8B83 ivory4
584             #8B8B7A LightYellow4
585             #FFFF00 yellow
586             #FFFF00 yellow1
587             #EEEE00 yellow2
588             #CDCD00 yellow3
589             #8B8B00 yellow4
590             #808000 olive
591             #BDB76B DarkKhaki
592             #EEE685 khaki2
593             #8B8970 LemonChiffon4
594             #FFF68F khaki1
595             #CDC673 khaki3
596             #8B864E khaki4
597             #EEE8AA PaleGoldenrod
598             #FFFACD LemonChiffon
599             #FFFACD LemonChiffon1
600             #F0E68C khaki
601             #CDC9A5 LemonChiffon3
602             #EEE9BF LemonChiffon2
603             #D1C166 MediumGoldenRod
604             #8B8878 cornsilk4
605             #FFD700 gold
606             #FFD700 gold1
607             #EEC900 gold2
608             #CDAD00 gold3
609             #8B7500 gold4
610             #EEDD82 LightGoldenrod
611             #8B814C LightGoldenrod4
612             #FFEC8B LightGoldenrod1
613             #CDBE70 LightGoldenrod3
614             #EEDC82 LightGoldenrod2
615             #CDC8B1 cornsilk3
616             #EEE8CD cornsilk2
617             #FFF8DC cornsilk
618             #FFF8DC cornsilk1
619             #DAA520 goldenrod
620             #FFC125 goldenrod1
621             #EEB422 goldenrod2
622             #CD9B1D goldenrod3
623             #8B6914 goldenrod4
624             #B8860B DarkGoldenrod
625             #FFB90F DarkGoldenrod1
626             #EEAD0E DarkGoldenrod2
627             #CD950C DarkGoldenrod3
628             #8B6508 DarkGoldenrod4
629             #FFFAF0 FloralWhite
630             #EED8AE wheat2
631             #FDF5E6 OldLace
632             #F5DEB3 wheat
633             #FFE7BA wheat1
634             #CDBA96 wheat3
635             #FFA500 orange
636             #FFA500 orange1
637             #EE9A00 orange2
638             #CD8500 orange3
639             #8B5A00 orange4
640             #8B7E66 wheat4
641             #FFE4B5 moccasin
642             #FFEFD5 PapayaWhip
643             #CDB38B NavajoWhite3
644             #FFEBCD BlanchedAlmond
645             #FFDEAD NavajoWhite
646             #FFDEAD NavajoWhite1
647             #EECFA1 NavajoWhite2
648             #8B795E NavajoWhite4
649             #8B8378 AntiqueWhite4
650             #FAEBD7 AntiqueWhite
651             #D2B48C tan
652             #8B7D6B bisque4
653             #DEB887 burlywood
654             #EEDFCC AntiqueWhite2
655             #FFD39B burlywood1
656             #CDAA7D burlywood3
657             #EEC591 burlywood2
658             #FFEFDB AntiqueWhite1
659             #8B7355 burlywood4
660             #CDC0B0 AntiqueWhite3
661             #FF8C00 DarkOrange
662             #EED5B7 bisque2
663             #FFE4C4 bisque
664             #FFE4C4 bisque1
665             #CDB79E bisque3
666             #FF7F00 DarkOrange1
667             #FAF0E6 linen
668             #EE7600 DarkOrange2
669             #CD6600 DarkOrange3
670             #8B4500 DarkOrange4
671             #CD853F peru
672             #FFA54F tan1
673             #EE9A49 tan2
674             #CD853F tan3
675             #8B5A2B tan4
676             #FFDAB9 PeachPuff
677             #FFDAB9 PeachPuff1
678             #8B7765 PeachPuff4
679             #EECBAD PeachPuff2
680             #CDAF95 PeachPuff3
681             #F4A460 SandyBrown
682             #8B8682 seashell4
683             #EEE5DE seashell2
684             #CDC5BF seashell3
685             #D2691E chocolate
686             #FF7F24 chocolate1
687             #EE7621 chocolate2
688             #CD661D chocolate3
689             #8B4513 chocolate4
690             #8B4513 SaddleBrown
691             #FFF5EE seashell
692             #FFF5EE seashell1
693             #8B4726 sienna4
694             #A0522D sienna
695             #FF8247 sienna1
696             #EE7942 sienna2
697             #CD6839 sienna3
698             #CD8162 LightSalmon3
699             #FFA07A LightSalmon
700             #FFA07A LightSalmon1
701             #8B5742 LightSalmon4
702             #EE9572 LightSalmon2
703             #FF7F50 coral
704             #FF4500 OrangeRed
705             #FF4500 OrangeRed1
706             #EE4000 OrangeRed2
707             #CD3700 OrangeRed3
708             #8B2500 OrangeRed4
709             #E9967A DarkSalmon
710             #FF8C69 salmon1
711             #EE8262 salmon2
712             #CD7054 salmon3
713             #8B4C39 salmon4
714             #FF7256 coral1
715             #EE6A50 coral2
716             #CD5B45 coral3
717             #8B3E2F coral4
718             #8B3626 tomato4
719             #FF6347 tomato
720             #FF6347 tomato1
721             #EE5C42 tomato2
722             #CD4F39 tomato3
723             #8B7D7B MistyRose4
724             #EED5D2 MistyRose2
725             #FFE4E1 MistyRose
726             #FFE4E1 MistyRose1
727             #FA8072 salmon
728             #CDB7B5 MistyRose3
729             #FFFFFF white
730             #FFFFFF gray100
731             #FFFFFF grey100
732             #FFFFFF grey100
733             #FCFCFC gray99
734             #FCFCFC grey99
735             #FAFAFA gray98
736             #FAFAFA grey98
737             #F7F7F7 gray97
738             #F7F7F7 grey97
739             #F5F5F5 gray96
740             #F5F5F5 grey96
741             #F5F5F5 WhiteSmoke
742             #F2F2F2 gray95
743             #F2F2F2 grey95
744             #F0F0F0 gray94
745             #F0F0F0 grey94
746             #EDEDED gray93
747             #EDEDED grey93
748             #EBEBEB gray92
749             #EBEBEB grey92
750             #E8E8E8 gray91
751             #E8E8E8 grey91
752             #E5E5E5 gray90
753             #E5E5E5 grey90
754             #E3E3E3 gray89
755             #E3E3E3 grey89
756             #E0E0E0 gray88
757             #E0E0E0 grey88
758             #DEDEDE gray87
759             #DEDEDE grey87
760             #DCDCDC gainsboro
761             #DBDBDB gray86
762             #DBDBDB grey86
763             #D9D9D9 gray85
764             #D9D9D9 grey85
765             #D6D6D6 gray84
766             #D6D6D6 grey84
767             #D4D4D4 gray83
768             #D4D4D4 grey83
769             #D3D3D3 LightGray
770             #D3D3D3 LightGrey
771             #D1D1D1 gray82
772             #D1D1D1 grey82
773             #CFCFCF gray81
774             #CFCFCF grey81
775             #CCCCCC gray80
776             #CCCCCC grey80
777             #C9C9C9 gray79
778             #C9C9C9 grey79
779             #C7C7C7 gray78
780             #C7C7C7 grey78
781             #C4C4C4 gray77
782             #C4C4C4 grey77
783             #C2C2C2 gray76
784             #C2C2C2 grey76
785             #C0C0C0 silver
786             #BFBFBF gray75
787             #BFBFBF grey75
788             #BEBEBE gray
789             #BEBEBE grey
790             #BDBDBD gray74
791             #BDBDBD grey74
792             #BABABA gray73
793             #BABABA grey73
794             #B8B8B8 gray72
795             #B8B8B8 grey72
796             #B5B5B5 gray71
797             #B5B5B5 grey71
798             #B3B3B3 gray70
799             #B3B3B3 grey70
800             #B0B0B0 gray69
801             #B0B0B0 grey69
802             #ADADAD gray68
803             #ADADAD grey68
804             #ABABAB gray67
805             #ABABAB grey67
806             #A9A9A9 DarkGray
807             #A9A9A9 DarkGrey
808             #A8A8A8 gray66
809             #A8A8A8 grey66
810             #A6A6A6 gray65
811             #A6A6A6 grey65
812             #A3A3A3 gray64
813             #A3A3A3 grey64
814             #A1A1A1 gray63
815             #A1A1A1 grey63
816             #9E9E9E gray62
817             #9E9E9E grey62
818             #9C9C9C gray61
819             #9C9C9C grey61
820             #999999 gray60
821             #999999 grey60
822             #969696 gray59
823             #969696 grey59
824             #949494 gray58
825             #949494 grey58
826             #919191 gray57
827             #919191 grey57
828             #8F8F8F gray56
829             #8F8F8F grey56
830             #8C8C8C gray55
831             #8C8C8C grey55
832             #8A8A8A gray54
833             #8A8A8A grey54
834             #878787 gray53
835             #878787 grey53
836             #858585 gray52
837             #858585 grey52
838             #828282 gray51
839             #828282 grey51
840             #808080 fractal
841             #7F7F7F gray50
842             #7F7F7F grey50
843             #7E7E7E gray
844             #7D7D7D gray49
845             #7D7D7D grey49
846             #7A7A7A gray48
847             #7A7A7A grey48
848             #787878 gray47
849             #787878 grey47
850             #757575 gray46
851             #757575 grey46
852             #737373 gray45
853             #737373 grey45
854             #707070 gray44
855             #707070 grey44
856             #6E6E6E gray43
857             #6E6E6E grey43
858             #6B6B6B gray42
859             #6B6B6B grey42
860             #696969 DimGray
861             #696969 DimGrey
862             #696969 gray41
863             #696969 grey41
864             #666666 gray40
865             #666666 grey40
866             #636363 gray39
867             #636363 grey39
868             #616161 gray38
869             #616161 grey38
870             #5E5E5E gray37
871             #5E5E5E grey37
872             #5C5C5C gray36
873             #5C5C5C grey36
874             #595959 gray35
875             #595959 grey35
876             #575757 gray34
877             #575757 grey34
878             #545454 gray33
879             #545454 grey33
880             #525252 gray32
881             #525252 grey32
882             #4F4F4F gray31
883             #4F4F4F grey31
884             #4D4D4D gray30
885             #4D4D4D grey30
886             #4A4A4A gray29
887             #4A4A4A grey29
888             #474747 gray28
889             #474747 grey28
890             #454545 gray27
891             #454545 grey27
892             #424242 gray26
893             #424242 grey26
894             #404040 gray25
895             #404040 grey25
896             #3D3D3D gray24
897             #3D3D3D grey24
898             #3B3B3B gray23
899             #3B3B3B grey23
900             #383838 gray22
901             #383838 grey22
902             #363636 gray21
903             #363636 grey21
904             #333333 gray20
905             #333333 grey20
906             #303030 gray19
907             #303030 grey19
908             #2E2E2E gray18
909             #2E2E2E grey18
910             #2B2B2B gray17
911             #2B2B2B grey17
912             #292929 gray16
913             #292929 grey16
914             #262626 gray15
915             #262626 grey15
916             #242424 gray14
917             #242424 grey14
918             #212121 gray13
919             #212121 grey13
920             #1F1F1F gray12
921             #1F1F1F grey12
922             #1C1C1C gray11
923             #1C1C1C grey11
924             #1A1A1A gray10
925             #1A1A1A grey10
926             #171717 gray9
927             #171717 grey9
928             #141414 gray8
929             #141414 grey8
930             #121212 gray7
931             #121212 grey7
932             #0F0F0F gray6
933             #0F0F0F grey6
934             #0D0D0D gray5
935             #0D0D0D grey5
936             #0A0A0A gray4
937             #0A0A0A grey4
938             #080808 gray3
939             #080808 grey3
940             #050505 gray2
941             #050505 grey2
942             #030303 gray1
943             #030303 grey1
944             #000000 black
945             #000000 gray0
946             #000000 grey0
947             #000000 opaque';
948              
949 0           my @lines = split (/\n/, $colors_text);
950 0           my %colors;
951 0           foreach (@lines){ #load all known color names into $image->{preset_colors}
952 0           chomp;
953 0           my ($html, $human_name) = split(/\t/,$_);
954 0           $colors{$human_name} = $html;
955             #~ #print $image -> {preset_colors}{$human_name} ,"-> $human_name\n"
956             }
957            
958             #~ print foreach sort keys %colors;
959 0           return %colors;
960             }