Viewing file: demo2.php (2.53 KB) -rw-rw-rw- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Documento sin título</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php
//$tipo = exif_imagetype("image1.jpg");
//$size = GetImageSize("image1.jpg");
//echo "Tipo de Archivo";
//echo $tipo;
//echo "<br>";
//echo "Tamaņo de Archivo";
//foreach ($size as $v) {
//echo $v;
//echo "<br>";
////}
//echo "<br>";
//resize_jpg("image1.jpg",100,100);
//function resize_jpg($img,$w,$h){
//$thumb = imagecreate ($w, $h);
//$image = ImageCreateFromJpeg($img);
//$imagedata = getimagesize($img);
//imagecopyresized ($thumb, $image, 0, 0, 0, 0, $w, $h, $imagedata[0], $imagedata[1]);
//imagejpeg($thumb, $img);
//}
$handle=opendir('C:\maps');
echo "Directory handle: $handle\n";
echo "Files:\n";
$res=0;
while ($file = readdir($handle)) {
$file = "C:\maps\\" . $file;
loadjpeg($file,100,100,$res);
$new = "imagenback" . $res . ".jpg";
$size = GetImageSize($new);
$an = $size[0];
$la = $size[1];
echo "<p><img src=\"$new\" width=\"$an\" height=\"$la\"></p>";
echo $file;
echo "-----";
echo $an;
echo " x ";
echo $la;
echo "<br>";
$res++;
}
closedir($handle);
function loadjpeg($path, $max_x, $max_y, $pro) {
$im = @imagecreatefromjpeg($path);
if (!$im) {
$im = imagecreate(150, 30);
$bgc = imagecolorallocate($im, 255, 255, 255);
$tc = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 150, 30, $bgc);
imagestring($im, 1, 5, 5, "Error loading $path", $tc);
}
if ($max_x != 0 && $max_y != 0) {
$x = imagesx($im);
$y = imagesy($im);
if ($x > $max_x) {
$y = (int)floor($y * ($max_x / $x));
$x = $max_x;
}
if ($y > $max_y) {
$x = (int)floor($x * ($max_y / $y));
$y = $max_y;
}
if (imagesx($im) != $x || imagesy($im) != $y) {
$tmp = imagecreate($x, $y);
imagecopyresized($tmp, $im, 0, 0, 0, 0, $x, $y, imagesx($im), imagesy($im));
$new = "imagenback" . $pro . ".jpg";
Imagejpeg($tmp,$new,20);
imagedestroy($im);
$im = $tmp;
}
}
return $im;
}
//Header("Content-type: image/jpeg");
//$im = imagecreatefromjpeg("image1.jpg");
//Imagejpeg($im,'',20);
//ImageDestroy($im);
// call resize function resize_jpg(image name, new width, new height)
?>
<p><img src="imagenback.jpg" width="<?php echo $an; ?>" height="<?php echo $la; ?>"></p>
</body>
</html>
|