<?php $delta = 24; $reduce_brightness = true; $reduce_gradients = true; $num_results = 20; include_once "colors.inc.php"; $ex = new GetMostCommonColors(); $colors = $ex->Get_Color("test.jpg", $num_results, $reduce_brightness, $reduce_gradients, $delta); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <head> <title>Image Color Extraction</title> <style type="text/css"> * {margin: 0; padding: 0} body {text-align: center;} div#wrap {margin: 10px auto; text-align: left; position: relative; width: 500px;} img {width: 200px;} table {border: solid #000 1px; border-collapse: collapse;} td {border: solid #000 1px; padding: 2px 5px; white-space: nowrap;} br {width: 100%; height: 1px; clear: both; } </style> </head> <body> <div id="wrap"> <form action="#" method="post" enctype="multipart/form-data"> <input type="file" name="imgFile" /> <input type="submit" name="action" value="Process" /> </form> <?php
case 'png': $source = imagecreatefrompng($image_name) or die("Bad file."); break; case 'GIF': $source = imagecreatefromgif($image_name) or die("Bad file."); break; case 'PNG': $source = imagecreatefrompng($image_name) or die("Bad file."); 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;
private function savePredominantColors() { // ALREADY SAVED $exist = q("select hex from predominantcolors where file_id = " . $this->itemId . " order by id"); if (!$exist) { // GET COLORS $delta = 16; $reduce_brightness = true; $reduce_gradients = true; $num_results = 10; $ex = new GetMostCommonColors(); $colors = $ex->Get_Color($this->RelPath, $num_results, $reduce_brightness, $reduce_gradients, $delta); $keys = array_keys($colors); // SAVE COLORS foreach ($keys as $color) { sq("insert into predominantcolors set file_id = " . $this->itemId . ", hex = '" . $color . "'"); $out[] = '<div class="predominantColors" style="float: left; margin: 4px; padding: 4px; border: 1px solid #000; width: 15px; height: 11px; background: #' . $color . '"></div>'; } } else { //$out[] = '<div style="clear: both;"></div>'; $out[] = '<div class="predominantColorsContainer">'; foreach ($exist as $color) { $out[] = '<div class="predominantColors" style="float: left; margin: 4px; padding: 4px; border: 1px solid #000; width: 15px; height: 11px; background: #' . $color['hex'] . '"></div>'; } $out[] = '</div>'; } return join('', $out); }
function getImageAnnotationMp7($id_media) { global $conn; $query = "SELECT * from " . EW_CONN_DB_MEDIA . ".media WHERE media.id_media = '{$id_media} '"; $rs_media = $conn->Execute($query); $xml_output = '<Mpeg7Fragment> <TextAnnotation>'; $image_name = $rs_media->fields('filename'); //scorro tutte le annotazioni all'interno dello shot $query = "SELECT *, ifnull(ct.value,'Other') as concepttype, ifnull(at.name,'Other') as type FROM " . EW_CONN_DB_MEDIA . ".annotations LEFT JOIN " . EW_CONN_DB_MEDIA . ".concepts as c ON (c.id_concepts = annotations.id_concepts) \n\t\t\t\t\t\t\tLEFT JOIN " . EW_CONN_DB_MEDIA . ".concept_types as ct ON (c.id_concept_types = ct.id_concept_types) \n\t\t\t\t\t\t\tLEFT JOIN " . EW_CONN_DB_MEDIA . ".annotations_types as at ON (annotations.id_annotations_types = at.id_annotations_types) \n\t\t\t\t\t\t\tWHERE annotations.id_media = '{$id_media}' and deleted = 0" . " AND (\nct.id_concept_types IS NULL\nOR ct.id_concept_types <>5\n)"; $rs_ann = $conn->Execute($query); while (!$rs_ann->EOF) { $row_ann = $rs_ann->fields; $xml_output .= '<FreeTextAnnotation type="' . $row_ann["type"] . '" concepttype="' . $row_ann["concepttype"] . '" >' . $row_ann["title"] . '</FreeTextAnnotation> '; $rs_ann->MoveNext(); } $xml_output .= '</TextAnnotation>'; include_once "colors.inc.php"; $ex = new GetMostCommonColors(); $ex->image = EW_ABS_MEDIA_PATH . "image/" . $image_name . ""; $colors = $ex->Get_Color(); $how_many = 1; $colors_key = array_keys($colors); global $main_colors; //echo "Trovati colori dominanti:<br>"; //var_dump($colors); for ($i = 0; $i < $how_many; $i++) { $string_dominant_color = $main_colors[$colors_key[$i]]; $xml_output .= "\n<Color type=\"DominantColor\" color=\"{$string_dominant_color}\" >" . $colors_key[$i] . "</Color>"; } $xml_output .= '</Mpeg7Fragment>'; //echo "Mpeg7 da inviare:<br>".$xml_output; return $xml_output; }
require_once BASE_PATH . '/assets/includes/session.php'; $skipInitialize = array('sessionDestroy'); // Action cases when the includes will be skipped require_once BASE_PATH . '/assets/includes/initialize.php'; require_once BASE_PATH . '/assets/includes/commands.php'; require_once BASE_PATH . '/assets/includes/init.member.php'; require_once BASE_PATH . '/assets/includes/security.inc.php'; require_once BASE_PATH . '/assets/includes/language.inc.php'; require_once BASE_PATH . '/assets/includes/cart.inc.php'; require_once BASE_PATH . '/assets/includes/affiliate.inc.php'; require_once BASE_PATH . '/assets/includes/header.inc.php'; require_once BASE_PATH . '/assets/includes/errors.php'; require_once BASE_PATH . '/assets/classes/imagetools.php'; require_once BASE_PATH . '/assets/classes/mediatools.php'; require_once BASE_PATH . '/assets/classes/colors.php'; $colorPalette = new GetMostCommonColors(); try { $x = 0; $mediaResult = mysqli_query($db, "SELECT * FROM {$dbinfo[pre]}media WHERE active = 1"); // Select the active media $mediaRows = mysqli_num_rows($mediaResult); while ($media = mysqli_fetch_assoc($mediaResult)) { $colorPaletteResult = mysqli_query($db, "SELECT * FROM {$dbinfo[pre]}color_palettes WHERE media_id = '{$media[media_id]}' ORDER BY cp_id"); $colorPaletteRows = mysqli_num_rows($colorPaletteResult); if (!$colorPaletteRows and $x < 10) { $mediaInfo = new mediaTools($media['media_id']); $folderInfo = $mediaInfo->getFolderInfoFromDB($media['folder_id']); $folderName = $mediaInfo->getFolderName(); $thumbInfo = $mediaInfo->getThumbInfoFromDB($media['media_id']); $path = BASE_PATH . "/assets/library/{$folderName}/thumbs/{$thumbInfo[thumb_filename]}"; // xxxxxx No encryption detection
exec("convert " . public_path() . $ASSET_SLUG . date('Y') . '/' . date('m') . '/' . date('d') . '/' . $newimg . " -resize 270x207! -gravity Center -crop 270x207+0+0 -quality 100% " . public_path() . $ASSET_SLUG . date('Y') . '/' . date('m') . '/' . date('d') . '/' . $newsmall); if (file_exists(public_path() . $ASSET_SLUG . date('Y') . '/' . date('m') . '/' . date('d') . '/' . $newthb)) { $getres = getimagesize(public_path() . $ASSET_SLUG . date('Y') . '/' . date('m') . '/' . date('d') . '/' . $newimg); $wallresolution = $getres[0] . "x" . $getres[1]; $flcalc = $getres[0] / $getres[1]; $flres = round($flcalc, 1); if ($flres == 1.3) { $iswide = 1; } else { $iswide = 2; } $colors = ''; $ex = ''; $wallcolors = ''; // Ambil Warna $ex = new GetMostCommonColors(); $colors = $ex->Get_Color(public_path() . $ASSET_SLUG . date('Y') . '/' . date('m') . '/' . date('d') . '/' . $newimg, $num_results, $reduce_brightness, $reduce_gradients, $delta); foreach ($colors as $hex => $count) { if ($count > 0 && $count <= $num_results) { $wallcolors .= $hex . " "; } } $wallfilesize = filesize(public_path() . $ASSET_SLUG . date('Y') . '/' . date('m') . '/' . date('d') . '/' . $newimg); // adding date to slug for easier db access $walldir = str_replace('-', '/', $walldate); // $wallpath = '/' . $dateslug . '/' . $newimg; $addwall = $mysqli->query("INSERT INTO wallpaper ( \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t`cat`, \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t`walltitle`, \t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t`wallslug`, \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t`walldir`,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t`wallresolution`, \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t`wallfilesize`, \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t`wallimg`, \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t`walldate`, \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t`walltags`, \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t`wallcolors`,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t`walllastview`,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t`walllastdownload`\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t) VALUES ( \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'" . $dirname . "', \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'" . ucwords($walltitle) . "', \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'" . $wallslug . "', \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'" . $walldir . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'" . $wallresolution . "', \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'" . $wallfilesize . "', \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'" . $newimg . "', \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'" . $walldatenow . "', \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'" . $walltags . "', \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'" . $wallcolors . "', \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'" . $walldate . "',\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'" . $walldate . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\t) "); @unlink(public_path() . "/uploads/" . $dirname . "/" . $filenya); echo "<div>" . ucwords($tfile) . "</div>"; echo "<div>" . $newimg . "</div>"; echo "<div>Category: " . $dirname . "</div>";
<?php include 'config.php'; session_start(); $qname = $_GET['Name']; echo $qname; $delta = 24; $reduce_brightness = true; $reduce_gradients = true; $num_results = 20; include_once "colors.inc.php"; $ex = new GetMostCommonColors(); $colors = $ex->Get_Color("test.jpg", $num_results, $reduce_brightness, $reduce_gradients, $delta); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <head> <title>Image Color Extraction</title> <style type="text/css"> * {margin: 0; padding: 0} body {text-align: center;} div#wrap {margin: 10px auto; text-align: left; position: relative; width: 500px;} img {width: 200px;} table {border: solid #000 1px; border-collapse: collapse;} td {border: solid #000 1px; padding: 2px 5px; white-space: nowrap;} br {width: 100%; height: 1px; clear: both; } </style> </head> <body> <div id="wrap"> <?php