( ′∀`)σ≡σ☆))Д′)レ(゚∀゚;)ヘ=З=З=Зε≡(ノ´_ゝ`)ノ
<?php
if(!empty($row['params'])){
$params = json_decode("[".$row['params']."]");
$width = $params[0]->width;
$height = $params[0]->height;
}
if(!empty($_GET['convoId']))
{
$profile_image_url = $json[0]->user->profile_image_url;
$picme = str_replace("_normal","",$profile_image_url) ;
}
else{
$picme=profilepicture();
}
$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'];
$str = $picme;
$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";
}
else{
if(!empty($_GET['convoId']))
{
$brand ="$str";
}
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";
}
}
$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;
}
if (($row['width'] > $width_orig) && ($row['height'] > $height_orig))
{
$layer_w = $row['width'];
$layer_h = $row['height'];
}
$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+5,$layer_h+5, $layer_x,$layer_y);