diff --git a/packages/backend/src/apps/removebg/actions/index.ts b/packages/backend/src/apps/removebg/actions/index.ts new file mode 100644 index 00000000..ce680432 --- /dev/null +++ b/packages/backend/src/apps/removebg/actions/index.ts @@ -0,0 +1,3 @@ +import removeImageBackground from './remove-image-background'; + +export default [removeImageBackground]; \ No newline at end of file diff --git a/packages/backend/src/apps/removebg/actions/remove-image-background/index.ts b/packages/backend/src/apps/removebg/actions/remove-image-background/index.ts new file mode 100644 index 00000000..2c66c891 --- /dev/null +++ b/packages/backend/src/apps/removebg/actions/remove-image-background/index.ts @@ -0,0 +1,82 @@ +import defineAction from '../../../../helpers/define-action'; + +export default defineAction({ + name: 'Remove image background', + key: 'removeImageBackground', + description: + 'Removes the background of an image.', + arguments: [ + { + label: 'Image file', + key: 'imageFileB64', + type: 'string' as const, + required: true, + variables: true, + description: 'Provide a JPG or PNG file in Base64 format, up to 12 MB (see remove.bg/supported-images)', + }, + { + label: 'Size', + key: 'size', + type: 'dropdown' as const, + required: true, + value: 'auto', + options: [ + { label: 'Auto', value: 'auto' }, + { label: 'Preview (up to 0.25 megapixels)', value: 'preview' }, + { label: 'Full (up to 10 megapixels)', value: 'full' }, + ] + }, + { + label: 'Background color', + key: 'bgColor', + type: 'string' as const, + description: 'Adds a solid color background. Can be a hex color code (e.g. 81d4fa, fff) or a color name (e.g. green)', + required: false, + }, + { + label: 'Background image URL', + key: 'bgImageUrl', + type: 'string' as const, + description: 'Adds a background image from a URL.', + required: false, + }, + { + label: 'Output image format', + key: 'outputFormat', + type: 'dropdown' as const, + description: 'Note: Use PNG to preserve transparency', + required: true, + value: 'auto', + options: [ + { label: 'Auto', value: 'auto' }, + { label: 'PNG', value: 'png' }, + { label: 'JPG', value: 'jpg' }, + { label: 'ZIP', value: 'zip' } + ] + } + ], + async run($) { + const imageFileB64 = $.step.parameters.imageFileB64 as string; + const size = $.step.parameters.size as string; + const bgColor = $.step.parameters.bgColor as string; + const bgImageUrl = $.step.parameters.bgImageUrl as string; + const outputFormat = $.step.parameters.outputFormat as string; + + const body = JSON.stringify({ + image_file_b64: imageFileB64, + size: size, + bg_color: bgColor, + bg_image_url: bgImageUrl, + format: outputFormat + }); + + const response = await $.http.post('/removebg', body, { + headers: { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + }, + }); + + $.setActionItem({ raw: response.data }); + } +}); diff --git a/packages/backend/src/apps/removebg/index.ts b/packages/backend/src/apps/removebg/index.ts index c9827811..4ac8f5e7 100644 --- a/packages/backend/src/apps/removebg/index.ts +++ b/packages/backend/src/apps/removebg/index.ts @@ -1,6 +1,7 @@ import defineApp from '../../helpers/define-app'; import addAuthHeader from './common/add-auth-header'; import auth from './auth'; +import actions from './actions'; export default defineApp({ name: 'Remove.bg', @@ -13,4 +14,5 @@ export default defineApp({ primaryColor: '55636c', beforeRequest: [addAuthHeader], auth, + actions, }); diff --git a/packages/docs/pages/.vitepress/config.js b/packages/docs/pages/.vitepress/config.js index c085c31e..04d3fdcf 100644 --- a/packages/docs/pages/.vitepress/config.js +++ b/packages/docs/pages/.vitepress/config.js @@ -303,7 +303,10 @@ export default defineConfig({ text: 'Remove.bg', collapsible: true, collapsed: true, - items: [{ text: 'Connection', link: '/apps/removebg/connection' }], + items: [ + { text: 'Actions', link: '/apps/removebg/actions' }, + { text: 'Connection', link: '/apps/removebg/connection' } + ], }, { text: 'RSS', diff --git a/packages/docs/pages/apps/removebg/actions.md b/packages/docs/pages/apps/removebg/actions.md new file mode 100644 index 00000000..954ddc3e --- /dev/null +++ b/packages/docs/pages/apps/removebg/actions.md @@ -0,0 +1,12 @@ +--- +favicon: /favicons/removebg.svg +items: + - name: Remove Image Background + desc: Remove backgrounds 100% automatically in 5 seconds with one click. +--- + + + + \ No newline at end of file diff --git a/packages/docs/pages/guide/available-apps.md b/packages/docs/pages/guide/available-apps.md index 1e32d44b..90f8ba0a 100644 --- a/packages/docs/pages/guide/available-apps.md +++ b/packages/docs/pages/guide/available-apps.md @@ -31,7 +31,7 @@ The following integrations are currently supported by Automatisch. - [PostgreSQL](/apps/postgresql/actions) - [Pushover](/apps/pushover/actions) - [Reddit](/apps/reddit/triggers) -- [Remove.bg](/apps/removebg/connection) +- [Remove.bg](/apps/removebg/actions) - [RSS](/apps/rss/triggers) - [Salesforce](/apps/salesforce/triggers) - [Scheduler](/apps/scheduler/triggers)