/[colormatch]/trunk/export.php
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /trunk/export.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (hide annotations)
Sat Oct 2 23:24:01 2004 UTC (14 years, 9 months ago) by dpavlin
File size: 5224 byte(s)
imported original ColorMatch

1 dpavlin 1 <?
2     $dt = strftime("%D");
3     $tm = strftime("%T");
4     $dtm = str_replace("/","",$dt) ."-".str_replace(":","",$tm);
5     function HTMLtoCMYK($htmlcol) {
6     $q = str_replace("#","",$htmlcol);
7     $col = strtoupper($q);
8     $r = hexdec(substr($col,0,2));
9     $g = hexdec(substr($col,2,2));
10     $b = hexdec(substr($col,4,2));
11     $c = 255 - $r;
12     $m = 255 - $g;
13     $y = 255 - $b;
14     if ($c < $m) {
15     $k = $c;
16     } else {
17     $k = $m;
18     }
19     if ($y < $k) {
20     $k = $y;
21     }
22     if ($k > 0) {
23     $c = $c - $k;
24     $m = $m - $k;
25     $y = $y - $k;
26     }
27     $cmyk = array("c" => $c, "m" => $m, "y" => $y, "k" => $k);
28     return $cmyk;
29     }
30    
31    
32    
33     if($_POST["photoshop"]) {
34     // Export set of colors to photoshop .act format
35     // Colors are given as col0 - col8
36     header("Content-Type: application/octet-stream");
37     header('Content-Disposition: attachment; filename="'.$dtm.'-swatches.act"');
38    
39     for($i=0;$i<256;$i++) {
40     if($i<9) {
41     $v = "col".$i;
42     $q = $_POST[$v];
43     $r = str_replace("#","",$q);
44     $col = strtoupper($r);
45     $red = hexdec(substr($col,0,2));
46     $blue = hexdec(substr($col,2,2));
47     $green= hexdec(substr($col,4,2));
48     echo sprintf("%c%c%c",$red,$blue,$green);
49     }
50     else {
51     echo sprintf("%c%c%c",255,255,255);
52     }
53     }
54     }
55     else if ($_POST["illustrator"]) {
56     header("Content-Type: application/octet-stream");
57     header('Content-Disposition: attachment; filename="'.$dtm.'-swatches.ai"');
58     echo <<<_END_
59     %!PS-Adobe-3.0 EPSF-3.0
60     %%Creator: Adobe Illustrator(r) 6.0
61     %%For: (Twyst) (Colormatch Remix)
62     %%Title: ($dtm-swatches.ai)
63     %%CreationDate: ($dt) ($tm)
64     %%BoundingBox: 224 631 268 661
65     %%HiResBoundingBox: 224.065 631 268 660.5208
66     %%DocumentProcessColors: Black
67     %%DocumentFonts: Verdana
68     %%DocumentNeededResources: procset Adobe_level2_AI5 1.0 0
69     %%+ procset Adobe_typography_AI5 1.0 0
70     %%+ procset Adobe_screens_AI5 1.0 0
71     %%+ procset Adobe_blend_AI5 1.0 0
72     %%+ procset Adobe_Illustrator_AI6_vars Adobe_Illustrator_AI6
73     %%+ procset Adobe_Illustrator_AI5 1.0 0
74     %AI5_FileFormat 2.0
75     %AI3_ColorUsage: Color
76     %%AI6_ColorSeparationSet: 1 1 (AI6 Default Color Separation Set)
77     %%+ Options: 1 16 0 1 0 1 1 1 0 1 1 1 1 18 0 0 0 0 0 0 0 0 -1 -1
78     %%+ PPD: 1 21 0 0 60 45 2 2 1 0 0 1 0 0 0 0 0 0 0 0 0 0 ()
79     %AI3_TemplateBox: 306 396 306 396
80     %AI3_TileBox: 31 31 583 761
81     %AI3_DocumentPreview: None
82     %AI5_ArtSize: 612 792
83     %AI5_RulerUnits: 2
84     %AI5_ArtFlags: 1 0 0 1 0 0 0 1 0
85     %AI5_TargetResolution: 800
86     %AI5_NumLayers: 1
87     %AI5_OpenToView: -78 780 1 826 581 58 0 1 2 40
88     %AI5_OpenViewLayers: 1
89     %%EndComments
90     %%BeginProlog
91     %%EndProlog
92     %%BeginSetup
93     %AI5_BeginPalette
94     0 0 Pb
95     _END_;
96     for($i=0;$i<9;$i++) {
97     $v = "col".$i;
98     $q = $_POST[$v];
99     $r = str_replace("#","",$q);
100     $col = strtoupper($r);
101     $red = (hexdec(substr($col,0,2)) / 255);
102     $blue = (hexdec(substr($col,2,2)) / 255);
103     $green= (hexdec(substr($col,4,2)) /255);
104     echo "\n$red $blue $green Xa\nPc\n";
105     }
106     echo <<<_END_
107     PB
108     %AI5_EndPalette
109     %%EndSetup
110     %%Trailer
111     %%EOF
112     _END_;
113     }
114     else if ($_POST["newTheme"]) {
115     include("config.php");
116     $db = mysql_connect($dbhost,$dbuser,$dbpass);
117     mysql_select_db($dbtable);
118     $q = $_POST["col0"];
119     if($q == "#808080") { header("Location: http://color.twysted.net\n\n"); }
120     $r = str_replace("#","",$q);
121     $col = strtoupper($r);
122     $red = hexdec(substr($col,0,2));
123     $green = hexdec(substr($col,2,2));
124     $blue = hexdec(substr($col,4,2));
125     $n = addslashes($_POST["newthemename"]);
126     if(($n == "Theme Name") || ($n == "")) { $n = "Base Color: ".$_POST["col0"]; }
127     $sql = "insert into colorpick(name,basecol,approved) values('$n','$red,$green,$blue',1)";
128     $r = mysql_query($sql);
129     header("Location: http://color.twysted.net\n\n");
130     }
131     else if ($_POST["plaintext"]) {
132     echo <<<_END_
133     <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
134     "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
135     <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
136     <head>
137     <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
138     <meta name="description" content="" />
139     <meta name="keywords" content="" />
140     <meta name="robots" content="all" />
141     <meta name="author" content="Twyst" />
142     <title>ColorMatch Remix - Color List</title>
143     <style type="text/css">
144     body, html {
145     width: 100%;
146     background: rgb(230,230,230);
147     font-family: Trebuchet MS, Verdana, Helvetica, Arial, Sans-serif;
148     font-size: small;
149     }
150     </style>
151     </head>
152     <body>
153     <p>
154     _END_;
155     echo "<b>HTML colors</b><br />";
156     echo "<ol>";
157     for($i=0;$i<9;$i++) {
158     $v = "col".$i;
159     $q = $_POST[$v];
160     echo "<li> $q</li>\n";
161     }
162     echo "</ol>\n";
163     echo "<br /><br /><b>RGB Colors</b><br />";
164     echo "<ol>";
165     for($i=0;$i<9;$i++) {
166     $v = "col".$i;
167     $q = $_POST[$v];
168     $r = str_replace("#","",$q);
169     $col = strtoupper($r);
170     $red = hexdec(substr($col,0,2));
171     $green = hexdec(substr($col,2,2));
172     $blue = hexdec(substr($col,4,2));
173     echo "<li> rgb($red,$green,$blue);</li>\n";
174     }
175     echo "</ol>";
176     echo "<br /><br /><b>CMYK Colors</b><br />";
177     echo "<ol>";
178     for($i=0;$i<9;$i++) {
179     $v = "col".$i;
180     $q = $_POST[$v];
181     extract(HTMLtoCMYK($q));
182     echo "<li> cmyk($c,$m,$y,$k);</li>\n";
183     }
184     echo "</ol>";
185     echo "</p>\n</body>\n</html>";
186     }
187     ?>

  ViewVC Help
Powered by ViewVC 1.1.26