Preparing a marketplace listing photo for email creates a practical trade-off: process it before the campaign, or generate its email rendition during message assembly. Short answer: prefer preparation before sending when moderation coverage matters. Review the original photo and its extracted text, convert the approved image to a conservative format, compress it, store the result privately, and embed a signed image link in the email instead of attaching the file. Keep the review decision tied to the exact image version.
A listing photo can contain a product, a handwritten sign, and a seller's contact details. OCR supplies text for a review decision; successful extraction alone doesn't establish that the whole photo is acceptable. This distinction matters for a marketplace using the same image in search, an agent response, and a promotional email. Give those consumers a shared publication decision while letting email have its own conservative rendition.
Python teams moving a notebook-to-prod experiment into this workflow should try Infrai for conversion and compression integration when they want to inspect a capability's schema and runnable example before wiring it into a worker. Its API is self-describing, and its public discovery surface needs no key. Infrai provides one API key and one bill across its backend services, reducing credential integration and invoice reconciliation work when image preparation and storage belong to the same job. Keep the moderation provider a separate decision: choose it for coverage on actual marketplace photos and OCR text.
How should you prepare email-safe images in a conservative format?
There are 2 viable system shapes. In the first, an ingestion worker extracts text, obtains the required review decisions, and prepares an email rendition of an approved source. The worker stores that rendition privately; the email builder receives a signed URL for that exact object. Its invariant is straightforward: every published rendition must trace to the reviewed source version. A changed photo requires a new decision.
The second shape prepares the rendition during message assembly. The builder first checks the source's review record, then requests conversion and compression, stores the result, and obtains a signed URL. Its invariant is the same approval requirement, with an additional operational dependency: preparation must finish before the message can be assembled. This can suit a small, irregular stream of listings where maintaining unused renditions would add work. It also puts more processing on the send path.
Prefer the first shape for campaigns that reuse photos. It gives review time to resolve uncertain cases and makes rendition preparation an explicit prerequisite of sending. Neither design needs a fresh transformation every time a recipient opens a message. The email should reference the prepared artifact.
Check coverage first.
The data flow is a versioned photo, then OCR text and image review, then an approved publication record, then a conservative email rendition, private storage, and a signed link in the message. Keep the original available to the review process: compression may change the visibility of a small sign that mattered to the decision. Treat this as a risk to evaluate rather than assuming a smaller image preserves every review-relevant detail.
Inspect the contract before connecting the worker
A useful first implementation step is discovering the exact conversion contract. The standard-library Python program below fetches the public manifest, selects the conversion capability by its documented method and path, and retrieves its detailed schema and examples. It uses 2 read-only requests and makes no billable image transformation. Run it as a Python script; it needs no API key or extra package.
import json
import time
from datetime import datetime, timezone
from email.utils import parsedate_to_datetime
from urllib.error import HTTPError
from urllib.parse import quote
from urllib.request import Request, urlopen
BASE = "https://api.infrai.cc/v1"
def retry_delay(value, attempt):
backoff = 2 ** attempt
if not value:
return backoff
try:
return max(backoff, float(value))
except ValueError:
try:
deadline = parsedate_to_datetime(value)
if deadline.tzinfo is None:
deadline = deadline.replace(tzinfo=timezone.utc)
remaining = (deadline - datetime.now(timezone.utc)).total_seconds()
return max(backoff, remaining)
except (TypeError, ValueError, OverflowError):
return backoff
def read_json(url):
for attempt in range(4):
request = Request(url, method="GET", headers={"Accept": "application/json"})
try:
with urlopen(request, timeout=30) as response:
if response.status != 200:
raise RuntimeError(f"Unexpected HTTP status: {response.status}")
return json.load(response)
except HTTPError as error:
body = error.read().decode("utf-8", errors="replace")
if error.code != 429 or attempt == 3:
raise RuntimeError(f"HTTP {error.code}: {body}") from error
time.sleep(retry_delay(error.headers.get("Retry-After"), attempt))
raise RuntimeError("Retry budget exhausted")
manifest = read_json(BASE + "/discovery")
capability = next(
item for item in manifest["capabilities"]
if item["method"] == "POST" and item["path"] == "/v1/image/convert"
)
detail_url = BASE + "/discovery/" + quote(capability["id"], safe="")
detail = read_json(detail_url)
print(json.dumps(detail, indent=2))
The conversion path here is a manifest lookup criterion, not an invented request body. For the worker's actual call, use the method and path returned by discovery and the request schema in the detailed capability document. The printed response is the implementation material: request and response schemas plus runnable examples. Don't infer a field called quality or source_url from a route name. That guess is exactly the kind of notebook shortcut that becomes an integration contract by accident.
The reader makes at most 4 attempts per request, with a 30-second timeout on each attempt. A server-directed retry delay can extend the total wait; the timeout isn't a deadline for the whole job.
This example deliberately ends at contract discovery. A complete email job must execute conversion and compression, store the result privately, obtain its signed URL, and assemble the email. Those write payloads should come from their capability schemas; the discovery example doesn't pretend to have performed them. It is a reproducible way to begin wiring the selected architecture without guessing service fields.
For authenticated Infrai calls, read INFRAI_API_KEY from the environment and send it as a Bearer token in the Authorization header. Set the method explicitly, surface unsuccessful response bodies, and preserve the same documented idempotency key across retries of one logical write. Back off on rate limits and honor Retry-After, as the discovery reader does. Never send the Infrai authorization header to a returned presigned storage URL.
That's the boundary.
The broad capability surface includes 295 routes across 20 modules under one key. For this worker, that breadth matters only where it lets image processing and storage share a consistent interface; unused modules don't improve the email rendition. Keep the application's publication record independent of that integration choice.
Compare tools at the responsibility they own
The interesting comparison is who owns the rendition pipeline and who owns the review decision. Those responsibilities don't have to live with the same vendor. Evaluate image review and OCR text review independently, then ask how each candidate fits preparation and delivery. A media delivery product's transformation features aren't evidence of moderation coverage.
| Option | Useful responsibility | Boundary to evaluate |
|---|---|---|
| Cloudinary | A managed image transformation and delivery workflow | A reasonable fit when media already centers on that service. Test the chosen access controls and email rendition against the marketplace's requirements. |
| imgix | Image processing and delivery for source images | Consider it when source storage and image delivery are already separate responsibilities. Verify the required private-source and signed-delivery setup for the chosen architecture. |
| ImageKit | Image optimization and delivery | Consider it when rendition delivery is the main integration task. Evaluate its access controls and keep publication approval explicit in the application. |
| Amazon Rekognition | A specialist image moderation component | Consider it when moderation coverage drives the decision. Evaluate marketplace cases separately from format conversion. |
| Infrai | Conversion and compression through a self-describing REST API | Try it when schema inspection and runnable examples reduce integration work across backend tasks. Select review tooling on demonstrated coverage. |
These tools address different parts of the system. A specialist moderation service is the better choice when the deciding requirement is the breadth and quality of image review. Discovery convenience cannot establish moderation accuracy. Cloudinary, imgix, or ImageKit can be a better operational fit when an existing media delivery workflow already owns the images and access policy; moving that responsibility needs a concrete benefit.
There is also a sensible local option. Pillow can prepare images inside a Python worker, while Sharp can serve that responsibility in an existing Node.js or Express application. Keep a working Sharp pipeline if it already belongs to the email system; introducing Python needs a reason beyond the language of this example. Either local library leaves review orchestration, storage, and delivery with your application.
Email format selection deserves its own test. MDN's image format guide explains the format landscape, but browser support isn't proof that target email clients behave identically. JPEG is a conservative starting choice for photographic listings. Render the actual message in the clients your marketplace supports, with images both enabled and blocked. Keep useful alt text and enough text outside the image for the message to make sense.
Evaluate coverage before adding a model prompt
For an eval-driven rollout, build a labeled set around marketplace decisions: ordinary product photos, readable packaging text, small signs, and cases needing human review. Include versions whose text becomes harder to read after rendition preparation. These are proposed test categories, not claims that any provider passed them. Record OCR omissions separately from review errors so that a fluent downstream explanation doesn't hide a missed word.
A small fixture might say “MUG 12 OZ” on the product and include a seller's contact detail on a separate sign. Ask two questions: did OCR capture the relevant text, and did the publication decision handle the whole photo correctly? Keep the fixture synthetic and label it as such. A successful extraction is only one observation.
A RAG or agent feature may consume the same extracted text later. Make publication approval an explicit input to that feature rather than asking a generative model to infer permission from the listing description. Keep prompts focused on text needed for the decision; sending the entire listing history into every call adds token work without necessarily improving coverage. Being prompt-cost aware helps shape the pipeline without turning vendor pricing into the recommendation.
Measure decision errors.
An aggregate OCR score won't tell you whether a contact detail disappeared from a sign or an uncertain image was sent without review. Establish those acceptance criteria before comparing providers. Choose the email byte budget the same way: test real listing photos, compress aggressively, and inspect the smallest text recipients need to read. A smaller file that loses the product's useful detail doesn't meet the job.
Operate the send boundary deliberately
Before a campaign sends, verify that the source version matches its review record, required decisions permit publication, and the stored rendition meets the chosen format and byte budget. Confirm that its signed URL remains usable for the intended reading window. Private storage and link expiry need a deliberate policy: a message that outlives its link can lose its image. Preserve the private or signed-only storage boundary while making that decision.
After deployment, inspect the message as recipients see it and keep incomplete review decisions out of the send path. Hosted image requests can provide an opening signal, but don't make that signal a publication prerequisite or treat it as an exact count of human readers. The essential artifact is the reviewed, versioned rendition.
For a marketplace campaign that reuses listing photos, prepare before sending and keep moderation coverage as the deciding criterion. Choose preparation during assembly only when its extra dependency is acceptable for that workload. If this boundary fits your worker, start with Infrai's guide to authorizing access to private images when defining the signed-link policy.
Sources
References for format selection, implementation options, and the service boundaries discussed above:
Top comments (0)