( ′∀`)σ≡σ☆))Д′)レ(゚∀゚;)ヘ=З=З=Зε≡(ノ´_ゝ`)ノ
<?php
$layer_x=$row['left']['desktop'];
$layer_y=$row['top']['desktop'];
$layer_w=$row['width'];
$layer_h=$row['height'];
$layeropacity=$row['deformation']['opacity'];
$layer_r=$row['deformation']['xrotate'];
$str = $row['image_url'];
$brand =basename($str);
$brand =basename($str);
$brand=explode('&', $brand);
$brand=$brand[0];
$picture = explode('.',$brand);
$ext = strtolower($picture[1]);
$imageFolder ="v/uploads/gthumbs/$brand";
if (file_exists($imageFolder)) {
}
else{
$page_directory = dirname($row['image_url']);
$parts=parse_url($page_directory);
$path_parts=explode('/', $parts['path']);
$page_directory = $path_parts[count($path_parts)-1];
copy("v/uploads/gthumbs/$page_directory/$brand", "v/uploads/gthumbs/$brand");
}
$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 ="$brand";
$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 = $layer_w; //with borders
$realSizeH = $layer_h;
$realPosX = $layer_x;
$realPosY = $layer_y;
// 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]);
if (!empty($_GET['newPic'])) {
$details = $_GET['newPic'];
$brand = $details;
}
$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;
}
if (!empty($_GET['newPic'])) {
$details = $_GET['newPic'];
$brand = $details;
}
$brand = $creationFunction("v/uploads/gthumbs/$brand");
if(!empty($_GET['convoId']))
{
$tweetIDX = $_GET['tweetIDX'];
$row = getEachTweetPicture("$tweetIDX",0);
$url = $row["tweet_media"];
if(!empty($url))
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $brand);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // good edit, thanks!
curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1); // also, this seems wise considering output is image.
$data = curl_exec($ch);
curl_close($ch);
$brand = imagecreatefromstring($data);
}
}
$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));