Ho un problema con il caricamento delle foto, insommo se scatto una foto con verticale me la ruota automaticamente, pero per il resto funziona benissimo, qualcuno può aiutarmi ?
il problema lo riscontro principalmene sui thumb ovvero le anterprime, ovvero tutti i file salvati (nome file)t.png/jpg/gif
il problema lo riscontro principalmene sui thumb ovvero le anterprime, ovvero tutti i file salvati (nome file)t.png/jpg/gif
PHP:
<?php
$dir_img = '../img/user_img/';
header('Cache-control: max-age='.(60*60*24*365));
header('Expires: '.gmdate(DATE_RFC1123,time()+60*60*24*365));
if (isset($_GET['img']) AND file_exists($dir_img.$_GET['img'].".png")) {
if (isset($_GET['t'])) {
$type = exif_imagetype ($dir_img.$_GET['img'].".png");
$thumb = $dir_img.$_GET['img']."t.png";
$thumboriginal = $dir_img.$_GET['img']."t.png";
if (!file_exists($thumb)) {
if ($type==1) {
$im = $dir_img.$_GET['img'].".png";
list($width, $height) = getimagesize($im);
$im = imagecreatefromgif($im);
if ($width > $height) {
$y = 0;
$x = ($width - $height) / 2;
$smallestSide = $height;
} else {
$x = 0;
$y = ($height - $width) / 2;
$smallestSide = $width;
}
$thumbSize = 300;
$thumb = imagecreatetruecolor($thumbSize, $thumbSize);
imagecopyresampled($thumb, $im, 0, 0, $x, $y, $thumbSize, $thumbSize, $smallestSide, $smallestSide);
$dirsave = $dir_img.$_GET['img']."t.png";
imagegif($thumb, $dirsave);
}
elseif ($type==2) {
$im = $dir_img.$_GET['img'].".png";
list($width, $height) = getimagesize($im);
$im = imagecreatefromjpeg($im);
if ($width > $height) {
$y = 0;
$x = ($width - $height) / 2;
$smallestSide = $height;
} else {
$x = 0;
$y = ($height - $width) / 2;
$smallestSide = $width;
}
$thumbSize = 300;
$thumb = imagecreatetruecolor($thumbSize, $thumbSize);
imagecopyresampled($thumb, $im, 0, 0, $x, $y, $thumbSize, $thumbSize, $smallestSide, $smallestSide);
$dirsave = $dir_img.$_GET['img']."t.png";
imagejpeg($thumb, $dirsave);
}
elseif ($type==3) {
$im = $dir_img.$_GET['img'].".png";
list($width, $height) = getimagesize($im);
$im = imagecreatefrompng($im);
if ($width > $height) {
$y = 0;
$x = ($width - $height) / 2;
$smallestSide = $height;
} else {
$x = 0;
$y = ($height - $width) / 2;
$smallestSide = $width;
}
$thumbSize = 300;
$thumb = imagecreatetruecolor($thumbSize, $thumbSize);
imagecopyresampled($thumb, $im, 90, 90, $x, $y, $thumbSize, $thumbSize, $smallestSide, $smallestSide);
$dirsave = $dir_img.$_GET['img']."t.png";
imagepng($thumb, $dirsave);
}
else {
header("Content-Type: image/png");
header('Content-Disposition: inline; filename="error.png');
$im = @imagecreate(300, 300);
$background_color = imagecolorallocate($im, 235, 235, 235);
$text_color = imagecolorallocate($im, 255, 0, 0);
imagestring($im, 5, 20, 140, "FILE IMMAGINE NON SUPPORTATO", $text_color);
imagepng($im);
imagedestroy($im);
}
}
if ($type==1) {
header('Content-Type: image/gif');
header('Content-Disposition: inline; filename="thumb.gif');
echo file_get_contents($thumboriginal);
}
elseif($type==2) {
header('Content-Type: image/jpeg');
header('Content-Disposition: inline; filename="thumb.jpg');
echo file_get_contents($thumboriginal);
}
elseif($type==3) {
header('Content-Type: image/png');
header('Content-Disposition: inline; filename="thumb.png');
echo file_get_contents($thumboriginal);
}
}
else {
$type = exif_imagetype ($dir_img.$_GET['img'].".png");
if ($type==1) {
$im = $dir_img.$_GET['img'].".png";
header('Content-Type: image/gif');
header('Content-Disposition: inline; filename="SocialEdge.gif');
echo file_get_contents($im);
}
elseif ($type==2) {
$im = $dir_img.$_GET['img'].".png";
header('Content-Type: image/jpeg');
header('Content-Disposition: inline; filename="SocialEdge.jpg');
echo file_get_contents($im);
}
elseif ($type==3) {
$im = $dir_img.$_GET['img'].".png";
header('Content-Type: image/png');
header('Content-Disposition: inline; filename="SocialEdge.png');
echo file_get_contents($im);
}
else {
header("Content-Type: image/png");
header('Content-Disposition: inline; filename="error.png');
$im = @imagecreate(300, 300);
$background_color = imagecolorallocate($im, 235, 235, 235);
$text_color = imagecolorallocate($im, 255, 0, 0);
imagestring($im, 5, 20, 140, "FILE IMMAGINE NON SUPPORTATO", $text_color);
imagepng($im);
imagedestroy($im);
}
}
}
$dir_img = '../img/profile_img/';
if (isset($_GET['profiloimg'])) {
if (file_exists($dir_img.$_GET['profiloimg'].".png")) {
$type = exif_imagetype ($dir_img.$_GET['profiloimg'].".png");
if ($type==1) {
$im = $dir_img.$_GET['profiloimg'].".png";
header('Content-Type: image/gif');
header('Content-Disposition: inline; filename="profilo.gif');
echo file_get_contents($im);
}
elseif ($type==2) {
$im = $dir_img.$_GET['profiloimg'].".png";
header('Content-Type: image/jpeg');
header('Content-Disposition: inline; filename="profilo.jpg');
echo file_get_contents($im);
}
elseif ($type==3) {
$im = $dir_img.$_GET['profiloimg'].".png";
header('Content-Type: image/png');
header('Content-Disposition: inline; filename="profilo.png');
echo file_get_contents($im);
}
else {
header("Content-Type: image/png");
header('Content-Disposition: inline; filename="error.png');
$im = @imagecreate(300, 300);
$background_color = imagecolorallocate($im, 235, 235, 235);
$text_color = imagecolorallocate($im, 255, 0, 0);
imagestring($im, 5, 20, 140, "FILE IMMAGINE NON SUPPORTATO", $text_color);
imagepng($im);
imagedestroy($im);
}
}
else {
$im = $dir_img."default.png";
header('Content-Type: image/png');
header('Content-Disposition: inline; filename="profilo.png');
echo file_get_contents($im);
}
}
?>