image_save_uploaded_to_file($file, $att_type, $table, $id)"; $filtnamn=$file['tmp_name']; $filnamn=$file['name']; $filtyp=$file['type']; $fil=fopen($file['tmp_name'], "rb"); $filesize=$file['size']; if($prop=getimagesize($file['tmp_name'])) { //Om det är en bild $fildata=fread($fil, $filesize); $fildata=addslashes($fildata); $thmb=$fildata; //Lägg undan filen på servern if(!file_exists($path)) mkdir($path); move_uploaded_file($filtnamn, "$path/$filename"); //Ändra storleken om den är för stor image_resize($path, $filename, 700, 500, "$path/$filename"); image_resize($path, $filename, 150, 150, "$path/$tfilename"); } else { define('ERROR', "The uploaded file doesn't seem to be a valid image"); } } else add_error("The uploaded file doesn't seem to be a valid image"); } function image_remove_from_file($att_type, $table, $id) { //echo "
image_remove_from_file($att_type, $table, $id)"; //Ta bort filen på servern $uppath=IMG_UP_PATH."/".$_SESSION["IS_Username"]; $filename=$att_type."_".$id.".png"; $tfilename=$att_type."_".$id."_thmb.png"; unlink("$uppath/$filename"); unlink("$uppath/$tfilename"); //Fixa referens i databasen $sql="UPDATE ".sql_safe($table)." SET img_url=NULL, thmb=NULL WHERE id=".sql_safe($id).";"; //echo "
$sql"; mysql_query($sql); define('MESS', "Image has been removed"); } function image_Load_url_Jpeg ($imgname) { $im = ImageCreateFromJPEG ($imgname); /* Attempt to open */ if (!$im) { /* See if it failed */ $im = ImageCreate (150, 30); /* Create a blank image */ $bgc = ImageColorAllocate ($im, 255, 255, 255); $tc = ImageColorAllocate ($im, 0, 0, 0); ImageFilledRectangle ($im, 0, 0, 150, 30, $bgc); /* Output an errmsg */ ImageString ($im, 1, 5, 5, "Error $imgname", $tc); } return $im; } function image_save_url_to_file($img_url, $att_type, $table, $id) { //echo "
---image_save_url_to_file(".$img_url.", ".$att_type.", ".$id.")"; //Sätt iordning sökvägar och sånt $uppath=IMG_UP_PATH."/".$_SESSION["IS_Username"]; $filename=$att_type."_".$id.".png"; $tfilename=$att_type."_".$id."_thmb.png"; //kolla så att mappen finns if(!file_exists($uppath)) mkdir($uppath); // initialize the image class $image = new GetImage; // just an image URL $image->source = $img_url; $image->save_to = "$uppath/"; // with trailing slash at the end $image->dest_name = $filename; $image->set_extension = ".png"; $get = $image->download('curl'); // using GD if($get) { define('MESS','The image has been saved.'); } else { define('ERROR','Something went wrong with your image!'); } //Ändra storleken om den är för stor image_resize($uppath, $filename, 700, 500, "$uppath/$filename"); image_resize($uppath, $filename, 150, 150, "$uppath/$tfilename"); //Fixa referens i databasen $sql="UPDATE $table SET img_url='".IMG_PATH."/".$_SESSION["IS_Username"]."/$filename', thmb='".IMG_PATH."/".$_SESSION["IS_Username"]."/$tfilename' WHERE id=".sql_safe($id).";"; //echo "
$sql"; mysql_query($sql); } function image_resize($path, $img, $max_width, $max_height, $destination) { $size=64*1024*1024; ini_set('memory_limit', $size); //echo "
image_open_from_file($path/$img)"; $image = image_open_from_file("$path/$img"); if ($image == false) { echo "

Unable to open image $path/$img for thumbcreation

"; return NULL; } else { //echo "

Creating thumbnail for $path/$img

"; // get originalsize of image $im = $image; $iwidth = imagesx($im); $iheight = imagesy($im); if($iwidth>$max_width) { // Set thumbnail-width to max_width pixel $imgw = $iwidth * ($max_width/$iwidth); // calculate thumbnail-height from given width to maintain aspect ratio $imgh = $iheight * ($max_width/$iwidth); } else if($iheight>$max_height) { // Set thumbnail-width to max_width pixel $imgw = $iwidth * ($max_height/$iheight); // calculate thumbnail-height from given width to maintain aspect ratio $imgh = $iheight * ($max_height/$iheight); } else { $imgw = $iwidth; $imgh = $iheight; } // create new image using thumbnail-size $thumb=ImageCreateTrueColor($imgw,$imgh); //Skaffa om det finns genomskinlig färg imagecolortransparent ($thumb , imagecolortransparent($im)); imagefill($thumb,0,0,0xFF00FF); // copy original image to thumbnail imagecopyresized($thumb,$im,0,0,0,0,$imgw,$imgh,$iwidth,$iheight); //Lägg på "vattenmärke" //Hämta färg och invertera // $x=35; // $y=$imgh-12; // $diff=45; // $rgb=imagecolorat ( $thumb , $x , $y); // $gr = ($rgb >> 16) & 0xFF; // $gg = ($rgb >> 8) & 0xFF; // $gb = $rgb & 0xFF; // echo "
RGB: $gr $gg $gb"; // if(($gr+$gg+$gb)>(128*3)) // { // Gör mörkare // $r=(int)(($gr*$diff)/100); // $g=(int)(($gg*$diff)/100); // $b=(int)(($gb*$diff)/100); // } // else // { // Gör ljusare // $r=255-(int)(((255-$gr)*$diff)/100); // $g=255-(int)(((255-$gg)*$diff)/100); // $b=255-(int)(((255-$gb)*$diff)/100); // } // echo "
RGB: $r $g $b"; // $tc = ImageColorAllocate ($thumb, $r, $g, $b); // ImageString ($thumb, 3, 5, $imgh-30, user_get_name($_SESSION[PREFIX.'user_id']), $tc); // ImageString ($thumb, 3, 5, $imgh-15, "at DreamHorse.se", $tc); // $tc = ImageColorAllocate ($thumb, 255, 0, 0); // imagesetpixel ( $thumb , $x , $y , $tc); imagepng($thumb, $destination); // clean memory imagedestroy ($im); imagedestroy ($thumb); } } function image_create_thmb_db($table,$column,$width) { if($bb=mysql_query("SELECT id, $column FROM ".$_SESSION["IS_prefix"]."$table;")) { while($b=mysql_fetch_array($bb)) { if($b[$column]!=NULL) { $image =@imagecreatefromstring($b[$column]); if ($image==false) { echo "

Unable to open image $table/$column:$b[id] for thumbcreation

"; mysql_query("update ".$_SESSION["IS_prefix"]."$table set $column=NULL where id=$b[id]"); } else { // get originalsize of image $im = $image; $iwidth = imagesx($im); $iheight = imagesy($im); if($iwidth>$width) { // Set thumbnail-width to 100 pixel $imgw = $iwidth * ($width/$iwidth); // calculate thumbnail-height from given width to maintain aspect ratio $imgh = $iheight * ($width/$iwidth); } else { $imgw = $iwidth; $imgh = $iheight; } // create new image using thumbnail-size $thumb=ImageCreateTrueColor((int)$imgw,(int)$imgh); //Skaffa om det finns genomskinlig färg imagecolortransparent ($thumb , imagecolortransparent($im)); imagefill($thumb,0,0,0xFF00FF); // copy original image to thumbnail imagecopyresized($thumb,$im,0,0,0,0,(int)$imgw,(int)$imgh,(int)$iwidth,(int)$iheight); imagejpeg($thumb, $img."___temp.jpg"); $filesize=filesize($img."___temp.jpg"); $fil=fopen($img."___temp.jpg","rb"); $fildata=fread($fil, $filesize); $fildata=addslashes($fildata); fclose($fil); unlink($img."___temp.jpg"); // clean memory imagedestroy ($im); imagedestroy ($thumb); mysql_query("UPDATE ".$_SESSION["IS_prefix"]."$table SET $column='$fildata' WHERE id=$b[id];"); } } } } } function image_create_jpg_db($db,$column,$maxwidth) { //Skapar en jpeg från databasen if($bb=mysql_query("SELECT id, $column FROM ".$_SESSION["IS_prefix"]."$db;")) { while($b=mysql_fetch_array($bb)) { if($b[$column]!=NULL) { $im = @imagecreatefromstring($b[$column]); if($im == false) $im = @image_open_from_file("display_bmp.php?lista=$db&kolumn=$column&id=$b[id]"); if ($im == false) { echo "

Unable to open image $db/$column id:$b[id] for thumbcreation

"; } else { // get originalsize of image $iwidth = imagesx($im); $iheight = imagesy($im); if($iwidth>$maxwidth) { // Set thumbnail-width to 100 pixel $imgw = $iwidth * ($maxwidth/$iwidth); // calculate thumbnail-height from given width to maintain aspect ratio $imgh = $iheight * ($maxwidth/$iwidth); } else { $imgw = $iwidth; $imgh = $iheight; } // create new image using thumbnail-size $thumb=ImageCreateTrueColor((int)$imgw,(int)$imgh); //Skaffa om det finns genomskinlig färg imagecolortransparent ($thumb , imagecolortransparent($im)); imagefill($thumb,0,0,0xFF00FF); // copy original image to thumbnail imagecopyresized($thumb,$im,0,0,0,0,(int)$imgw,(int)$imgh,(int)$iwidth,(int)$iheight); imagejpeg($thumb, $img."___temp.jpg"); $filesize=filesize($img."___temp.jpg"); $fil=fopen($img."___temp.jpg","rb"); $fildata=fread($fil, $filesize); $fildata=addslashes($fildata); fclose($fil); unlink($img."___temp.jpg"); // clean memory imagedestroy ($im); imagedestroy ($thumb); mysql_query("UPDATE ".$_SESSION["IS_prefix"]."$db SET $column='$fildata' WHERE id=$b[id];"); } } } } } function image_open_from_file($file) { //KOLLA så att bilden inte är för STOR!!! $prop=getimagesize($file); if(/*filesize($file)>100*1024*1024) // || */($prop[0]*$prop[1])>(1024*1280*1024)) //*/ { DEFINE('MESS', "Image is too big"); return false; } // echo "

Öppnar $file...

"; # JPEG: $im = @imagecreatefromjpeg($file); if ($im !== false) { // echo "

Öppnade $file...

"; return $im; } else { $im = @imagecreatefromjpeg($file); if ($im !== false) { // echo "

Öppnade $file...

"; return $im; } } # PNG: $im = @imagecreatefrompng($file); if ($im !== false) { return $im; } # GIF: $im = @imagecreatefromgif($file); if ($im !== false) { return $im; } #BMP $im = @ImageCreateFromBMP("$file"); if ($im !== false) { return $im; } # GD File: $im = @imagecreatefromgd($file); if ($im !== false) { return $im; } # GD2 File: $im = @imagecreatefromgd2($file); if ($im !== false) { return $im; } # WBMP: $im = @imagecreatefromwbmp($file); if ($im !== false) { return $im; } # XBM: $im = @imagecreatefromxbm($file); if ($im !== false) { return $im; } # XPM: $im = @imagecreatefromxpm($file); if ($im !== false) { return $im; } # Try and load from string: $im = @imagecreatefromstring(file_get_contents($file)); if ($im !== false) { return $im; } echo "kunde inte öpnna $file"; return false; } function ImageCreateFromBMP($filename) { //Ouverture du fichier en mode binaire if (! $f1 = fopen($filename,"rb")) return FALSE; //1 : Chargement des ent?tes FICHIER $FILE = unpack("vfile_type/Vfile_size/Vreserved/Vbitmap_offset", fread($f1,14)); if ($FILE['file_type'] != 19778) return FALSE; //2 : Chargement des ent?tes BMP $BMP = unpack('Vheader_size/Vwidth/Vheight/vplanes/vbits_per_pixel'. '/Vcompression/Vsize_bitmap/Vhoriz_resolution'. '/Vvert_resolution/Vcolors_used/Vcolors_important', fread($f1,40)); $BMP['colors'] = pow(2,$BMP['bits_per_pixel']); if ($BMP['size_bitmap'] == 0) $BMP['size_bitmap'] = $FILE['file_size'] - $FILE['bitmap_offset']; $BMP['bytes_per_pixel'] = $BMP['bits_per_pixel']/8; $BMP['bytes_per_pixel2'] = ceil($BMP['bytes_per_pixel']); $BMP['decal'] = ($BMP['width']*$BMP['bytes_per_pixel']/4); $BMP['decal'] -= floor($BMP['width']*$BMP['bytes_per_pixel']/4); $BMP['decal'] = 4-(4*$BMP['decal']); if ($BMP['decal'] == 4) $BMP['decal'] = 0; //3 : Chargement des couleurs de la palette $PALETTE = array(); if ($BMP['colors'] < 16777216) { $PALETTE = unpack('V'.$BMP['colors'], fread($f1,$BMP['colors']*4)); } //4 : Cr?ation de l'image $IMG = fread($f1,$BMP['size_bitmap']); $VIDE = chr(0); $res = imagecreatetruecolor($BMP['width'],$BMP['height']); $P = 0; $Y = $BMP['height']-1; while ($Y >= 0) { $X=0; while ($X < $BMP['width']) { if ($BMP['bits_per_pixel'] == 24) $COLOR = unpack("V",substr($IMG,$P,3).$VIDE); elseif ($BMP['bits_per_pixel'] == 16) { $COLOR = unpack("n",substr($IMG,$P,2)); $COLOR[1] = $PALETTE[$COLOR[1]+1]; } elseif ($BMP['bits_per_pixel'] == 8) { $COLOR = unpack("n",$VIDE.substr($IMG,$P,1)); $COLOR[1] = $PALETTE[$COLOR[1]+1]; } elseif ($BMP['bits_per_pixel'] == 4) { $COLOR = unpack("n",$VIDE.substr($IMG,floor($P),1)); if (($P*2)%2 == 0) $COLOR[1] = ($COLOR[1] >> 4) ; else $COLOR[1] = ($COLOR[1] & 0x0F); $COLOR[1] = $PALETTE[$COLOR[1]+1]; } elseif ($BMP['bits_per_pixel'] == 1) { $COLOR = unpack("n",$VIDE.substr($IMG,floor($P),1)); if (($P*8)%8 == 0) $COLOR[1] = $COLOR[1] >>7; elseif (($P*8)%8 == 1) $COLOR[1] = ($COLOR[1] & 0x40)>>6; elseif (($P*8)%8 == 2) $COLOR[1] = ($COLOR[1] & 0x20)>>5; elseif (($P*8)%8 == 3) $COLOR[1] = ($COLOR[1] & 0x10)>>4; elseif (($P*8)%8 == 4) $COLOR[1] = ($COLOR[1] & 0x8)>>3; elseif (($P*8)%8 == 5) $COLOR[1] = ($COLOR[1] & 0x4)>>2; elseif (($P*8)%8 == 6) $COLOR[1] = ($COLOR[1] & 0x2)>>1; elseif (($P*8)%8 == 7) $COLOR[1] = ($COLOR[1] & 0x1); $COLOR[1] = $PALETTE[$COLOR[1]+1]; } else return FALSE; imagesetpixel($res,$X,$Y,$COLOR[1]); $X++; $P += $BMP['bytes_per_pixel']; } $Y--; $P+=$BMP['decal']; } //Fermeture du fichier fclose($f1); return $res; } function imagehue(&$image, $angle, $width, $height) { if($angle % 360 == 0) return; // $width = imagesx($image); // $height = imagesy($image); for($x = 0; $x < $width; $x++) { for($y = 0; $y < $height; $y++) { $rgb = imagecolorat($image, $x, $y); $r = ($rgb >> 16) & 0xFF; $g = ($rgb >> 8) & 0xFF; $b = $rgb & 0xFF; $alpha = ($rgb & 0x7F000000) >> 24; list($h, $s, $l) = rgb2hsl($r, $g, $b); $h += $angle / 360; if($h > 1) $h--; list($r, $g, $b) = hsl2rgb($h, $s, $l); imagesetpixel($image, $x, $y, imagecolorallocatealpha($image, $r, $g, $b, $alpha)); } } } function rgb2hsl($r, $g, $b) { $var_R = ($r / 255); $var_G = ($g / 255); $var_B = ($b / 255); $var_Min = min($var_R, $var_G, $var_B); $var_Max = max($var_R, $var_G, $var_B); $del_Max = $var_Max - $var_Min; $v = $var_Max; if ($del_Max == 0) { $h = 0; $s = 0; } else { $s = $del_Max / $var_Max; $del_R = ( ( ( $var_Max - $var_R ) / 6 ) + ( $del_Max / 2 ) ) / $del_Max; $del_G = ( ( ( $var_Max - $var_G ) / 6 ) + ( $del_Max / 2 ) ) / $del_Max; $del_B = ( ( ( $var_Max - $var_B ) / 6 ) + ( $del_Max / 2 ) ) / $del_Max; if ($var_R == $var_Max) $h = $del_B - $del_G; else if ($var_G == $var_Max) $h = ( 1 / 3 ) + $del_R - $del_B; else if ($var_B == $var_Max) $h = ( 2 / 3 ) + $del_G - $del_R; if ($h < 0) $h++; if ($h > 1) $h--; } return array($h, $s, $v); } function hsl2rgb($h, $s, $v) { if($s == 0) { $r = $g = $B = $v * 255; } else { $var_H = $h * 6; $var_i = floor( $var_H ); $var_1 = $v * ( 1 - $s ); $var_2 = $v * ( 1 - $s * ( $var_H - $var_i ) ); $var_3 = $v * ( 1 - $s * (1 - ( $var_H - $var_i ) ) ); if ($var_i == 0) { $var_R = $v ; $var_G = $var_3 ; $var_B = $var_1 ; } else if ($var_i == 1) { $var_R = $var_2 ; $var_G = $v ; $var_B = $var_1 ; } else if ($var_i == 2) { $var_R = $var_1 ; $var_G = $v ; $var_B = $var_3 ; } else if ($var_i == 3) { $var_R = $var_1 ; $var_G = $var_2 ; $var_B = $v ; } else if ($var_i == 4) { $var_R = $var_3 ; $var_G = $var_1 ; $var_B = $v ; } else { $var_R = $v ; $var_G = $var_1 ; $var_B = $var_2 ; } $r = $var_R * 255; $g = $var_G * 255; $B = $var_B * 255; } return array($r, $g, $B); } ?> Dreamhorse | Comment | Id 4822

where to buy cialis cheap in the usa states 2019 where to buy cialis over the counter where can i buy cialis over the counter at target.

is there a difference between viagra and generic sildenafil - is there a difference between viagra and generic sildenafil: generic viagra online canada pharmacy side effects of generic of viagra drug.

payday loans near me no credit check 30281 amg services payday loans quick payday loans without bank accounts online.

payday loans in canton ohio same day loans for bad credit guaranteed bad credit payday loans direct lenders.

Comment on this