commit
92f0e5bba0
1 changed files with 16 additions and 12 deletions
|
@ -83,7 +83,7 @@ function sanitize($name)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure the "thumbs" directory exists.
|
// Make sure the "thumbs" directory exists.
|
||||||
if (!is_dir('thumbs'))
|
if (!is_dir('thumbs') && is_writable('.'))
|
||||||
{
|
{
|
||||||
mkdir('thumbs',0700);
|
mkdir('thumbs',0700);
|
||||||
}
|
}
|
||||||
|
@ -140,14 +140,18 @@ else // otherwise, generate thumbnail, send it and save it to file.
|
||||||
$height = $width;
|
$height = $width;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$degrees = 0;
|
||||||
|
$flip = '';
|
||||||
// Rotate JPG pictures
|
// Rotate JPG pictures
|
||||||
if (preg_match("/.jpg$|.jpeg$/i", $_GET['filename']))
|
if (preg_match("/.jpg$|.jpeg$/i", $_GET['filename']))
|
||||||
{
|
{
|
||||||
if (function_exists('exif_read_data') && function_exists('imagerotate'))
|
if (function_exists('exif_read_data') && function_exists('imagerotate'))
|
||||||
{
|
{
|
||||||
$exif = exif_read_data($_GET['filename'], 0, true);
|
$exif = exif_read_data($_GET['filename'], 0, true);
|
||||||
|
if (isset($exif['IFD0']) && isset($exif['IFD0']['Orientation']))
|
||||||
$ort = $exif['IFD0']['Orientation'];
|
$ort = $exif['IFD0']['Orientation'];
|
||||||
$degrees = 0;
|
else
|
||||||
|
$ort = 0;
|
||||||
switch($ort)
|
switch($ort)
|
||||||
{
|
{
|
||||||
case 3: // 180 rotate right
|
case 3: // 180 rotate right
|
||||||
|
@ -215,21 +219,21 @@ else // otherwise, generate thumbnail, send it and save it to file.
|
||||||
flipVertical($target);
|
flipVertical($target);
|
||||||
flipHorizontal($target);
|
flipHorizontal($target);
|
||||||
flipVertical($target);
|
flipVertical($target);
|
||||||
ImageJPEG($target,null,80);
|
|
||||||
} else {
|
|
||||||
ImageJPEG($target,null,80);
|
|
||||||
}
|
}
|
||||||
|
ImageJPEG($target,null,80);
|
||||||
|
|
||||||
imagedestroy($target);
|
imagedestroy($target);
|
||||||
|
|
||||||
$cachedImage = ob_get_contents(); // Get the buffer content.
|
$cachedImage = ob_get_contents(); // Get the buffer content.
|
||||||
ob_end_flush();// End buffering
|
ob_end_flush();// End buffering
|
||||||
|
if (is_writable(dirname($thumbname))) {
|
||||||
$fd = fopen($thumbname, "w"); // Save buffer to disk
|
$fd = fopen($thumbname, "w"); // Save buffer to disk
|
||||||
if ($fd)
|
if ($fd)
|
||||||
{
|
{
|
||||||
fwrite($fd,$cachedImage);
|
fwrite($fd,$cachedImage);
|
||||||
fclose($fd);
|
fclose($fd);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Reference in a new issue