Problem z galeria

0

Witam mam problem z galeria czy można zrobić aby galerie ten robiła thumby z plików png .itp ?

<?php

if(empty($enclose)) { // Sprawdza, czy plik został dołączony
	die("Nie możesz otworzyć tego pliku!");
}

$picture = glob("pictures/*"); // Pobiera zdjęcia
$thumbnail = glob("thumbnails/*"); // Pobiera miniaturki

$number['photos'] = count($picture); // Liczba wszystkich zdjęć
$number['perpage'] = ($settings['cols']*$settings['rows']); // Liczba zdjęć na stronie
$number['pages'] = ceil($number['photos']/$number['perpage']); // Liczba stron

if(isset($_GET['action'])) { // Przepisanie akcji
	$action = $_GET['action'];
}
else {
	$action = "page";
}

if(isset($_GET['id'])) { // Pobiera id elementu (strony lub zdjęcia)
	$id = $_GET['id'];
}
else {
	$id = 1;
}

function makephoto($img) {
	global $settings;
	
	list($oldwidth, $oldheight) = getimagesize($img);
        
	if($oldwidth < $settings['imgsize'] && $oldheight < $settings['imgsize']) {
		$imgwidth = $oldwidth;
		$imgheight = $oldheight;
	}	           
	elseif($oldheight > $oldwidth) {
		$imgwidth = round((($oldwidth*$settings['imgsize'])/$oldheight));
		$imgheight = $settings['imgsize'];
	}
	else {
		$imgwidth = $settings['imgsize'];
		$imgheight = round((($oldheight*$settings['imgsize'])/$oldwidth));
	}
	
	$name = explode("/", $img);
	if(file_exists("../pictures/".$name[2]) == TRUE) {
		$short = explode(".", $name[2]);
		$prefix = "_".rand(100, 999);
		$newname = $short[0].$prefix."";
	}
	else {
		$newname = $name[2];
	}

$newimg = imagecreatetruecolor($imgwidth, $imgheight);
	$tempimg = imagecreatefromjpeg($img);
	imagecopyresampled($newimg, $tempimg, 0, 0, 0, 0, $imgwidth, $imgheight, $oldwidth, $oldheight);	
	imagejpeg($newimg, "../pictures/".$newname, 95);
	
	if($oldwidth < $settings['thumbsize'] && $oldheight < $settings['thumbsize']) {
		$thumbwidth = $oldwidth;
		$thumbheight = $oldheight;
	}	           
	elseif($oldheight > $oldwidth) {
		$thumbwidth = round((($oldwidth*$settings['thumbsize'])/$oldheight));
		$thumbheight = $settings['thumbsize'];
	}
	else {
		$thumbwidth = $settings['thumbsize'];
		$thumbheight = round((($oldheight*$settings['thumbsize'])/$oldwidth));
	}
	
	$newthumb = imagecreatetruecolor($thumbwidth, $thumbheight);
	$tempthumb = imagecreatefromjpeg($img);
	imagecopyresampled($newthumb, $tempthumb, 0, 0, 0, 0, $thumbwidth, $thumbheight, $oldwidth, $oldheight);	
	imagejpeg($newthumb, "../thumbnails/".$newname, 85);
	
	unlink("../upload/".$name[2]);
	
	echo "Przetwarzanie <em>".$name[2]."</em>... OK!<br />";
	
}

function rename_to_jpg($x) {
	
	$x = str_replace(".JPG", ".jpg", $x);
	$x = str_replace(".jpeg", ".jpg", $x);
	$x = str_replace(".JPEG", ".jpg", $x);
	$x = str_replace(".PNG", ".jpg", $x);
	$x = str_replace(".png", ".jpg", $x);
		
	return $x;
		
}

function rename_uploaded() {
	
	$upload = glob("../upload/*");
	
	for($i = 0; $i < count($upload); $i++) {
		
		rename($upload[$i], rename_to_jpg($upload[$i]));
		
	}
	
}
0

Można.

1 użytkowników online, w tym zalogowanych: 0, gości: 1