Automatic product analysis and product image adaptation

Topic summary

Main topic: Automating bulk product image handling and product visibility in a new Shopify store with 10,000+ products.

Requirements:

  • If a product has no image: automatically add a tag and exclude/hide these products from display.
  • If a product has an image: classify it as either a “Marketing image” or a “lifestyle image.”
    • For “Marketing image”: make the background transparent (background removal).
    • For “lifestyle image”: apply a predefined shape (likely a consistent mask/crop).

Context:

  • The requester is proficient in Python but not in JavaScript or Shopify specifics, and is seeking tips or approaches to implement this workflow.

Status and outcomes:

  • No solutions, decisions, or action items have been posted yet.
  • The thread remains open with unanswered questions on how to perform image classification and transformations within Shopify workflows or via external automation.
Summarized with AI on January 7. AI used: gpt-5.

Hi, I’m very new to Shopify, we recently built our webshop and have 10.000+ products. I need the following to happen to all the products: if there is no image of the product, I want to add a tag, and not show these products anymore.
If there is an image, I want to check if the image is a ‘Marketing image‘, and if so, have the background made transparent. If the image is a ‘lifestyle image‘ it should get a predefined shape.

I’m quite handy with Python, but not at all with Javascript, or even Shopify itself. Any tips would be appreciated!

1 Like

The first part can be done with a spreadsheet editor - you can filter empty product image fields and add tags to the products to make them inactive (or directly deactivate them)

Hi @PhilipRuijten
@K_Br4 got it, sanitize data before ingest or your just creating headaches.
When you control the upstream tagging based on empty columns is a literal formula in excel/google-sheets to do before involving or even thinking about yet another system.

Because image manipulation is involved if doing a bunch of stuff like this by stitching services together look at N8N for python automation.
https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.code/#python-native

Use shopify-flow or a full fledge automation app like mechanic and build custom processes:
examples https://tasks.mechanic.dev/?tags=Auto-Tag%2CProducts

If you have time to waste try the “AI” to randomly generate a single-page-app(SPA app*) in the admin
https://help.shopify.com/en/manual/shopify-admin/productivity-tools/sidekick/generate-apps

Do that before shopify is even involved.
That has nothing to do with shopify and is a magnitude of complexity in difference.
In what way would you expect a third party CMS system to even know what a “‘Marketing image‘” is and or then do arbitrary image editing** / graphic design.
Otherwise your looking for media personalization services, apps or rolling your own computer vision app.

**Shopify magic can edit images ONE image at a time manually inside the product admin, this is not automatable in any official capacity or even that reliable if you know how because it’s just a LLM.

Use the dev docs and ask the AI assistant for sample code YOU then VERIFY and research.
About the product media in graphql.

:judge: Emphasis on SAMPLE code you must take responsibility for what it randomly generates.

e.g.

/* not tested */
query ProductHasMediaWithType($id: ID!) {
  product(id: $id) {
    id
    title
    media(first: 1) {
      edges {
        node {
          id
          mediaContentType
        }
      }
    }
  }
}

You have 10,000+ products and want to:

  1. Tag products without images and hide them from storefront.

  2. Process images depending on type:

    • Marketing images: make background transparent

    • Lifestyle images: apply predefined shape


Step 1: Tag products without images

Since you’re comfortable with Python, the Shopify Admin API + Python is perfect for this.

Steps:

  1. Install the Python Shopify API client:
pip install ShopifyAPI

  1. Python script to tag products without images:
import shopify

# Shopify API setup
API_KEY = "YOUR_API_KEY"
PASSWORD = "YOUR_PASSWORD"
SHOP_NAME = "your-shop-name.myshopify.com"

shop_url = f"https://{API_KEY}:{PASSWORD}@{SHOP_NAME}/admin"
shopify.ShopifyResource.set_site(shop_url)

# Iterate over products
products = shopify.Product.find(limit=250)
while products:
    for product in products:
        if not product.images:
            # Add tag
            tags = product.tags.split(",") if product.tags else []
            if "no-image" not in tags:
                tags.append("no-image")
                product.tags = ",".join(tags)
                product.save()
    # Get next page
    products = products.next_page()

:white_check_mark: This automatically tags all products without images.

Tip: Then, in your theme or Shopify collections, you can exclude products with the no-image tag so they don’t appear on the storefront.


Step 2: Process product images

Shopify itself doesn’t do image editing (transparency, shapes, etc.). You’ll need Python + an image library like Pillow or OpenCV.

Example: Make marketing images transparent

from PIL import Image

img = Image.open("marketing_image.jpg")
img = img.convert("RGBA")

datas = img.getdata()
newData = []
for item in datas:
    # If white background, make transparent
    if item[0] > 240 and item[1] > 240 and item[2] > 240:
        newData.append((255, 255, 255, 0))
    else:
        newData.append(item)

img.putdata(newData)
img.save("marketing_image_transparent.png")

Example: Apply shape to lifestyle image

from PIL import Image, ImageDraw

img = Image.open("lifestyle_image.jpg").convert("RGBA")
mask = Image.new("L", img.size, 0)
draw = ImageDraw.Draw(mask)
draw.ellipse((0,0,img.size[0], img.size[1]), fill=255)  # Circular mask

img.putalpha(mask)
img.save("lifestyle_image_shaped.png")


Step 3: Upload processed images back to Shopify

After processing:

product = shopify.Product.find(PRODUCT_ID)
image = shopify.Image()
image.src = "https://your-server.com/processed_image.png"
product.images = [image]
product.save()

You can replace the old image or add it as a new one.


Step 4: Automate for all products

  • Loop through all products

  • Identify marketing vs lifestyle images (you may use naming conventions or tags)

  • Apply the right processing

  • Upload back via Shopify API


Optional Tip for Hiding Products

  • Create a collection that excludes no-image products

  • Or add a theme filter in your product loop:

{% unless product.tags contains 'no-image' %}
  <!-- show product -->
{% endunless %}


:white_check_mark: Summary

  • Use Python + Shopify API for tagging and uploading images

  • Use Pillow to process images (transparency, shapes)

  • Use Liquid filters or collections to hide unwanted products

  • Fully automatable for thousands of products

Hi,

Hope this will help

  • Use Python and Shopify Admin API to scan all products
  • Tag or draft products with no images
  • Classify images externally (Shopify can’t do this)
  • Process images outside Shopify then re-upload
  • Store image type in tags or metafields
  • Let theme only handle display not logic
  • Biggest conversion issue: trust, clarity and presentation