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.
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!
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.
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.
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
}
}
}
}
}
Tag products without images and hide them from storefront.
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:
Install the Python Shopify API client:
pip install ShopifyAPI
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()
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")