1
Mods & Plugins (Releases & Support) / Re: [MOD] Histogram
« on: September 23, 2006, 12:53:27 PM »
Hallolo..
Also irgendwie funktionierts und irgendwie funktionierts auch wieder nicht....
Bei manchen Bildern wird ein "Histogramm" angelegt - bei anderen habe ich immer noch das weiße Blatt...
Das Histogramm das angezeigt wird sieht so aus:
http://www.entscheidende-augenblicke.de/details.php?image_id=86
oder so:
http://www.entscheidende-augenblicke.de/details.php?image_id=19
Hier der Code der Histo.php
...hier der Code der detais.php
...und hier der Code der details.html
Anmerkung: Die PHP-Markierung habe ich nur zur besseren farblichen Kennzeichnung hinzugefügt.
Vielleicht hat ja noch jemand ne Idee...
Grüßle
Udo
Also irgendwie funktionierts und irgendwie funktionierts auch wieder nicht....
Bei manchen Bildern wird ein "Histogramm" angelegt - bei anderen habe ich immer noch das weiße Blatt...
Das Histogramm das angezeigt wird sieht so aus:
http://www.entscheidende-augenblicke.de/details.php?image_id=86
oder so:
http://www.entscheidende-augenblicke.de/details.php?image_id=19
Hier der Code der Histo.php
Code: [Select]
<?php
// Histogram creation
// Created by Anton Sparrius (Spaz) 6/9/05 anton_spaz@yahoo.com
// Free to use and change, provided you keep these lines :)
if (isset($HTTP_GET_VARS['hist_image']) || isset($HTTP_POST_VARS['hist_image'])) {
$hist_image = (isset($HTTP_GET_VARS['hist_image'])) ? stripslashes(trim($HTTP_GET_VARS['hist_image'])) : stripslashes(trim($HTTP_POST_VARS['hist_image']));
}
else {
$hist_image = "";
}
if (isset($HTTP_GET_VARS['hist_path']) || isset($HTTP_POST_VARS['hist_path'])) {
$hist_path = (isset($HTTP_GET_VARS['hist_path'])) ? stripslashes(trim($HTTP_GET_VARS['hist_path'])) : stripslashes(trim($HTTP_POST_VARS['hist_path']));
}
else {
$hist_path = "";
}
if (isset($HTTP_GET_VARS['hist_file']) || isset($HTTP_POST_VARS['hist_file'])) {
$hist_file = (isset($HTTP_GET_VARS['hist_file'])) ? stripslashes(trim($HTTP_GET_VARS['hist_file'])) : stripslashes(trim($HTTP_POST_VARS['hist_file']));
}
else {
$hist_file = "";
}
// $hist_image = $_REQUEST['image'];
// $hist_path = $_REQUEST['filepath'];
// $hist_path = "albums/".$hist_path;
if (file_exists($hist_path.$hist_file)) {
$im=imagecreatefromPNG($hist_path . $hist_file);
imagePNG($im);
imagedestroy($im);
} else {
$im=imagecreatefromjpeg($hist_path.$hist_image);
for($i=0;$i<imagesx($im);$i+=2)
{
for($j=0;$j<imagesy($im);$j++)
{
$rrggbb=imagecolorsforindex ($im, imagecolorat($im,$i,$j));
$r[$rrggbb['red']]+=1;
$g[$rrggbb['green']]+=1;
$b[$rrggbb['blue']]+=1;
}
}
for ($i=0;$i<256;$i++)
{
$max[$i]=($r[$i]+$g[$i]+$b[$i])/3;
}
$max_value=max($max)/150;
$m[0]=max($r);
$m[1]=max($b);
$m[2]=max($g);
$max_rgb=max($m)/150;
$im_out = imageCreate (280, 164);
$background = imageColorAllocate($im_out,70,70,70);
$hist=ImageColorAllocate($im_out,0,0,0);
$white=ImageColorAllocate($im_out,143,143,134);
$red=ImageColorAllocate($im_out,255,0,0);
$green=ImageColorAllocate($im_out,0,255,0);
$blue=ImageColorAllocate($im_out,0,0,255);
$ry=107;
$gy=107;
$by=107;
for($i=0;$i<256;$i++)
{
imageLine($im_out, $i+14, 157, $i+14, 157-($max[$i]/$max_value),$white);
imageLine($im_out, $i+13, $ry, $i+14, 157-($r[$i]/$max_rgb), $red);
imageLine($im_out, $i+13, $gy, $i+14, 157-($g[$i]/$max_rgb), $green);
imageLine($im_out, $i+13, $by, $i+14, 157-($b[$i]/$max_rgb), $blue);
$ry=157-($r[$i]/$max_rgb);
$gy=157-($g[$i]/$max_rgb);
$by=157-($b[$i]/$max_rgb);
}
imageLine($im_out,13,158,270,158,$hist);
imageLine($im_out,13,6,270,6,$hist);
imageLine($im_out,13,6,13,158,$hist);
imageLine($im_out,270,6,270,158,$hist);
imagePNG($im_out,$hist_path . $hist_file);
imageDestroy($im);
imagedestroy($im_out);
$im=imagecreatefromPNG($hist_path . $hist_file);
imagePNG($im);
imagedestroy($im);
}
?>
...hier der Code der detais.php
Code: [Select]
<?php
//-----------------------------------------------------
//--- Show Image --------------------------------------
//-----------------------------------------------------
//--- Start Histogramm 27.02.2006 ----------------------
$hist_image = $image_row['image_media_file'] ;
$hist_file= "hist_".substr($hist_image,0,strlen($hist_image)-4).".png";
$hist_path = "data/histo/";
$ext = substr($hist_image, strpos($hist_image, ".")+1, strlen($hist_image));
$AutorisedImageType = array ("jpg", "jpeg", "JPG", "JPEG"); // Dateitypen für die das Histogramm gezeigt werden soll
if (in_array($ext, $AutorisedImageType)) {
$histogramm_image = "<img src='histo.php?hist_image=".$hist_image."&hist_file=".$hist_file."&hist_path=".$hist_path."' border=\"1\">";
} else {
$histogramm_image = REPLACE_EMPTY;
}
$site_template->register_vars(array(
"histogramm" => "Histogramm:",
"histogramm_image" => $histogramm_image
));
//--- Ende Histogramm 27.02.2006 ------------------------
?>
...und hier der Code der details.html
Code: [Select]
<?php
{if histogramm_image}
<tr>
<td valign="top" class="row1"><b>{histogramm}</b></td>
<td valign="top" class="row1">{histogramm_image}</td>
</tr>
{endif histogramm_image}
?>
Anmerkung: Die PHP-Markierung habe ich nur zur besseren farblichen Kennzeichnung hinzugefügt.
Vielleicht hat ja noch jemand ne Idee...
Grüßle
Udo