feat: resolution condition for workflow IF/SWITCH nodes (megapixels, short/long edge)
Adds a "Resolution" condition type filtering assets by image dimensions, useful for isolating low-resolution images for cleanup or selecting high-resolution ones. Three metrics with optional min/max bounds: - Megapixels (width x height / 1e6, fractional values allowed) - Short edge in pixels (LEAST of width/height) - Long edge in pixels (GREATEST of width/height) Short/long edge are orientation-agnostic, so a 4000x3000 landscape and a 3000x4000 portrait are treated identically. Uses the exifImageWidth/ exifImageHeight columns on asset_exif, which the condition queries already join; assets without recorded dimensions never match. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f0d8a88c27
commit
b473bfdc5d
4 files changed
+47
-1
No files matched your search
@@ -92,6 +92,21 @@ function buildSingleCondition(c: ICondition): SQL | undefined {
|
||||
return parts.length > 0 ? and(...parts)! : undefined;
|
||||
}
|
||||
|
||||
case "resolution": {
|
||||
// Short/long edge are orientation-agnostic; megapixels = width × height / 1e6.
|
||||
const metric = c.metric || "megapixels";
|
||||
const value =
|
||||
metric === "short_edge"
|
||||
? sql`LEAST(${exif.exifImageWidth}, ${exif.exifImageHeight})`
|
||||
: metric === "long_edge"
|
||||
? sql`GREATEST(${exif.exifImageWidth}, ${exif.exifImageHeight})`
|
||||
: sql`(${exif.exifImageWidth}::bigint * ${exif.exifImageHeight}) / 1000000.0`;
|
||||
const parts: SQL[] = [];
|
||||
if (c.min !== undefined && c.min !== null) parts.push(sql`${value} >= ${c.min}`);
|
||||
if (c.max !== undefined && c.max !== null) parts.push(sql`${value} <= ${c.max}`);
|
||||
return parts.length > 0 ? and(...parts)! : undefined;
|
||||
}
|
||||
|
||||
case "person": {
|
||||
const ids: string[] = c.personIds || (c.personId ? [c.personId] : []);
|
||||
if (ids.length === 0) return undefined;
|
||||
|
||||
Reference in new issue
Block a user