コード例 #1
0
ファイル: image_adder.php プロジェクト: Apothems/naranai
         break;
     default:
         $source = imagecreatefromjpeg($image_name) or die("Bad file.");
         break;
 }
 imagecopyresampled($thumb, $source, 0, 0, 0, 0, $new_img_width, $new_img_height, $current_img_width, $current_img_height) or die("Bad reample?.");
 imagejpeg($thumb, $thumb_name, 90) or die("Create thumb file failed.");
 $ex = new GetMostCommonColors();
 $ex->image = $thumb;
 $colors = $ex->Get_Color();
 $how_many = 2;
 // zero based.
 $colors_key = array_keys($colors);
 $primary_color = color_to_name($colors_key[0]);
 $secondary_color = color_to_name($colors_key[1]);
 $tertiary_color = color_to_name($colors_key[2]);
 $ip = "255.255.255.255";
 $filesize = filesize($image_name);
 $note = "Linked in IRC by " . $username;
 switch ($username) {
     case "digiwombat":
         $user = 2;
         break;
     case "Alkenshel":
         $user = 16;
         break;
     case "Ci":
         $user = 4;
         break;
     case "Mastersage":
         $user = 5;
コード例 #2
0
         $source = imagecreatefromjpeg($image_name);
         break;
 }
 imagecopyresampled($thumb, $source, 0, 0, 0, 0, $new_img_width, $new_img_height, $current_img_width, $current_img_height);
 imagedestroy($source);
 imagejpeg($thumb, $thumb_name, 90);
 $ex = new GetMostCommonColors();
 $ex->image = $thumb;
 $colors = $ex->Get_Color();
 $how_many = 2;
 // zero based.
 $colors_key = array_keys($colors);
 $color_names = array();
 $color_names = file(dirname(__FILE__) . '/lib/color_names.json');
 for ($i = 0; $i <= 2; $i++) {
     $color_name_array[] = color_to_name($colors_key[$i]);
 }
 unset($names);
 $color_set = array();
 $primary = trim($color_name_array[0]);
 $secondary = trim($color_name_array[1]);
 $tertiary = trim($color_name_array[2]);
 $sqlhue = "SELECT `hue`, FIND_IN_SET(`hexadecimal`, '" . $primary . "," . $secondary . "," . $tertiary . "') FROM `colors` WHERE `hexadecimal` IN ('" . $primary . "', '" . $secondary . "', '" . $tertiary . "')";
 $gethue = mysql_query($sqlhue) or die(mysql_error());
 while ($runhue = mysql_fetch_assoc($gethue)) {
     $color_set[] = $runhue['hue'];
 }
 $sql = "INSERT INTO images(\n\t\t\t\t\t\t\t\t\t   owner_id,\n\t\t\t\t\t\t\t\t\t   owner_ip,\n\t\t\t\t\t\t\t\t\t   filename,\n\t\t\t\t\t\t\t\t\t   filesize,\n\t\t\t\t\t\t\t\t\t   hash,\n\t\t\t\t\t\t\t\t\t   ext,\n\t\t\t\t\t\t\t\t\t   width,\n\t\t\t\t\t\t\t\t\t   height,\n\t\t\t\t\t\t\t\t\t   posted,\n\t\t\t\t\t\t\t\t\t   primary_color,\n\t\t\t\t\t\t\t\t\t   secondary_color,\n\t\t\t\t\t\t\t\t\t   tertiary_color\n\t\t\t\t\t\t\t\t\t  )\n\t\t\t\t\t\t\t\tVALUES(\n\t\t\t\t\t\t\t\t\t   " . $user . ",\n\t\t\t\t\t\t\t\t\t   '" . $ip . "',\n\t\t\t\t\t\t\t\t\t   '" . $name . "',\n\t\t\t\t\t\t\t\t\t   " . $filesize . ",\n\t\t\t\t\t\t\t\t\t   '" . $hash . "',\n\t\t\t\t\t\t\t\t\t   '" . $ext . "',\n\t\t\t\t\t\t\t\t\t   " . $size[0] . ",\n\t\t\t\t\t\t\t\t\t   " . $size[1] . ",\n\t\t\t\t\t\t\t\t\t   '" . date('Y-m-d H:i:s') . "',\n\t\t\t\t\t\t\t\t\t   '" . strtolower($color_set[0]) . "',\n\t\t\t\t\t\t\t\t\t   '" . strtolower($color_set[1]) . "',\n\t\t\t\t\t\t\t\t\t   '" . strtolower($color_set[2]) . "'\n\t\t\t\t\t\t\t\t\t  )";
 mysql_query($sql);
 $id = mysql_insert_id();
 if ($group != "None" && $group != "") {