mattrguerra/meridian-skillsmainPrivate on GitHub, published here in full

topaz-prepress/

Topaz Pre-Pass

Takes raster images that are headed for a Topaz Gigapixel upscale and does two jobs: it preps each file so Topaz starts from a clean signal, and it recommends the right Topaz model and settings per image. Output is a zip of prepped files plus a markdown report.

The core principle (do not violate it)

Topaz works best on the original signal. Do not pre-sharpen, pre-denoise, or "enhance" in Python before Topaz, that destroys the detail Topaz reconstructs from and double-stacks with Topaz's own denoise/sharpen. Python's only legitimate pre-pass jobs are structure and format hygiene and routing:

  • Normalize color mode (indexed/palette, grayscale, CMYK, JPEG) to a clean RGB/RGBA working file.
  • Re-save lossless PNG so no further generational loss happens (critical for JPEG sources).
  • For transparent logos: split the alpha into a separate mask and defringe the RGB (extend edge color into transparent areas) so the upscale doesn't pull a halo into the edges.
  • Optionally pre-downscale a false-resolution image (inflated size, no real detail) so Topaz upscales from concentrated pixels. This is opt-in, never automatic, because misjudging it throws away real detail.

If you find yourself wanting to sharpen or denoise the pixels, stop. That is Topaz's job.

Workflow

  1. Locate the inputs. Images the user uploaded live in /mnt/user-data/uploads. You can pass that directory directly, or individual file paths.
  2. Install deps if needed: pip install pillow numpy scipy --break-system-packages -q (scipy is only used for the alpha defringe; the script degrades gracefully without it).
  3. Run the engine:
    python scripts/prep.py /mnt/user-data/uploads --out /mnt/user-data/outputs/topaz-prep
    Add --predownscale only if the user wants false-resolution images downscaled before upscaling (the report flags which images qualify). Use --zip-name NAME.zip to rename the archive.
  4. The script writes, into the --out directory:
    • *__RGB.png: the file(s) to load into Topaz.
    • *__ALPHA.png: the transparency mask, only for images that had real transparency.
    • Topaz-Prep-Report.md: the per-image model + settings report.
    • analysis.json: machine-readable metrics and recommendations.
    • the zip (prepped images + report).
  5. Deliver: call present_files on the zip and the report. Present the report as the markdown artifact the user reads; the zip is what they download. Keep your chat summary short, the report carries the detail. Flag any image where you'd override the script's automatic call (e.g. you can see it's an emblem, so Art & CG beats the defaulted Text & Shapes). The script routes from measurable features and is right most of the time, but your eyes on the actual image are the tiebreaker, say so when you disagree with it.

How routing works

The script classifies each image from features it measures (color count and flatness, edge density, high-frequency energy vs pixel size, JPEG blockiness, alpha coverage) into one of: flat vector logo, gradient/rendered logo, detailed illustration, low-res/degraded, or a JPEG variant. Each maps to a primary Topaz model, an alternate, and a settings block. The full routing table, with the reasoning and the override cases, is in references/model-selection.md. Read it when a recommendation looks off or the user asks why.

Recompositing transparent logos

When the script splits a logo into __RGB and __ALPHA, the user upscales both by the same factor in Topaz (RGB with its recommended model, ALPHA with Standard and denoise off), then loads the upscaled alpha as a layer mask on the upscaled RGB in Photoshop. The report spells this out per image. This is what keeps a transparent logo's edges clean at banner size instead of fringed.

Scope

This skill preps and recommends; it does not run Topaz (Topaz is a desktop GUI app). It will not invent detail or fake an upscale in Python. If asked to actually upscale, explain that the upscale happens in Topaz with the prepped files and supplied settings.