( ′∀`)σ≡σ☆))Д′)レ(゚∀゚;)ヘ=З=З=Зε≡(ノ´_ゝ`)ノ
<?php
$themeid = $_GET["theme_id"];
$row = getParamJSONTheme($themeid);
if(!empty($row['params'])){
$params = json_decode("[".$row['params']."]");
$width = $params[0]->width;
$height = $params[0]->height;
}
else
{
$width =600;
$height = 600;
}
$brand ="8b2d084dac2ed9b7d8e14fd5ce2bed6f.jpg";
$amount=100;$sizeW=7; $sizeH=7; $posX=0; $posY=0;$gridWidth=10;$gridHeight=10;
$cellWidth = $width / $gridWidth;
$cellHeight = $height / $gridHeight;
// Getting top left and bottom right of our rectangle
$topLeftX = $realPosX;
$realPosY = $realPosY;
$bottomRightX = $realPosX + $realSizeW;
$bottomRightY = $realPosY + $realSizeH;
// Conversion of our virtual sizes/positions to real ones
$realSizeW = ($cellWidth * $sizeW)-2; //with borders
$realSizeH = ($cellHeight * $sizeH)-2;
$realSizeW = 100; //with borders
$realSizeH = 100;
$realPosX = 40;
$realPosY = 70;
// Getting top left and bottom right of our rectangle
$topLeftX = $realPosX;
$realPosY = $realPosY;
$bottomRightX = $realPosX + $realSizeW;
$bottomRightY = $realPosY + $realSizeH;
$picture = explode('.',$brand);
$ext = strtolower($picture[1]);
$imageFolder ="v/uploads/gthumbs/$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");
$foto2W = imagesx($brand);
$foto2H = imagesy($brand);
$srcRatio = $foto2W / $foto2H;
$targetRatio = $realSizeW / $realSizeH;
if ( $srcRatio >= $targetRatio )
{
// If image is wider than thumbnail (in aspect ratio sense)
$background2H = $realSizeH;
$background2W = $foto2W / ( $foto2H / $realSizeH);
}
else
{
// If the thumbnail is wider than the image
$background2W = $realSizeW;
$background2H = $foto2H / ($foto2W / $realSizeW);
}
$background2 = imagecreatetruecolor( $realSizeW, $realSizeH );
$brand = imagecopyresampled($background2,
$brand,
0 - ($background2W - $realSizeW) / 2, // Center the image horizontally
0 - ($background2H - $realSizeH) / 2, // Center the image vertically
0, 0,
$background2W, $background2H,
$foto2W, $foto2H);
imagecopyresampled($background, $brand, $realPosX, $realPosY, 0, 0, $realSizeW, $realSizeH, imagesx($brand), imagesy($brand));
imagecopy($background, $background2,$topLeftX, $realPosY, 0, 0, imagesx($background2), imagesy($background2));
?>