Comments (6)
Let me check this issue too.
from backgroundremover.
Hello @daslicht , I will check the API and I will let you know once the problem is fixed.
from backgroundremover.
Nice ! another issue is that batch processing isnt working, I replaced curl for downloading teh images since my server has outdated openssl, thre seams to go something wrong in the get_results
function
<?
use Functions as F;
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ERROR | E_PARSE);
class BackgroundRemoverAPI
{
private $headers;
private $api_url;
private $results_url;
// private function download_file($url, $filename) : void
// {
// $curl = curl_init();
// $url = "https://api.backgroundremoverai.com" . $url;
// echo $url;
// curl_setopt($curl, CURLOPT_URL, $url);
// curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
// curl_setopt($curl, CURLOPT_SSLVERSION, 3);
// $data = curl_exec($curl);
// $error = curl_error($curl);
// var_dump($data );
// curl_close($curl);
// # Make sure destination path exists
// $destination_path = "./processed_images/";
// $destination_file = fopen($destination_path . $filename, "w+");
// fwrite($destination_file, $data);
// fclose($destination_file);
// }
private function download_file($url, $filename) : void
{
$url = "https://api.backgroundremoverai.com" . $url;
$destination_path = "./processed_images/";
if (file_put_contents($destination_path.$filename, file_get_contents($url)))
{
echo "File downloaded successfully";
}
else
{
echo "File downloading failed.";
}
}
private function get_results($params)
{
if (isset($params->error)) {
print_r($params->error);
return;
}
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $this->results_url);
curl_setopt($curl, CURLOPT_HTTPHEADER, $this->headers);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, json_decode(json_encode($params), true));
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$content = json_decode(curl_exec($curl));
curl_close($curl);
if ($content->finished == false) {
if (intval($content->queue_count) > 0) {
print_r("queue: $content->queue_count");
}
sleep(5);
$results = $this->get_results($params);
return;
}
foreach ($content->files as $f) {
$this->download_file($f->url, $f->filename);
}
}
public function convert_files(array $file_list) : void
{
$post_data['lang'] = 'en';
$post_data['convert_to'] = 'image-backgroundremover';
foreach ($file_list as $index => $file) {
$post_data['file[' . $index . ']'] = curl_file_create(
realpath($file),
mime_content_type($file),
basename($file)
);
}
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $this->api_url);
curl_setopt($curl, CURLOPT_HTTPHEADER, $this->headers);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$content = curl_exec($curl);
curl_close($curl);
$this->get_results( json_decode($content) );
//return json_decode($content);
}
function __construct()
{
//$this->file_list = $files_list;//['/path/to/files/blah.jpeg'];
$this->headers = array("Authorization: 08144e1b39cc41a190d691242edaad61");
$this->api_url = "https://api.backgroundremoverai.com/v1/convert/";
$this->results_url = "https://api.backgroundremoverai.com/v1/results/";
}
}
//$resp = convert_files($file_list, $headers, $api_url);
//get_results($resp, $results_url, $headers);
from backgroundremover.
I have the same problem as you, with high probability is your image exif info contains rotating info. you can try:
from PIL import Image, ImageOps
img = Image.open('path/to/image').convert('RGB')
img = ImageOps.exif_transpose(img)
from backgroundremover.
thanks will try what is PIL?
from backgroundremover.
thanks will try what is PIL?
pythom Image library. The basic idea is to process the exif information of the image. you need to deal with it yourself if you use other language
from backgroundremover.
Related Issues (20)
- Great god, come on!
- How to use in a Android App ? HOT 1
- How to use as a library ? HOT 2
- Does this software support batch JPG processing? HOT 1
- Anyone can help? thanks HOT 6
- Error initializing filter 'alphamerge' with args 'shortest=1' HOT 3
- May I ask how to make a model
- Video removal produces mask only? HOT 4
- transparent mov not created HOT 1
- video over image not working HOT 1
- Server Requirements? HOT 2
- Mismatch Between GitHub and PyPI Versions of backgroundremover v0.2.7 HOT 3
- Solved - ValueError: invalid literal for int() with base 10: '9222,\n\n' HOT 2
- It doesn't use GPU and runs much slower on Intel CPU
- How to start http server. ?
- Some elements of the background of the image are lost HOT 1
- API Usage Problem
- HEIC support
- The backgound still exists in my generated video. OS is ubuntu 22.04 HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from backgroundremover.