( ′∀`)σ≡σ☆))Д′)レ(゚∀゚;)ヘ=З=З=Зε≡(ノ´_ゝ`)ノ
<?php
if (!empty($crop)) {
$_POST = filter($_POST);
$newsid = $_POST['newsid'];
$newsid = $db->base64url_decode($newsid);
$photo = $_POST['photo'];
$targ_w = 500;
$mag = $_POST['mag'];
$targ_h = 666;
$jpeg_quality = 100;
$src = "v/uploads/raw/$photo";
$size = GetImageSize($src);
$mime = $size['mime'];
if (substr($mime, 0, 6) != 'image/')
{
header("Location: ./cropMobile.php?original=$photo&mode=crop&msg=requested file is not an accepted type");
exit();
}
$dst_r = imagecreatetruecolor( $targ_w, $targ_h );
// Set up the appropriate image handling functions based on the original image's mime type
switch ($size['mime'])
{
case 'image/gif':
// We will be converting GIFs to PNGs to avoid transparency issues when resizing GIFs
// This is maybe not the ideal solution, but IE6 can suck it
$creationFunction = 'ImageCreateFromGif';
$outputFunction = 'ImagePng';
$mime = 'image/png'; // We need to convert GIFs to PNGs
$quality = round(10 - ($quality / 10)); // We are converting the GIF to a PNG and PNG needs a compression level of 0 (no compression) through 9
break;
case 'image/png':
$quality=100;
$creationFunction = 'ImageCreateFromPng';
$outputFunction = 'ImagePng';
$quality = round(10 - ($quality / 10)); // PNG needs a compression level of 0 (no compression) through 9
break;
default:
$creationFunction = 'ImageCreateFromJpeg';
$outputFunction = 'ImageJpeg';
$quality=100;
break;
}
$img_r = $creationFunction($src);
if (in_array($size['mime'], array('image/gif', 'image/png')))
{
/* exit("ikooooooooooooooooooo");*/
if (!$color)
{
// If this is a GIF or a PNG, we need to set up transparency
imagealphablending($dst_r, false);
imagesavealpha($dst_r, true);
}
else
{
// Fill the background with the specified color for matting purposes
if ($color[0] == '#')
$color = substr($color, 1);
$background = FALSE;
if (strlen($color) == 6)
$background = imagecolorallocate($dst_r, hexdec($color[0].$color[1]), hexdec($color[2].$color[3]), hexdec($color[4].$color[5]));
else if (strlen($color) == 3)
$background = imagecolorallocate($dst_r, hexdec($color[0].$color[0]), hexdec($color[1].$color[1]), hexdec($color[2].$color[2]));
if ($background)
imagefill($dst_r, 0, 0, $background);
}
}
imagecopyresampled($dst_r,$img_r,0,0,$_POST['x'],$_POST['y'],$targ_w,$targ_h,$_POST['w'],$_POST['h']);
$outputFunction($dst_r, $src, $jpeg_quality);
$newsid = mysqli_real_escape_string($link,$newsid);
if(!empty($mag))
{
$db->crop2($newsid);
$newsidD = $db->base64url_encode($newsid);
header("Location: index.php?original=$photo&mag=mag&mode=effects&newsid=$newsidD&step=2&msg=Photo+cropped+successfully!");
}
else
{
$db->crop($newsid);
$newsidD = $db->base64url_encode($newsid);
header("Location: index.php?original=$photo&mode=pimpme&newsid=$newsidD&step=0&msg=Photo+cropped+successfully!");
}
}
?>