QR Codes and Text as Covers: Auditing 1,647 Images with AI
An image file that opens and returns 200 is not necessarily suitable as a cover. Deciding whether an image is appropriate requires someone to look at it, and with over a thousand images, that inspection needs to cover every image without sampling.
1-minute summary
- Symptom / problem
- The image checker reports 0 missing covers, yet the site is full of QR codes and text banners as covers
- Who should read
- People auditing many cover images when the check only confirms the file exists
- Fix in short
- Build contact sheets of all 1,647 covers for a vision model to review without sampling. It flagged 225 unsuitable ones, which were then fixed in order.
I had just finished migrating a client's website content to a new system. In the admin interface, a content review queue called Broken links/images had 159 pending tasks. I went through them one by one and found that all 159 were about links, with none about images, even though I could open the site and see cards with chat app QR codes as their covers right in front of me. My own checker said there were no image problems, which meant it was asking the wrong question.
The item IDs, names, and images in this article are all fictional. The item and image counts are from the actual job.
The original checker only asked whether the file existed
The image checker I wrote during the migration worked like this: go through every published item, check whether it has a cover path, then request the file and check its response.
import requests
def cover_missing(items, base):
bad = []
for it in items: # it = {id, cover_url}
if not it.get("cover_url"):
continue # ไม่มีปก นับแยกอีกหัวข้อ
r = requests.head(base + it["cover_url"], timeout=15)
if r.status_code != 200:
bad.append((it["id"], r.status_code))
return bad
print(len(cover_missing(items, "https://example.com"))) # 0
The result was 0 missing covers. Every file returned 200, which was true, but did not answer what the site owner was seeing. A QR image is a valid image file: it opens and has the correct dimensions. A checker like this has no way to know what is inside the image.
Checking that a file exists and returns 200 checks file delivery, not content. If the review queue is called Image problems but this is all it checks behind the scenes, a count of 0 will mislead everyone into thinking the images have been reviewed.
First pass: rules and spot checks, then a rejection
I started with a familiar approach: add rules for things code can measure, then spot-check what it cannot. The rules covered three things: items with no cover, images less than 400 pixels wide, and covers duplicated across items. The last one used perceptual hashing, which I covered in a separate article about dHash and union-find, so I will not repeat the details here. For QR codes and text graphics, I relied on the image classification results from the crawl, as described in Migrating an old .aspx site to a JSON catalog, along with spot checks of pages.
These were the first-pass results.
| Type | Count |
|---|---|
| No cover (2 services, 12 articles, 7 reviews) | 21 |
| Less than 400 pixels wide | 15 |
| QR code as cover | 11 |
| Posters, text graphics, screenshots, logos | 38 |
| Cover unrelated to the subject (one item used an image from another item with different content) | 1 |
| Covers duplicated across items | 109 groups |
I sent this report to the site owner. The response was: check the images again, without sampling.
At first, I thought the initial counts were probably close to the real numbers, because the rules caught the large groups and my spot checks had not found much more. That was a bad guess. The crawl classifier was designed to catch byte-for-byte duplicate QR images and small logos. It did not recognize promotional graphics filled with text, maps, or composites, each of which was unique and as large as an ordinary photograph. Sampling also gave me false confidence, because the images I happened to check and found acceptable said nothing about the ones I had not opened.
Rules + spot checks
Only measurable properties such as width or duplication were checked directly. Image content relied on the old classifier and opening a few pages. This found 11 QR covers and 38 in the graphics and logos group.
Contact sheets, every cell checked
The cover of every published item was placed on a sheet with a number. A vision model inspected every sheet and returned a list, finding 225 items across 10 types.
Contact sheets: making it possible to inspect every image
The problem with inspecting 1,647 images is that opening pages one at a time is too much for a person, while sending images individually to a vision model takes an unreasonable number of calls. I used contact sheets, like those photographers use to review a whole roll of film: shrink the covers into a grid on a single image, then have the model inspect one sheet at a time.
The sheet generator uses plain Pillow. More important than the cell size is the number strip beneath every image.
from PIL import Image, ImageDraw
def make_sheets(items, out_prefix, cols=6, rows=5, cell=(260, 174), bar=22):
"""items = [{no, file}] ค่า cols/rows/cell เป็นค่าตั้งต้น ต้องลองกับรูปจริงว่าอ่านออกไหม"""
per = cols * rows
w, h = cell
sheets = []
for s in range(0, len(items), per):
chunk = items[s:s + per]
sheet = Image.new("RGB", (cols * w, rows * (h + bar)), "white")
draw = ImageDraw.Draw(sheet)
for i, it in enumerate(chunk):
x, y = (i % cols) * w, (i // cols) * (h + bar)
try:
im = Image.open(it["file"]).convert("RGB")
im.thumbnail((w - 4, h - 4))
sheet.paste(im, (x + 2, y + 2))
except OSError:
draw.rectangle([x + 2, y + 2, x + w - 2, y + h - 2], outline="red")
# หมายเลขอยู่ในภาพ ไม่ใช่ในข้อความที่ส่งคู่กัน
draw.rectangle([x, y + h, x + w, y + h + bar], fill="black")
draw.text((x + 6, y + h + 4), f"#{it['no']:04d}", fill="white")
name = f"{out_prefix}_{s // per + 1:03d}.png"
sheet.save(name)
sheets.append({"file": name, "numbers": [it["no"] for it in chunk]})
return sheets
The sheets contained covers from every published item: 1,647 images in total, comprising 798 articles, 403 products, 252 services, 68 gallery main images, 46 listing page covers, 45 reviews, and 35 team photos. Nothing was filtered out beforehand, and there was no sampling. Items with no cover at all were also counted as a category in the overall results.
The model inspected every sheet and returned a list of numbers and issue types, only for cells with problems. The format below is the structure I recommend: define a closed list of categories in the prompt, rather than letting the model name them itself, or the combined results will have ten different names for the same category.
{
"sheet": "covers_014.png",
"types": ["text", "map", "none", "qr", "logo", "small", "screen", "collage", "dup", "other"],
"found": [
{"no": 402, "type": "qr"},
{"no": 405, "type": "text"},
{"no": 408, "type": "logo"},
{"no": 411, "type": "screen"}
]
}
Preventing the model from miscounting cells
I ran into two limitations with this method. First, if the cells are too small, small text inside the images becomes invisible. A graphic with a single line of text in a corner will pass as an ordinary photograph. Second, the model can miscount cell positions. If asked to report row 3, cell 5, it may shift by one cell and flag a neighboring item that has no problem.
The second issue is why the numbers must be printed into the image. The model reads the number from the cell itself, without counting. And when the sheet generator also saves the list of numbers on each sheet, the response can be checked to confirm that every returned number actually appears on that sheet. The check can be as short as this.
import json
ALLOWED = {"text", "map", "none", "qr", "logo", "small", "screen", "collage", "dup", "other"}
def check_answer(sheet, answer_text):
"""sheet = ผลจาก make_sheets หนึ่งแผ่น, answer_text = JSON ที่โมเดลตอบ"""
ans = json.loads(answer_text)
valid, rejected = [], []
known = set(sheet["numbers"])
for row in ans.get("found", []):
if row.get("no") in known and row.get("type") in ALLOWED:
valid.append(row)
else:
rejected.append(row) # เลขไม่อยู่ในแผ่นนี้ หรือประเภทนอกรายการ
return valid, rejected
# ถ้า rejected ไม่ว่าง ให้ส่งแผ่นนั้นดูใหม่ทั้งแผ่น ไม่เดาว่าโมเดลหมายถึงช่องไหน
This only catches numbers that are not present. It cannot catch cases where the model reads the number correctly but assigns the wrong category. That requires the next step: every flagged item will be opened again when choosing a replacement image anyway.
Second-pass results: 225 items, 10 types
The largest category was text graphics at 110 items, followed by maps or infographics at 22, no cover at 19, QR codes at 15, logos at 14, small images at 13, screenshots at 12, composites at 10, duplicate covers at 8, and other at 2. Compared with the first pass, where posters, text graphics, screenshots, and logos totaled 38, the second pass found 136 in the same group. What the first pass missed were images whose problems required looking at them.
Besides covers, I separately checked 7,754 images embedded in content and galleries, using a QR detector together with vision. This found 724 QR images or contact graphics, almost all of them chat app QR codes.
Fixes in order, from lowest to highest risk
After finding 225 items, the next question was what images to use instead. I ordered the options by the risk that the replacement itself would be wrong.
- First, use a real image from the item's own gallery or content. It must not be another item's cover or a QR code, must be at least 600 pixels wide, must pass a dHash check for duplicates against existing covers, and must get another visual check. This fixed 103 items.
- For items with no real image to choose from, generate a photorealistic image with an image generation CLI, attaching related images from the site as references and asking for a different angle. The first round produced 48 images: 14 for products and 34 for services, taking around 1 minute per image. The second round brought the total to 280 images.
- For the remaining items, which were old articles, do not generate images; state explicitly in the report that they remain unfixed.
The generated images had four review criteria of their own: distorted faces, scenes warped enough to look unrealistic, illegible fake text, and logos that appeared on their own. Any image meeting any one of those criteria was discarded.
Along the way, three tooling traps cost me time. First, the image generation CLI's sandbox on Windows could not save files to the requested folder, returning error 206, so I had to retrieve the latest files from the CLI's own generated folder. Second, the default model version was rejected for a login-based account, so I had to specify the model with -m every time. Third, web-side commands running as the web user could not read root's folder, so the images had to be copied to that user's working folder first.
# เก็บไฟล์ที่ CLI เพิ่งสร้าง จากโฟลเดอร์ generated ของมันเอง แล้วตั้งชื่อตามกุญแจของงาน
param([string]$GenDir, [string]$OutDir, [string]$Key, [datetime]$Since)
$new = Get-ChildItem -Path $GenDir -Recurse -File -Include *.png, *.jpg |
Where-Object { $_.LastWriteTime -gt $Since } |
Sort-Object LastWriteTime -Descending |
Select-Object -First 1
if (-not $new) { Write-Output "[ERR] $Key ไม่มีไฟล์ใหม่หลัง $Since"; exit 1 }
Copy-Item $new.FullName (Join-Path $OutDir "$Key$($new.Extension)")
Write-Output "[OK] $Key <- $($new.Name)"
I personally inspected 56 of the 280 images
I need to state this plainly. The 280 images generated in the second round were placed on 18 contact sheets for review against the four criteria above. I personally opened 4 sheets, or 56 images. For the other 14 sheets, I relied on the report from the agent that generated and checked them, which means AI was checking AI's work.
I do not think 56 out of 280 is a number to hide, and I do not think the answer is to promise to inspect them all, because there will be another batch next time. What I did instead was put four mechanisms in place that do not depend on repeated visual inspection.
First, a blocked-image list in config, whose images are removed from covers, galleries, and content during import. Second, an override table that locks the source image for each item. Third, a verify command that reports drift when the actual cover differs from the locked one. Fourth, a manifest of generated images, using keys prefixed with gen: and keeping the originals outside the docroot. If a generated image turns out to be wrong one day, I can immediately identify it as generated and remove the entire batch.
The blocked-image list is ordinary config, grouped by reason. The numbers in this example are fictional.
<?php
// config/media_hidden.php
return [
// QR กับโลโก้แอปแชท จากผลจำแนกตอน crawl
'qr_logo' => ['9001', '9002', '9003'],
// ป้ายตัวหนังสือ ไม่แสดงในแกลเลอรีรูปถ่าย
'posters' => ['9104', '9105'],
// QR และป้ายติดต่อที่พบจากการตรวจรูปในเนื้อหา ห้ามทุกที่: ปก แกลเลอรี และเนื้อหา
'blocked' => ['9210', '9211', '9212', '9213'],
];
The importer reads this config on every run. Listed images are never assigned as covers, never enter galleries, and are stripped from the content HTML during import. Even if the source includes the same QR code every time, it will not return to the site. To check that everything locked in place is still intact, I run these commands after every import.
# นำรูปที่สร้างเข้าระบบจากโฟลเดอร์งานของ user เว็บ พร้อม manifest
php artisan app:content-images /home/webuser/work/genimg --dry
php artisan app:content-images /home/webuser/work/genimg
# แปะรูปต้นฉบับกลับตามตาราง override แล้วรายงานส่วนที่ไม่ตรง
php artisan app:media-master
php artisan app:media-master --verify # ต้องรายงาน drift = 0
After the fixes were finished, the content review queue dropped from 255 tasks to 0. But I read this 0 differently from the 0 at the start. Back then, 0 meant the images had not been checked. Now, 0 means every cover has been checked once, fixes have been applied in order, and the items known to remain unfixed are explicitly documented.
What this method cannot do
Contact sheets and a vision model suit broad questions: is this a photograph or a graphic, and is it a QR code? They are not suitable for detailed questions, such as whether the image matches the actual product. The 1 unrelated cover in the first pass was found by someone who knew the products, not through contact sheets. Small cells cause small text to be missed, and the model's classifications still require a step where a person or code opens the image again before making a fix.
To me, the value of this method is not the model's accuracy, but its ability to move from sampling to checking every image at an affordable cost, while forcing the results into a numbered list that can be counted, categorized, and compared with the next pass. Anyone applying this to their own site can choose the cell size, cells per sheet, and category list to suit their images. Just keep the numbers in the cells, and do not report a complete review if a person has only inspected part of it. If I have left anything out or made a typo, I will come back and fix it later.
Want us to set this up?
Get help with server setup, configuration, migration, or troubleshooting. Save time for the work that matters.
Hit something like this? Stuck somewhere?
Come trade notes on the LinuxThai board



Comments 0
No comments yet — be the first