How to automate colour swatch generation with scripts

Creating colour swatches by hand is manageable for a small fabric collection, but the process quickly becomes repetitive when a range includes dozens of prints, colourways and material options. A script can turn a list of colour values into consistent image files, printable sheets, web previews and production references in a few seconds.

Automated swatch generation is especially useful for textile studios, interior suppliers, independent designers and digital fabric printers. Instead of opening each file, drawing rectangles and typing names manually, you can define a repeatable workflow that reads colour data and produces the required assets in a predictable format.

The most important point is that automation does not remove the need for colour judgement. Screens, printers, fabric bases and lighting conditions all affect appearance. The script should handle repetitive preparation while designers and production teams approve the final visual result.

For Australian businesses, a practical workflow also needs to suit small-batch production, remote approvals and customers spread between Melbourne, Sydney, Brisbane, Perth and regional areas. Clear file naming and reliable digital proofs can save plenty of back-and-forth when a client says they would like something “a bit warmer” or “not so bright”.

Why automate swatch production

A colour swatch script can begin with a simple CSV file containing a swatch name, hexadecimal value, RGB values or Pantone reference. It can then create a labelled tile for every entry, arrange those tiles into a grid and save the result as a PNG, JPEG or PDF. The same source data can generate website thumbnails and a downloadable colour card.

Consistency is the main benefit. Every tile can use the same dimensions, typography, padding, background and naming convention. This reduces common manual errors, such as mislabelled colourways, uneven spacing or a file exported at the wrong resolution. If a brand updates its typeface or changes the size of its presentation boards, the entire library can be rebuilt from the source data.

Automation also makes version control easier. A script can add a date, collection name or material code to each output folder. When a textile range is revised, staff can compare the new batch with the previous version instead of wondering which files were edited by hand.

Define reliable colour inputs

Start by deciding how colours will be stored. Hexadecimal values work well for web previews, while RGB values are convenient in most image libraries. For print and textile production, you may also need CMYK conversions, Lab values or physical references. These systems describe colour differently, so a swatch labelled with one value should not be treated as an exact match across every output.

A useful CSV might contain columns such as name, hex, collection, fabric, season and notes. A row could identify a shade as “Eucalyptus Mist”, use #A8B8A2, and specify a particular cotton or linen base. Avoid relying on colour names alone: “sage”, “terracotta” and “navy” can mean different things to different people.

Your script should validate every input before creating files. It can check that a hex code has six valid characters, flag duplicate names, reject missing values and warn when an RGB value falls outside the expected range. These checks are simple, but they prevent a defective data file from producing a polished-looking set of incorrect swatches.

When a palette includes artwork rather than flat colour, keep the source assets separate from the presentation tiles. Understanding the difference between vector and raster images helps determine whether a pattern should be resized, rasterised or preserved as editable artwork before it enters the swatch workflow.

Build a script workflow

Python is a practical choice because it has accessible image libraries and can process folders of files efficiently. Pillow is suitable for creating raster swatches, while libraries such as ReportLab can produce PDF colour cards. For browser-based previews, a script can generate HTML, CSS or SVG files instead.

A basic Pillow workflow follows a clear sequence:

from PIL import Image, ImageDraw, ImageFont
import csv
from pathlib import Path

output = Path("swatches")
output.mkdir(exist_ok=True)

tile_width, tile_height = 600, 420
font = ImageFont.load_default()

with open("palette.csv", newline="", encoding="utf-8") as file:
    for row in csv.DictReader(file):
        name = row["name"].strip()
        colour = row["hex"].strip()

        image = Image.new("RGB", (tile_width, tile_height), colour)
        draw = ImageDraw.Draw(image)

        text_colour = "#FFFFFF" if sum(
            int(colour[i:i+2], 16) for i in (1, 3, 5)
        ) < 380 else "#111111"

        draw.rectangle((0, 340, tile_width, tile_height), fill="white")
        draw.text((24, 365), name, fill=text_colour, font=font)

        safe_name = name.lower().replace(" ", "-")
        image.save(output / f"{safe_name}.png", dpi=(150, 150))

The example creates one tile per row, but a production-ready version should calculate a grid, wrap long names and load a proper font file. It should also handle malformed colours gracefully instead of stopping halfway through a collection. Logging each skipped row to a report makes it easier to repair the source CSV.

For a more refined result, add a contrast calculation so text remains readable on pale and dark backgrounds. You can include a small colour code, collection identifier and fabric reference below the main label. If the script creates a contact sheet, calculate the number of rows from the palette length rather than setting a fixed number that may leave blank pages.

Create files for printers and customers

Different audiences need different outputs. A design team may want large PNG files, a customer may need a lightweight web image, and a printer may require a high-resolution PDF with production notes. Use the same palette data but create separate export profiles rather than forcing one file to serve every purpose.

For online use, convert images to sRGB and compress them carefully. Consistent filenames such as coastal-collection-eucalyptus-mist.png are easier to search than names containing spaces, punctuation or vague labels such as final-new-2. Include a small metadata file with the palette name, date generated and source values.

For printed colour cards, set page dimensions, margins and resolution deliberately. A swatch displayed on an uncalibrated monitor is only a guide, and ink, paper, fabric weave and finishing can alter the result. Mark digital proofs as approximate where appropriate, and keep approved physical samples linked to the corresponding digital record.

If your business supplies repeating patterns, a separate preview can show the colourway applied to a small fabric repeat. This gives customers more useful context than a solid block of colour, particularly for florals, geometrics and textured designs. The preview should still include the underlying swatch code so production staff can identify the correct file.

Handle Australian production realities

Australian textile businesses often work with short runs, independent makers and geographically dispersed clients. A designer in Melbourne may approve a palette for a printer in Sydney while a boutique in Hobart reviews the same files. Automated naming, cloud storage and low-resolution contact sheets make these exchanges quicker and reduce the chance of an outdated attachment being used.

Large distances can also make physical proofing slower and more expensive. A script can create a compact approval pack for email or a client portal, with colour names, codes and notes in Australian English. Keep time zones in mind when generating timestamps: an order discussed in Perth may be reviewed later by a team working on AEST or AEDT.

The local market also includes many small businesses that value flexible quantities rather than enormous production runs. A script supports this model by allowing a new colourway to be generated without rebuilding a whole catalogue. It can also add fabric-specific notes, which matter when the same ink or design behaves differently on cotton, polyester, canvas or upholstery cloth.

When discussing colour with Australian customers, plain language is often more useful than technical jargon. A note such as “the fabric reads slightly softer in daylight” can sit alongside Lab or RGB values. Informal phrases such as “no worries” may suit a customer email, but the production file should remain precise, searchable and unambiguous.

Recommendations for dependable automation

A useful system is small enough for a designer to run but structured enough for a production team to trust. Keep the palette data in one controlled location, store scripts in version control and never overwrite approved exports without creating a new version. If someone changes a colour value, the record should show who made the change and when.

Build a review stage into the process. Automation can confirm that every required file exists, but it cannot decide whether a green looks right on a particular fabric. Open a contact sheet, inspect representative files at full size and compare physical samples before releasing a colour card to customers or a printer.

  • Store colour values and labels in a validated CSV or spreadsheet.
  • Use separate export settings for web previews, print sheets and production references.
  • Add collection, fabric, date and version details to filenames or metadata.
  • Check contrast, image dimensions, resolution and missing fields automatically.
  • Preserve original artwork and never replace source files with flattened previews.
  • Approve representative physical samples before confirming a final colourway.

A scheduled script can regenerate the catalogue whenever the source palette changes, while a simple command-line option can create only one collection when speed matters. For teams that prefer a graphical interface, the same logic can later be placed behind a small desktop tool or internal web form.

Start with a modest palette and a single output format. Once the naming, validation and approval steps are dependable, add PDF contact sheets, pattern previews, customer download packs and colour conversion reports. This staged approach keeps the workflow understandable and avoids building a complicated system before its requirements are clear.

A well-designed colour swatch generator gives creative teams more time for design decisions and fewer repetitive production tasks. Prepare a clean palette file, test the script against real fabric samples and establish a review checkpoint before using the outputs in customer-facing material.