Bekijk de onderstaande video om te zien hoe je onze site als een web app op je startscherm installeert.
Opmerking: Deze functie is mogelijk niet beschikbaar in sommige browsers.
class Get_Photo {
private $Pdir = "images/photo/";
private $Idir = "images/info/";
private function Check_Dir($folder) {
if (!is_dir($folder)) {
//echo "no Dir<br>";
return false; // not a dir
} else {
//echo "Dir found<br>";
return true;
}
}
function img_resize( $tmpname, $size, $save_dir, $save_name, $maxisheight = 0 )
{
$save_dir .= ( substr($save_dir,-1) != "/") ? "/" : "";
if(!$this->Check_Dir($save_dir)) {
//create dir
if(!mkdir($save_dir, 0700, true)) {
echo "failed making dir: ".$save_dir;
}
}
$gis = getimagesize($tmpname);
$type = $gis[2];
switch($type)
{
case "1": $imorig = imagecreatefromgif($tmpname); break;
case "2": $imorig = imagecreatefromjpeg($tmpname);break;
case "3": $imorig = imagecreatefrompng($tmpname); break;
default: $imorig = imagecreatefromjpeg($tmpname);
}
$x = imagesx($imorig);
$y = imagesy($imorig);
$woh = (!$maxisheight)? $gis[0] : $gis[1] ;
if($woh <= $size)
{
$aw = $x;
$ah = $y;
}
else
{
if(!$maxisheight){
$aw = $size;
$ah = $size * $y / $x;
} else {
$aw = $size * $x / $y;
$ah = $size;
}
}
$im = imagecreatetruecolor($aw,$ah);
if (imagecopyresampled($im,$imorig , 0,0,0,0,$aw,$ah,$x,$y))
if (imagejpeg($im, $save_dir.$save_name))
return true;
else
return false;
}
/* Load all photos in the folder in a array */
Private function Load_Photos() {
if ($this->Check_Dir($this->Pdir)){
if ($handle = opendir($this->Pdir)) {
/* loop over the directory */
while (false !== ($file = readdir($handle))) {
if ($file == "." || $file == ".."){
} else
{
$names[] = $file;
}
}
return $names;
unset($names,$file);
} else {
return false;
}// end if/else $handler
}// end if Check_Dir
}// End Load_Photos
/* Filter_Photos takes a array
with the names of the photos in the folder "photo"
and a boolean to filter photos with or without a info file
true for with info-file
false for without info-file(admin)
return array name of images */
Private function Filter_Photos($phots,$info=true) {
$X = 0;
WHILE($X < COUNT($phots)) {
$dfile = explode('.',$phots[$X]);
if (file_exists($this->Idir.$dfile[0].".info")) {
$W_Photo[]= $phots[$X];
} else {
$N_Photo[]= $phots[$X];
}
$X++;
}
if($info) {
$S_Photo = $W_Photo;
} else {
$S_Photo = $N_Photo;
}
if(!isset($S_Photo)) {
return false;
} else{
return $S_Photo;
}
unset($photo,$S_Photo,$N_Photo,$W_Photo,$dfile);
}// End Filter_Photos
private function Photo_Size($photo) {
$x = 0;
WHILE ($x < count($photo)) {
list($width, $height) = getimagesize($this->Pdir.$photo[$x]);
$nw_photo[] = array( 'name' => $photo[$x],
'width' => $width,
'height' => $height);
$x++;
}
return $nw_photo;
unset($photo,$nw_photo,$x,$width,$height);
}
/* Returns array with names of photos and size(width/height)
and if $admin is false info
*/
public function Get_Images_Display($admin= true) {
$Photos = $this->Load_Photos();
if($Photos) {
$Rphoto = $this->Filter_Photos($Photos, $admin);
if($Rphoto){
$Out_Photo = $this->Photo_Size($Rphoto);
if($admin){
$Out_Photo = $this->Get_Photo_Info($Out_Photo);
}
return $Out_Photo;
} else {
return false;
}
} else {
return false;
}
unset($Photos,$W_Photo,$Out_Photo,$Rphoto);
// Return array with photo's'
}// End Get_Images_Display
public function Get_Photo_Info($photo) {
$x = 0;
while($x < count($photo)) {
$name = explode(".",$photo[$x]['name']);
$info =array('info' => file_get_contents($this->Idir.$name[0].'.info'));
$return[] = array_merge($photo[$x], $info);
$x++;
}
return $return;
// return content info-file
}// End Get_photo_info
public function Display_Images_No_Info() {
// Return array of photos without a info-file
}// End Display_Images_No_Info
}// End Class Get_Photo
We gebruiken essentiële cookies om deze site te laten werken, en optionele cookies om de ervaring te verbeteren.