Hi guys and gals,
I want to add a transparency function to my image.php so I can upload transparency images I am using GD Thumbnail.
but dont know how to do it not so good in php
here is my Thumbnail.php
<?php
class Thumbnail {
var $errmsg;
var $error;
var $format;
var $fileName;
var $imageMeta;
var $currentDimensions;
var $newDimensions;
var $newImage;
var $oldImage;
var $workingImage;
var $percent;
var $maxWidth;
var $maxHeight;
function Thumbnail($fileName) {
if(!function_exists("gd_info")) {
echo 'You do not have the GD Library installed. This class requires the GD library to function properly.' . "\n";
echo 'visit http://us2.php.net/manual/en/ref.image.php for more information';
exit;
}
$this->errmsg = '';
$this->error = false;
$this->currentDimensions = array();
$this->newDimensions = array();
$this->fileName = $fileName;
$this->imageMeta = array();
$this->percent = 100;
$this->maxWidth = 0;
$this->maxHeight = 0;
if(!file_exists($this->fileName)) {
$this->errmsg = 'File not found';
$this->error = true;
}
elseif(!is_readable($this->fileName)) {
$this->errmsg = 'File is not readable';
$this->error = true;
}
if($this->error == false) {
if(stristr(strtolower($this->fileName),'.gif')) $this->format = 'GIF';
elseif(stristr(strtolower($this->fileName),'.jpg') || stristr(strtolower($this->fileName),'.jpeg')) $this->format = 'JPG';
elseif(stristr(strtolower($this->fileName),'.png')) $this->format = 'PNG';
else {
$this->errmsg = 'Unknown file format';
$this->error = true;
}
}
if($this->error == false) {
switch($this->format) {
case 'GIF':
$this->oldImage = ImageCreateFromGif($this->fileName);
break;
case 'JPG':
$this->oldImage = ImageCreateFromJpeg($this->fileName);
break;
case 'PNG':
$this->oldImage = ImageCreateFromPng($this->fileName);
break;
}
$size = GetImageSize($this->fileName);
$this->currentDimensions = array('width'=>$size[0],'height'=>$size[1]);
$this->newImage = $this->oldImage;
$this->gatherImageMeta();
}
if($this->error == true) {
$this->showErrorImage();
break;
}
}
function destruct() {
if(is_resource($this->newImage)) @ImageDestroy($this->newImage);
if(is_resource($this->oldImage)) @ImageDestroy($this->oldImage);
if(is_resource($this->workingImage)) @ImageDestroy($this->workingImage);
}
function getCurrentWidth() {
return $this->currentDimensions['width'];
}
function getCurrentHeight() {
return $this->currentDimensions['height'];
}
function calcWidth($width,$height) {
$newWp = (100 * $this->maxWidth) / $width;
$newHeight = ($height * $newWp) / 100;
return array('newWidth'=>intval($this->maxWidth),'newHeight'=>intval($newHeight));
}
function calcHeight($width,$height) {
$newHp = (100 * $this->maxHeight) / $height;
$newWidth = ($width * $newHp) / 100;
return array('newWidth'=>intval($newWidth),'newHeight'=>intval($this->maxHeight));
}
function calcPercent($width,$height) {
$newWidth = ($width * $this->percent) / 100;
$newHeight = ($height * $this->percent) / 100;
return array('newWidth'=>intval($newWidth),'newHeight'=>intval($newHeight));
}
function calcImageSize($width,$height) {
$newSize = array('newWidth'=>$width,'newHeight'=>$height);
if($this->maxWidth > 0) {
$newSize = $this->calcWidth($width,$height);
if($this->maxHeight > 0 && $newSize['newHeight'] > $this->maxHeight) {
$newSize = $this->calcHeight($newSize['newWidth'],$newSize['newHeight']);
}
}
if($this->maxHeight > 0) {
$newSize = $this->calcHeight($width,$height);
if($this->maxWidth > 0 && $newSize['newWidth'] > $this->maxWidth) {
$newSize = $this->calcWidth($newSize['newWidth'],$newSize['newHeight']);
}
}
$this->newDimensions = $newSize;
}
function calcImageSizePercent($width,$height) {
if($this->percent > 0) {
$this->newDimensions = $this->calcPercent($width,$height);
}
}
function showErrorImage() {
header('Content-type: image/png');
$errImg = ImageCreate(220,25);
$bgColor = imagecolorallocate($errImg,0,0,0);
$fgColor1 = imagecolorallocate($errImg,255,255,255);
$fgColor2 = imagecolorallocate($errImg,255,0,0);
imagestring($errImg,3,6,6,'Error:',$fgColor2);
imagestring($errImg,3,55,6,$this->errmsg,$fgColor1);
imagepng($errImg);
imagedestroy($errImg);
}
function resize($maxWidth = 0, $maxHeight = 0) {
$this->maxWidth = $maxWidth;
$this->maxHeight = $maxHeight;
$this->calcImageSize($this->currentDimensions['width'],$this->currentDimensions['height']);
if(function_exists("ImageCreateTrueColor")) {
$this->workingImage = ImageCreateTrueColor($this->newDimensions['newWidth'],$this->newDimensions['newHeight']);
}
else {
$this->workingImage = ImageCreate($this->newDimensions['newWidth'],$this->newDimensions['newHeight']);
}
ImageCopyResampled(
$this->workingImage,
$this->oldImage,
0,
0,
0,
0,
$this->newDimensions['newWidth'],
$this->newDimensions['newHeight'],
$this->currentDimensions['width'],
$this->currentDimensions['height']
);
$this->oldImage = $this->workingImage;
$this->newImage = $this->workingImage;
$this->currentDimensions['width'] = $this->newDimensions['newWidth'];
$this->currentDimensions['height'] = $this->newDimensions['newHeight'];
}
function manual_resize($maxWidth = 0, $maxHeight = 0) {
$this->maxWidth = $maxWidth;
$this->maxHeight = $maxHeight;
$this->calcImageSize($this->currentDimensions['width'],$this->currentDimensions['height']);
if(function_exists("ImageCreateTrueColor")) {
$this->workingImage = ImageCreateTrueColor($this->maxWidth,$this->maxHeight);
}
else {
$this->workingImage = ImageCreate($this->maxWidth,$this->maxHeight);
}
ImageCopyResampled(
$this->workingImage,
$this->oldImage,
0,
0,
0,
0,
$this->maxWidth,
$this->maxHeight,
$this->currentDimensions['width'],
$this->currentDimensions['height']
);
$this->oldImage = $this->workingImage;
$this->newImage = $this->workingImage;
$this->currentDimensions['width'] = $this->newWidth;
$this->currentDimensions['height'] = $this->maxHeight;
}
function resizePercent($percent = 0) {
$this->percent = $percent;
$this->calcImageSizePercent($this->currentDimensions['width'],$this->currentDimensions['height']);
if(function_exists("ImageCreateTrueColor")) {
$this->workingImage = ImageCreateTrueColor($this->newDimensions['newWidth'],$this->newDimensions['newHeight']);
}
else {
$this->workingImage = ImageCreate($this->newDimensions['newWidth'],$this->newDimensions['newHeight']);
}
ImageCopyResampled(
$this->workingImage,
$this->oldImage,
0,
0,
0,
0,
$this->newDimensions['newWidth'],
$this->newDimensions['newHeight'],
$this->currentDimensions['width'],
$this->currentDimensions['height']
);
$this->oldImage = $this->workingImage;
$this->newImage = $this->workingImage;
$this->currentDimensions['width'] = $this->newDimensions['newWidth'];
$this->currentDimensions['height'] = $this->newDimensions['newHeight'];
}
function cropFromCenter($cropSize) {
if($cropSize > $this->currentDimensions['width']) $cropSize = $this->currentDimensions['width'];
if($cropSize > $this->currentDimensions['height']) $cropSize = $this->currentDimensions['height'];
$cropX = intval(($this->currentDimensions['width'] - $cropSize) / 2);
$cropY = intval(($this->currentDimensions['height'] - $cropSize) / 2);
if(function_exists("ImageCreateTrueColor")) {
$this->workingImage = ImageCreateTrueColor($cropSize,$cropSize);
}
else {
$this->workingImage = ImageCreate($cropSize,$cropSize);
}
imagecopyresampled(
$this->workingImage,
$this->oldImage,
0,
0,
$cropX,
$cropY,
$cropSize,
$cropSize,
$cropSize,
$cropSize
);
$this->oldImage = $this->workingImage;
$this->newImage = $this->workingImage;
$this->currentDimensions['width'] = $cropSize;
$this->currentDimensions['height'] = $cropSize;
}
function crop($startX,$startY,$width,$height) {
if($width > $this->currentDimensions['width']) $width = $this->currentDimensions['width'];
if($height > $this->currentDimensions['height']) $height = $this->currentDimensions['height'];
if(($startX + $width) > $this->currentDimensions['width']) $startX = ($this->currentDimensions['width'] - $width);
if(($startY + $height) > $this->currentDimensions['height']) $startY = ($this->currentDimensions['height'] - $height);
if($startX < 0) $startX = 0;
if($startY < 0) $startY = 0;
if(function_exists("ImageCreateTrueColor")) {
$this->workingImage = ImageCreateTrueColor($width,$height);
}
else {
$this->workingImage = ImageCreate($width,$height);
}
imagecopyresampled(
$this->workingImage,
$this->oldImage,
0,
0,
$startX,
$startY,
$width,
$height,
$width,
$height
);
$this->oldImage = $this->workingImage;
$this->newImage = $this->workingImage;
$this->currentDimensions['width'] = $width;
$this->currentDimensions['height'] = $height;
}
function show($quality=100,$name = '') {
switch($this->format) {
case 'GIF':
if($name != '') {
ImageGif($this->newImage,$name);
}
else {
header('Content-type: image/gif');
ImageGif($this->newImage);
}
break;
case 'JPG':
if($name != '') {
ImageJpeg($this->newImage,$name,$quality);
}
else {
header('Content-type: image/jpeg');
ImageJpeg($this->newImage,'',$quality);
}
break;
case 'PNG':
if($name != '') {
ImagePng($this->newImage,$name);
}
else {
header('Content-type: image/png');
ImagePng($this->newImage);
}
break;
}
}
function save($name,$quality=100) {
$this->show($quality,$name);
}
function createReflection($percent,$reflection,$white,$border = true,$borderColor = '#a4a4a4') {
$width = $this->currentDimensions['width'];
$height = $this->currentDimensions['height'];
$reflectionHeight = intval($height * ($reflection / 100));
$newHeight = $height + $reflectionHeight;
$reflectedPart = $height * ($percent / 100);
$this->workingImage = ImageCreateTrueColor($width,$newHeight);
ImageAlphaBlending($this->workingImage,true);
$colorToPaint = ImageColorAllocateAlpha($this->workingImage,255,255,255,0);
ImageFilledRectangle($this->workingImage,0,0,$width,$newHeight,$colorToPaint);
imagecopyresampled(
$this->workingImage,
$this->newImage,
0,
0,
0,
$reflectedPart,
$width,
$reflectionHeight,
$width,
($height - $reflectedPart));
$this->imageFlipVertical();
imagecopy($this->workingImage,$this->newImage,0,0,0,0,$width,$height);
imagealphablending($this->workingImage,true);
for($i=0;$i<$reflectionHeight;$i++) {
$colorToPaint = imagecolorallocatealpha($this->workingImage,255,255,255,($i/$reflectionHeight*-1+1)*$white);
imagefilledrectangle($this->workingImage,0,$height+$i,$width,$height+$i,$colorToPaint);
}
if($border == true) {
$rgb = $this->hex2rgb($borderColor,false);
$colorToPaint = imagecolorallocate($this->workingImage,$rgb[0],$rgb[1],$rgb[2]);
imageline($this->workingImage,0,0,$width,0,$colorToPaint);
imageline($this->workingImage,0,$height,$width,$height,$colorToPaint);
imageline($this->workingImage,0,0,0,$height,$colorToPaint);
imageline($this->workingImage,$width-1,0,$width-1,$height,$colorToPaint);
}
$this->oldImage = $this->workingImage;
$this->newImage = $this->workingImage;
$this->currentDimensions['width'] = $width;
$this->currentDimensions['height'] = $newHeight;
}
function imageFlipVertical() {
$x_i = imagesx($this->workingImage);
$y_i = imagesy($this->workingImage);
for($x = 0; $x < $x_i; $x++) {
for($y = 0; $y < $y_i; $y++) {
imagecopy($this->workingImage,$this->workingImage,$x,$y_i - $y - 1, $x, $y, 1, 1);
}
}
}
function hex2rgb($hex, $asString = false) {
if (0 === strpos($hex, '#')) {
$hex = substr($hex, 1);
} else if (0 === strpos($hex, '&H')) {
$hex = substr($hex, 2);
}
$cutpoint = ceil(strlen($hex) / 2)-1;
$rgb = explode(':', wordwrap($hex, $cutpoint, ':', $cutpoint), 3);
$rgb[0] = (isset($rgb[0]) ? hexdec($rgb[0]) : 0);
$rgb[1] = (isset($rgb[1]) ? hexdec($rgb[1]) : 0);
$rgb[2] = (isset($rgb[2]) ? hexdec($rgb[2]) : 0);
return ($asString ? "{$rgb[0]} {$rgb[1]} {$rgb[2]}" : $rgb);
}
function gatherImageMeta() {
if(function_exists("exif_read_data") && $this->format == 'JPG') {
$imageData = exif_read_data($this->fileName);
if(isset($imageData['Make']))
$this->imageMeta['make'] = ucwords(strtolower($imageData['Make']));
if(isset($imageData['Model']))
$this->imageMeta['model'] = $imageData['Model'];
if(isset($imageData['COMPUTED']['ApertureFNumber'])) {
$this->imageMeta['aperture'] = $imageData['COMPUTED']['ApertureFNumber'];
$this->imageMeta['aperture'] = str_replace('/','',$this->imageMeta['aperture']);
}
if(isset($imageData['ExposureTime'])) {
$exposure = explode('/',$imageData['ExposureTime']);
$exposure = round($exposure[1]/$exposure[0],-1);
$this->imageMeta['exposure'] = '1/' . $exposure . ' second';
}
if(isset($imageData['Flash'])) {
if($imageData['Flash'] > 0) {
$this->imageMeta['flash'] = 'Yes';
}
else {
$this->imageMeta['flash'] = 'No';
}
}
if(isset($imageData['FocalLength'])) {
$focus = explode('/',$imageData['FocalLength']);
$this->imageMeta['focalLength'] = round($focus[0]/$focus[1],2) . ' mm';
}
if(isset($imageData['DateTime'])) {
$date = $imageData['DateTime'];
$date = explode(' ',$date);
$date = str_replace(':','-',$date[0]) . ' ' . $date[1];
$this->imageMeta['dateTaken'] = date('m/d/Y g:i A',strtotime($date));
}
}
}
function rotateImage($direction = 'CW') {
if($direction == 'CW') {
$this->workingImage = imagerotate($this->workingImage,-90,0);
}
else {
$this->workingImage = imagerotate($this->workingImage,90,0);
}
$newWidth = $this->currentDimensions['height'];
$newHeight = $this->currentDimensions['width'];
$this->oldImage = $this->workingImage;
$this->newImage = $this->workingImage;
$this->currentDimensions['width'] = $newWidth;
$this->currentDimensions['height'] = $newHeight;
}
}
?>
and here is my image.php
<?php
$modul_no = "0";
ob_start();
include "login_check.php";
include "../class/thumbnail.php";
$do = trim($_REQUEST['do']);
$q = trim($_REQUEST['q']);
$type = trim($_REQUEST['type']);
$field = trim($_REQUEST['field']);
if(!$field){
$field = "image";
}
$dir = $settings['root_path']."/images/".$type;
$view_url = $settings['site_url']."/images/".$type."/";
$allow_types = $settings['image_type'];
$image_size = $settings['image_size'];
function get_ext($key) {
$key=strtolower(substr(strrchr($key, "."), 1));
$key=str_replace("jpeg","jpg",$key);
return $key;
}
$ext_count=count($allow_types);
$i=0;
foreach($allow_types as $extension) {
if($i <= $ext_count-2){
$types .="*.".$extension.", ";
}else{
$types .="*.".$extension;
}
$i++;
}
unset($i,$ext_count);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Resim Yönetimi</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-9">
<link rel="stylesheet" href="images/style.css" type="text/css" />
<style>
BODY{
margin:1px;
background:#BCCED9;
}
.style1 {color: #FFFFFF}
.style2 {color: #000000}
</style>
<?php
if($type == "other"){
?>
<script language="javascript">
function imageAdd(_width, _height, image, filepath)
{
window.opener.document.getElementById('f_url').value = filepath;
window.close();
}
</script>
<?php
}else{
?>
<script language="javascript">
function imageAdd(_width, _height, image, filepath)
{
window.opener.document.addForm.image.value = image;
window.close();
}
</script>
<?php
}
?>
</head>
<body>
<table width="100%" border="0" cellspacing="1" cellpadding="0" class="table_box" >
<?php
if($_POST['upload']){
echo "<tr>\n";
echo " <td colspan=\"2\" align=\"center\" class=\"style1 listEven row5px\" style=\"height:15px; background:url(images/popup-head.png)\" >";
echo "Resim Yükleme</td>\n";
echo " </tr>\n";
echo "<tr>\n";
echo " <td class=\"row5px listEven\" align=\"center\">\n";
$ext=get_ext($_FILES['file']['name']);
$size=$_FILES['file']['size'];
$image_size_byte=$image_size*1024;
if(!in_array($ext, $allow_types)) {
echo "Bu Dosya uzantısını yükleyemezsiniz : ".$_FILES['file']['name'].", sadece ".$types."
uzantılı dosyaları yükleyebilirsiniz.<br />Resim yüklenemedi <br /><br><a href=\"javascript:history.go(-1)\">Geri</a>";
exit;
}elseif($size > $image_size_byte) {
echo "Yüklenecek resim: ".$_FILES['file']['name']." boyutu çok büyük.Max resim boyutu
".$settings['image_file_size']." KB.<br />Resim yüklenemedi<br /><br><a href=\"javascript:history.go(-1)\">Geri</a>";
exit;
}else{
$ext=get_ext($_FILES['file']['name']);
$query = $db->read_query("select newname from images where type='$type' ORDER BY image_id DESC LIMIT 1") or die($db->sql_error());
$row = $db->sql_fetcharray($query);
$last_img = explode(".",$row[newname]);
$new_image_name = ($last_img[0]+1).".".$ext;
if(@move_uploaded_file($_FILES['file']['tmp_name'],$dir."/".$new_image_name)) {
$db->write_query("insert into images
(
oldname, newname, type, size
)
values
(
'".$_FILES['file']['name']."',
'".$new_image_name."',
'".$type."',
'".$size."'
)
");
$thumb = new Thumbnail($dir."/".$new_image_name);
if($type == "news"){
$thumb->manual_resize($settings['news_image_width'],$settings['news_image_height']);
$thumb->save($dir."/".$new_image_name,100);
}elseif($type == "authors"){
$thumb->manual_resize($settings['authors_big_width'],$settings['authors_big_height']);
$thumb->save($dir."/".$new_image_name,100);
$thumb_small = new Thumbnail($dir."/".$new_image_name);
$thumb_small->manual_resize($settings['authors_small_width'],$settings['authors_small_height']);
$thumb_small->save($dir."/th_".$new_image_name,100);
}else{
$image_pix = @getimagesize($dir."/".$new_image_name);
$width_org = $image_pix[0];
if($width_org > $settings['page_image_max_width']){
$thumb->resize($settings['page_image_max_width']);
$thumb->save($dir."/".$new_image_name,100);
}
}
@chmod($dir."/".$new_image_name,0644);
}else{
echo "Resim Yüklenemedi.Lütfen Sonra Tekrar Deneyiniz.";
exit;
}
echo "<input type=\"hidden\" name=urlImage_".$new_imagename." id=urlImage_".$new_imagename." value=\"".$view_url.$new_image_name."\">\n";
$image_file_size=number_format($_FILES['file']['size']/1024, 1, ".", "");
echo "<img src=\"".$view_url.$new_image_name."\" border=\"0\" id=img_upload><br>
<a href=\"javascript:;\" onclick=\"javascript:imageAdd(document.all.img_upload.width, document.all.img_upload.height, '".$new_image_name."', '".$view_url.$new_image_name."'); window.close();\">Resmi Kullan [ Resim Adı : ".$_FILES['file']['name']." ] [ $image_file_size KB ]</a> [ <a href=\"".$_SERVER['PHP_SELF']."?do=delete&image_id=".$db->sql_nextid()."\">Sil</a> ] <p>\n";
}
echo "<input name=\"back\" type=\"button\" onclick=\"javascript:history.go(-1);\" class=\"button\" id=\"back\" value=\"Geri Dön\" />";
echo "<input name=\"close\" type=\"button\" onclick=\"javascript:window.close()\" class=\"button\" id=\"close\" value=\"Vazgeç\" />";
echo " </td>\n";
echo "</tr>\n";
}elseif($_POST['search_post']){
echo "<tr>\n";
echo " <td colspan=\"2\" align=\"center\" class=\"style1 listEven row5px\" style=\"height:15px; background:url(images/popup-head.png)\" >";
echo "Arama Sonuçları</td>\n";
echo " </tr>\n";
echo "<tr>\n";
echo " <td class=\"row5px listEven\" align=\"center\">\n";
if(!$q){
echo "Lütfen Formu Doldurun..<br /><br><a href=\"javascript:history.go(-1)\">Geri</a>";
exit;
}elseif(strlen($q)<3){
echo "En Az 3 Karakter Girmelisiniz..<br /><br><a href=\"javascript:history.go(-1)\">Geri</a>";
exit;
}else{
$query = $db->read_query("select image_id, newname, oldname, size from images where type='$type' and oldname LIKE '%$q%'") or die($db->sql_error());
$i=0;
while($row = $db->sql_fetcharray($query)){
$i++;
$image_file_size=number_format($row[size]/1024, 1, ".", "");
$img_url = $view_url.$row[newname];
echo "<input type=\"hidden\" name=urlImage_".$row[newname]." id=urlImage_".$row[newname]." value=\"".$img_url."\">\n";
echo "<img src=\"".$img_url."\" border=\"0\" id=img_upload><br>";
echo "<a href=\"javascript:;\"
onclick=\"javascript:imageAdd(document.all.img_upload.width, document.all.img_upload.height, '".$row[newname]."', '".$img_url."'); window.close();\">Resmi Kullan [ Resim Adı : ".$row[oldname]." ] [ $image_file_size KB ]</a> [ <a href=\"".$_SERVER['PHP_SELF']."?do=delete&image_id=".$row[image_id]."\">Sil</a> ] <p>\n";
}
if(!$i){
echo "Kayıt Bulunamadı..<br /><br><a href=\"javascript:history.go(-1)\">Geri</a>";
exit;
}
}
echo "<input name=\"back\" type=\"button\" onclick=\"javascript:history.go(-1);\" class=\"button\" id=\"back\" value=\"Geri Dön\" />";
echo "<input name=\"close\" type=\"button\" onclick=\"javascript:window.close()\" class=\"button\" id=\"close\" value=\"Vazgeç\" />";
echo " </td>\n";
echo "</tr>\n";
}elseif($do == "delete"){
$image_id = intval($_GET['image_id']);
$query = $db->read_query("select type, newname from images where image_id=$image_id") or die($db->sql_error());
$row = $db->sql_fetcharray($query);
if(file_exists($settings['root_path']."/images/".$row[type]."/".$row[newname])){
@unlink($settings['root_path']."/images/".$row[type]."/".$row[newname]);
}
$query = $db->write_query("delete from images where image_id=$image_id") or die($db->sql_error());
echo "<script>alert('Resim Silindi.'); window.location = 'image.php?do=upload&type=".$row[type]."';</script>";
}elseif($do == "search"){
?>
<form action="<?=$_SERVER['PHP_SELF']?>" method="post" enctype="multipart/form-data">
<input type="hidden" value="<?=$type?>" name="type" />
<input type="hidden" value="<?=$do?>" name="do" />
<input type="hidden" value="<?=$rte?>" name="rte" />
<tr>
<td colspan="2" align="center" class="style1 listEven row5px" style="height:15px; background:url(images/popup-head.png)" >Arama Yapmak İstediğiniz Kriterleri Giriniz</td>
</tr>
<tr>
<td width="30%" class="row5px listEven">Kelime Girin :</td>
<td width="70%" class="row5px listOdd"><input name="q" type="text" size="50" />
En az 3 Karakter </td>
</tr>
<tr>
<td width="30%" class="row5px listEven" align="center"> </td>
<td width="70%" class="row5px listOdd"><input name="search_post" type="submit" class="button" id="search_post" value="Ara" />
<input name="close23" type="button" onclick="javascript:window.close()" class="button" id="close23" value="Vazgeç" />
<input name="uploadimg" type="button" onclick="javascript:window.location='<?=$_SERVER['PHP_SELF']?>?do=upload&rte=<?=$rte?>&type=<?=$type?>'" class="button" id="uploadimg" value="Resim Yükle" /></td>
</tr>
</form>
<?php
}else{
?>
<form action="<?=$_SERVER['PHP_SELF']?>" method="post" enctype="multipart/form-data">
<input type="hidden" value="<?=$type?>" name="type" />
<input type="hidden" value="<?=$do?>" name="do" />
<input type="hidden" value="<?=$rte?>" name="rte" />
<tr>
<td colspan="2" align="center" class="style1 listEven row5px" style="height:15px; background:url(images/popup-head.png)" >Yüklenecek Resmi Seçiniz</td>
</tr>
<tr>
<td colspan="2" align="left" class="row5px listEven style2" style="height:15px; line-height:140%; background: #A5BBC8" >Yüklemek İstediğiniz Resmi " GÖZAT " butonuna basarak seçiniz ve Yükle butonuna Basınız. <br />Sadece <?=$types?> uzantılı resimleri yükleyebilirsiniz.</td>
</tr>
<tr>
<td width="30%" class="row5px listEven">Resim Seçin :</td>
<td width="70%" class="row5px listOdd"><input name="file" type="file" size="50" /></td>
</tr>
<tr>
<td width="30%" class="row5px listEven" align="center"> </td>
<td width="70%" class="row5px listOdd"><input name="upload" type="submit" class="button" id="upload" value="Yükle" />
<input name="close222" type="button" onclick="javascript:window.close()" class="button" id="close222" value="Vazgeç" />
<input name="imgsearch" type="button" onclick="javascript:window.location='<?=$_SERVER['PHP_SELF']?>?do=search&rte=<?=$rte?>&type=<?=$type?>'" class="button" id="imgsearch" value="Resim Ara" /></td>
</tr>
</form>
<?php
}
?>
</table>
</body>
</html>
What I have tried:
I have this function but dont know how to handle it in image.php
function IsTransparentPng($File){
if ((ord(file_get_contents($File, false, null, 25, 1)) & 4)>0){
return true;
}
$fd=fopen($File, 'r');
$continue=true;
$plte=false;
$trns=false;
$idat=false;
while($continue===true){
$continue=false;
$line=fread($fd, 1024);
if ($plte===false){
$plte=(stripos($line, 'PLTE')!==false);
}
if ($trns===false){
$trns=(stripos($line, 'tRNS')!==false);
}
if ($idat===false){
$idat=(stripos($line, 'IDAT')!==false);
}
if ($idat===false and !($plte===true and $trns===true)){
$continue=true;
}
}
fclose($fd);
return ($plte===true and $trns===true);
}