module:
   name: rmbgpro
   display_name: RMBG PRO
   description: Remove image backgrounds automatically using RMBG.PRO API
   compatibility:
      prestashop:
       - '1.7+'
       - '8+'

features:
 - Configure RMBG.PRO API key in module settings (stored via PrestaShop Configuration).
 - 'Remove Background button inside the product edit page (replaces the selected product image).'
 - Regenerates all PrestaShop product image formats (thumbnails) after replacement.
 - API key validation button (connectivity check).
 - Bulk processing tool (AJAX batches to reduce timeouts).

how_it_works:
 - The module uploads the selected product image to RMBG.PRO API and receives a processed image (base64).
 - The module replaces the original product image file.
 - The module deletes old product thumbnails and regenerates them for all configured product ImageTypes.

external_service:
   service_url: https://api.rmbg.pro/v1.0.1/remove_background
   authentication_header: X-API-KEY
   data_sent:
    - The image file you choose to process
   request_params:
      return_type: base64
      output_format: configured in module settings

installation:
 - Copy the module folder to: /modules/rmbgpro
 - Back Office: Modules -> Module Manager -> Search "RMBG PRO" -> Install
 - Then: Modules -> RMBG PRO -> Configure

configuration:
   api_key: Paste your RMBG.PRO API key.
   output_format:
      allowed:
       - png
       - jpg
       - jpeg
       - webp
       - avif
      note: PrestaShop product images are stored as JPG by default. If the API returns a non-JPG format, the module converts it to JPG before replacing the product image.

usage_single_image:
 - Catalog -> Products -> open a product
 - In the left column, find the "RMBG PRO" panel
 - Select an image ID
 - Click "Remove Background"
 - The page reloads after success

usage_bulk:
 - Modules -> RMBG PRO -> Configure
 - Click "Remove backgrounds for all product images"
 - The module processes images by batches (AJAX) and prints progress

security:
 - Admin-only usage through an Admin controller
 - CSRF protection: every AJAX request includes a back-office token validated server-side
 - File validation: extension check + 10MB limit before calling the API

troubleshooting:
   api_key_missing: Set the API key in the module configuration.
   invalid_token: Reload the Back Office page and retry.
   curl_required: Enable the PHP cURL extension.
   thumbnails_wrong: Clear cache and ensure ImageTypes are properly configured.

support:
   website: https://rmbg.pro/
   api_credits: https://rmbg.pro/profile
