Photoroom
    Photoroom
    • Remove Background (Basic plan)
      POST
    • Account Details
      GET
    • Image Editing v2 (Plus plan)
      GET
    • Image Editing v2 (Plus plan)
      POST
    • [LEGACY] Image Editing v1 (Plus plan)
      GET
    • [LEGACY] Image Editing v1 (Plus plan)
      POST

      Image Editing v2 (Plus plan)

      Production server (Plus plan)
      https://image-api.photoroom.com
      Production server (Plus plan)
      https://image-api.photoroom.com
      POST
      /v2/edit
      This endpoint processes an image, removing the background if specified, and applies various transformations such as scaling, padding, and margin adjustments. It accepts binary data for the image. If you want to send the URL of an image, please use the GET endpoint. For more details on the difference between the GET and POST endpoints, please have a look at our documentation: https://docs.photoroom.com/image-editing-api/which-endpoints-are-available. The output size, background color or image, and other parameters can be customized.
      请求示例请求示例
      Shell
      JavaScript
      Java
      Swift
      curl --location --request POST 'https://image-api.photoroom.com/v2/edit' \
      --header 'x-api-key;'
      响应示例响应示例
      200 - 示例 1
      {}

      请求参数

      Header 参数
      x-api-key
      string 
      必需
      Body 参数multipart/form-data
      background.color
      string 
      可选
      Color of the background. If omitted, background will be transparent unless background.imageUrl or background.imageFile is provided.
      Can be a hex color without the hash sign (example: FF0000, FFF, FF0000EE) or color name (examples: red, blue)
      Can't be provided if removeBackground is set to false
      background.imageFile
      file 
      可选
      IMPORTANT: this argument is currently NOT supported. Please use background.imageUrl to provide an image for the background.
      Bytes of the image to use as a background. Only available in the POST request
      Can't be provided if removeBackground is set to false
      If background.imageUrl is provided, neither background.imageFile nor background.prompt can be provided, and vice versa.
      background.negativePrompt
      string 
      可选
      [Advanced] A negative prompt to use for guiding the background generation process;
      If provided, the generation algorithm will try to avoid properties listed in the negativePrompt.
      background.prompt
      string 
      可选
      Prompt to use for guiding the background generation process.
      background.scaling
      string 
      可选
      Whether the background should fit or fill (default) the output image
      If set to fit, the empty pixels will be transparent
      Can only be provided if background.imageUrl or background.imageFile is provided
      background.seed
      number 
      可选
      Seed used to generate the background. Can be used to get similar looking results for the same prompt.
      export.format
      string 
      可选
      The format of the result image.
      Supported values are "png", "jpeg" and "jpg".
      Default value is "png".
      horizontalAlignment
      string 
      可选
      [Advanced] Defines the horizontal alignment of the cutout subject within its bounding box.
      Specifying a custom horizontal alignment will implicitly set ignorePaddingAndSnapOnCroppedSides to false for the horizontal direction.
      ignorePaddingAndSnapOnCroppedSides
      boolean 
      可选
      If set to true (default), cropped sides of the subject will snap to the edges
      For instance, for a portrait image cropped below the elbows, the subject will be aligned at the bottom
      even if a bottom padding is provided (but it will still respect bottom margin)
      Can't be provided if removeBackground is set to false
      (See positioning section of the documentation for more information)
      imageFile
      file 
      可选
      Bytes of the main image used by the API. The POST endpoint accepts imageFile only.
      The maximum size of the image is 30MB.
      If you want to send the URL of an image, please instead use the GET endpoint with the argument imageUrl.
      lighting.mode
      string 
      可选
      Lighting mode to use on the main image used by the API.
      If set to ai.auto, the lighting will be automatically adjusted
      margin
      number 
      可选
      [Advanced] Margin around the subject. Expressed in a ratio of the output image size.
      Unlike padding, margin is never ignored even on cropped sides of the subject.
      (See positioning section of the documentation for more information)
      marginBottom
      number 
      可选
      [Advanced] Bottom Margin, overrides margin argument on the Bottom side if provided
      marginLeft
      number 
      可选
      [Advanced] Left Margin, overrides margin argument on the left side
      marginRight
      number 
      可选
      [Advanced] Right Margin, overrides margin argument on the right side if provided
      marginTop
      number 
      可选
      [Advanced] Top Margin, overrides margin argument on the Top side if provided
      maxHeight
      number 
      可选
      Maximum output height. Can only be provided if outputSize is originalImage or croppedSubject.
      Useful for: redimensioning while keeping the aspect ratio
      maxWidth
      number 
      可选
      Maximum output width. Can only be provided if outputSize is originalImage or croppedSubject.
      Useful for: resizing an image while keeping the aspect ratio
      outputSize
      string 
      可选
      Output size of the image. In the form of either:
      widthxheight for a custom size (example: 200x400)
      originalImage to keep the original image dimensions
      croppedSubject to use the size of the foreground dimensions after cropping around it
      padding
      number 
      可选
      Padding around the subject. Unlike margin, it will be ignored on cropped sides of the subject if the option is enabled
      Expressed in a ratio of the size of the document, minus margins (similar to CSS)
      (See positioning section of the documentation for more information)
      paddingBottom
      number 
      可选
      Bottom Padding, overrides padding argument on the Bottom side if provided
      paddingLeft
      number 
      可选
      Left Padding, overrides padding argument on the left side
      paddingRight
      number 
      可选
      Right Padding, overrides padding argument on the right side if provided
      paddingTop
      number 
      可选
      Top Padding, overrides padding argument on the Top side if provided
      referenceBox
      string 
      可选
      [Advanced] subjectBox by default. When set to originalImage, the padding / margin will be around the original image
      and not the cropped subject.
      It can lead to the subject disappearing when scaling is set to 'fill', for instance if the subject is on the left
      of a landscape image and outputSize is a square.
      Most use cases don't require this option. It is useful if you'd like to maintain subject positioning in the original image.
      Can't be provided if removeBackground is set to false
      (See positioning section of the documentation for more information)
      removeBackground
      boolean 
      可选
      If enabled (default), the background of the image will be removed using PhotoRoom's award-winning algorithm
      scaling
      string 
      可选
      Whether the subject should fit (default) or fill the output image
      If set to fit, the empty pixels will be transparent
      Can only be provided if imageUrl or imageFile is provided
      shadow.mode
      string 
      可选
      Shadow generation mode to use on the main image used by the API.
      If set to ai.soft, a soft shadow will be generated
      If set to ai.hard, a hard shadow will be generated
      If set to ai.floating, a floating shadow will be generated
      textRemoval.mode
      string 
      可选
      Text removal mode to use on the main image used by the API.
      If set to ai.artificial, artificial text will be automatically removed.
      Artificial text includes all text added on an image through post-precessing, such as company name, watermarks, discount, etc.
      If set to ai.natural, natural text will be automatically removed.
      Natural text includes text that naturally occurs in an image such as writing on buildings or clothings, road signs, etc.
      If set to ai.all, all text (natural and artificial) will be automatically removed.
      verticalAlignment
      string 
      可选
      [Advanced] Defines the vertical alignment of the cutout subject within its bounding box.
      Specifying a custom vertical alignment will implicitly set ignorePaddingAndSnapOnCroppedSides to false for the vertical direction.

      返回响应

      🟢200OK
      application/json
      Body
      object {0}
      🟠400Bad Request
      🟠402Payment Required
      🔴500Internal Server Error
      上一页
      Image Editing v2 (Plus plan)
      下一页
      [LEGACY] Image Editing v1 (Plus plan)
      Built with