Api settings only crop/padding

We’re using the API for background removal, adding ai shadows + center / auto-cropping. As the removal and ai shadows are still not working properly, we have to use a different tool for that now. For now only for the padding / auto-cropping is needed for the api. Could you help with that? So input will be a transparant image > api process only crop / auto-center. Thanks.

Hi @martijnkersten ,

Could you please share a bit more regarding your issue with AI Shadows/ Center/ Auto-Cropping not working properly?

For example, giving us the output image result and what you were expecting to receive, along with the actual parameters that you were using so we can take a look into this.

As for your additional results, we have some documentation specified on this. We also have a playground you can use to configure your image and have the parameters created for you.

Let us know if anything is unclear?

Best,

Allie

Hi Allie,

We solved the padding thing. But we still can’t figure out why the quality is so bad after it goes through the process (even when we selected original resolution as output size). It’s very compressed / lacks sharpness etc.

Have a look (original + after it went through the api)

Hey @martijnkersten ,

Thanks for sharing the original and output images. I went ahead and re-ran your image through the API with the following parameters:

removeBackground = true

shadow.mode = ai.soft

referenceBox = original image

horizontalAlignment = center

verticalAlignment = center

pr-hd-background-removal = auto

And received this result:

The two things to note here are

  1. The resolution size of your input image is greater than that of your output size, but we automatically default to the original resolution and output size - if you share the parameters of your output call I can take a look at why the result image was altered.
  2. I used the pr-hd-background-removal: this parameter is recommended when you want to remove the background of a high-resolution image (≥ 2K) to get more detailed subject edges

Let me know if you want to share those parameters, or if you have any other questions!

Hi, thanks for getting back and test this, tried it with original as output as well.

As we getting some grey noise over the whole frame when we don’t use photorooms ‘transparant background’ anymore, we now go for a solid off-white background (where those issues are not happening, ) but still the overalll quality is not amazing / much less than original.

This is what we use.

$headers = [
‘pr-background-removal-model-version’ => ‘2025-03-28’,
];

// Add AI shadows model version if configured in env
$aiShadowsVersion = App::parseEnv(‘$PHOTOROOM_AI_SHADOWS_VERSION’);
if ($aiShadowsVersion) {
$headers[‘pr-ai-shadows-model-version’] = $aiShadowsVersion;
}

return $this->post($client, ‘edit’, [
‘headers’ => $headers,
‘multipart’ => [
[
‘name’ => ‘imageFile’,
‘contents’ => $resource
],
[
‘name’ => ‘background.color’,
‘contents’ => ‘#FBF9F8
],
[
‘name’ => ‘shadow.mode’,
‘contents’ => ‘ai.soft’
],
[
‘name’ => ‘padding’,
‘contents’ => ‘0.1’
],
[
‘name’ => ‘outputSize’,
‘contents’ => ‘originalImage’
]
]
]);

Hey @martijnkersten ,

I recreated with your exact parameters and my output image retains the original size of the input image. You might want to try again.

To improve the sharpness around the edges of the glasses, I would recommend trying the HD Background Removal Parameter. You can read more about the functionality here.

Thanks!

Hi, so we just have to add the pr-hd-background-removal = auto ?

As we also alrady have this one in it: pr-background-removal-model-version’ => ‘2025-03-28’,

Hey @martijnkersten ,

Yes exactly, pr-hd-background-removalis an additional parameter you’d add in addition to your existing background removal parameters.