( ′∀`)σ≡σ☆))Д′)レ(゚∀゚;)ヘ=З=З=Зε≡(ノ´_ゝ`)ノ
<?php
$brand = $_GET["image"];
$picture = explode('.',$brand);
$ext = strtolower($picture[1]);
$imageFolder ="v/uploads/gthumbs/$brand";
$imageFolder ="$brand";
switch ($ext)
{
case '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
$doSharpen = FALSE;
$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 'png':
$creationFunction = 'ImageCreateFromPng';
$outputFunction = 'ImagePng';
$doSharpen = FALSE;
$quality = round(10 - ($quality / 10)); // PNG needs a compression level of 0 (no compression) through 9
break;
default:
$creationFunction = 'ImageCreateFromJpeg';
$outputFunction = 'ImageJpeg';
$doSharpen = FALSE;
break;
}
$brand = $creationFunction("v/uploads/gthumbs/$brand");
$layer_w = $_GET["layer_w"];
$layer_h = $_GET["layer_h"];
$foto2W = imagesx($brand);
$foto2H = imagesy($brand);
$w_ratio = ($layer_w / $foto2W);
$h_ratio = ($layer_h / $foto2H);
if ($foto2W > $foto2H ) {//landscape
$crop_w = round($foto2W * $h_ratio);
$crop_h = $layer_h;
$src_x = ceil( ( $foto2W - $foto2H ) / 2 );
$src_y = 0;
if($crop_w < $layer_w) {
$foto2W2 = $layer_w;
$crop_w2 = $crop_w;
$crop_w = $layer_w;
$w_ratio2 = ($foto2W2/$crop_w2);
$crop_w = round($layer_w * $w_ratio2);/**/
$src_y = 0;
}
} elseif ($foto2W < $foto2H ) {//portrait
$crop_h = round($foto2H * $w_ratio);
$crop_w = $layer_w;
$src_x = 0;
$src_y = ceil( ( $foto2H - $foto2W ) / 2 );
if($layer_h>$crop_h ) {
$foto2H2 = $layer_h;
$crop_h2 = $crop_h;
$crop_h = $layer_h;
$h_ratio2 = ($foto2H2/$crop_h2);
$crop_w = round($layer_w * $h_ratio2);
$src_y = 0;
}
} else {//square
$crop_w = $layer_w;
$crop_h = $layer_h;
}
$src_x = 0;
$src_y = 14;
$src_x = 0;
$src_y = 0;
$realSizeW = $layer_w;
$realSizeH = $layer_h;
$background2W = $crop_w;
$background2H = $crop_h;
$background2 = imagecreatetruecolor($realSizeW,$realSizeH);
imagecopyresampled($background2, $brand, 0 , 0 , $src_x, $src_y, $crop_w, $crop_h, $foto2W, $foto2H);
header("Content-type: image/jpg");
imagejpeg($background2, null, 100);
?>