( ′∀`)σ≡σ☆))Д′)レ(゚∀゚;)ヘ=З=З=Зε≡(ノ´_ゝ`)ノ
<?php
if(!empty($row['params'])){
$params = json_decode("[".$row['params']."]");
$width = $params[0]->width;
$height = $params[0]->height;
}
$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'];
if (!empty($_GET['newPic']))
{ $str = $_GET['newPic'];
if (strpos($str, '[STARTAG]-') !== false) {
include("codenewStartag.php");
}
else{
$str = $_GET['newPic'];
}}
$brand =basename($str);
$brand =basename($str);
$brand=explode('&', $brand);
$brand=$brand[0];
$picture = explode('.',$brand);
$ext = strtolower($picture[1]);
$fileTitle = $picture[0] ;
$imageFolder ="v/uploads/gthumbs/$brand";
$imageFolderNoBG ="v/uploads/gthumbs/bg_gone_$fileTitle.png";
if (file_exists($imageFolderNoBG) ){
$brand="bg_gone_$fileTitle.png";
$filesize = filesize("v/uploads/gthumbs/bg_gone_$fileTitle.png");
if($filesize < 100) { unlink("v/uploads/gthumbs/bg_gone_$fileTitle.png");$brand = basename($_GET['newPic']);}
}
/*elseif(strpos($fileTitle, 'bg_gone_') !== false){
$brand="$brand";
}*/else{
// Generated by curl-to-PHP: http://incarnate.github.io/curl-to-php/
$url = "https://api.remove.bg/v1.0/removebg";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'x-api-key:NKLSR5Eh6PRdHrgTk7ZbkUvD',
]);
// move image_url here:
curl_setopt($ch, CURLOPT_POSTFIELDS, [
'image_url' => "http://localhost/thebrand/v/uploads/gthumbs/$str",
]);
$server_output = curl_exec($ch);
$fp = fopen("v/uploads/gthumbs/bg_gone_$fileTitle.png", "wb");
fwrite($fp, $server_output);
fclose($fp);
curl_close($ch);
/* $theme_id = $_GET['theme_id'];
$nani = $_GET['nani'];*/
$imageX = basename($imageFolderNoBG);
/* global $link;
$query = mysqli_query($link,"INSERT INTO general_file_manager(uid, file_name) VALUES('$nani', '$imageX')") or die(mysql_error()); */
$brand="bg_gone_$fileTitle.png";
if (!file_exists("v/uploads/gthumbs/bg_gone_$fileTitle.png") ){
$brand = basename($_GET['newPic']);
}
}
$picture = explode('.',$brand);
$ext = strtolower($picture[1]);
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;
}
$resourceNewBg = $creationFunction("v/uploads/gthumbs/$brand");
$width_orig = imagesx($resourceNewBg);
$height_orig = imagesy($resourceNewBg);
$ratio_orig = $width_orig/$height_orig;
if ($layer_w/$layer_h > $ratio_orig) {
$layer_w = $layer_h*$ratio_orig;
} else {
$layer_h = $layer_w/$ratio_orig;
}
$old_layer_x=$row['left']['desktop'];
$old_layer_y=$row['top']['desktop'];
$old_layer_w=$row['width'];
$old_layer_h=$row['height'];
if($old_layer_h > $layer_h)
{
$displacement = ($old_layer_h - $layer_h)/2;
$layer_y = $layer_y + $displacement;
}
if($old_layer_w > $layer_w)
{
$displacement = ($old_layer_w - $layer_w)/2;
$layer_x = $layer_x + $displacement;
}
MakeGridPictureX($background, $brand , 100,10,10, 0, 0,10,10, $layer_w,$layer_h, $layer_x,$layer_y);
$themeid = $_GET["theme_id"];
$row = getParamJSONTheme($themeid);
if(!empty($row['params'])){
$params = json_decode("[".$row['params']."]");
$width = $params[0]->width;
$height = $params[0]->height;
}
$layer_x=$row['left']['desktop'];
$layer_y=$row['top']['desktop'];
$layer_w=$row['width'];
$layer_h=$row['height'];
$layeropacity=$row['deformation']['opacity'];
include("fxNew.php");