{"record":{"id":"8f18d773015694dc","repo":"different-ai/openwork","slug":"use-an-image-no-larger-than-4096-4096-pixels","errorCode":null,"errorMessage":"Use an image no larger than 4096×4096 pixels.","messagePattern":"Use an image no larger than 4096×4096 pixels\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"ee/apps/den-web/app/(den)/dashboard/_components/brand-appearance-screen.tsx","lineNumber":44,"sourceCode":"  previewUrl: string;\n  width: number;\n  height: number;\n};\n\nasync function createBrandAssetDraft(file: File, kind: BrandAssetKind): Promise<BrandAssetDraft> {\n  if (file.type !== \"image/png\" && file.type !== \"image/jpeg\") throw new Error(\"Use a PNG or JPEG image.\");\n  if (file.size > BRAND_ASSET_MAX_BYTES) throw new Error(\"Use an image under 2 MB.\");\n\n  let image: ImageBitmap;\n  try {\n    image = await createImageBitmap(file);\n  } catch {\n    throw new Error(\"OpenWork could not decode that image.\");\n  }\n\n  const { width, height } = image;\n  image.close();\n  if (width > 4096 || height > 4096) throw new Error(\"Use an image no larger than 4096×4096 pixels.\");\n  if (kind === \"icon\") {\n    if (width < 64 || height < 64) throw new Error(\"Use a square icon at least 64×64 pixels.\");\n    if (width !== height) throw new Error(\"Use a square image for the app icon.\");\n  } else {\n    const aspectRatio = width / height;\n    if (width < 128 || height < 32) throw new Error(\"Use a wordmark at least 128×32 pixels.\");\n    if (aspectRatio < 1.5 || aspectRatio > 8) throw new Error(\"Use a horizontal wordmark between 1.5:1 and 8:1.\");\n  }\n\n  return { file, previewUrl: URL.createObjectURL(file), width, height };\n}\n\nfunction BrandAssetUploadField({\n  kind,\n  title,\n  description,\n  currentUrl,\n  managedAsset,","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/ee/apps/den-web/app/(den)/dashboard/_components/brand-appearance-screen.tsx#L26-L62","documentation":"After decoding, createBrandAssetDraft enforces a maximum dimension of 4096×4096 pixels on all brand assets (icons and wordmarks alike). Extremely large images are rejected to bound memory use when rendering and re-encoding the asset.","triggerScenarios":"Uploading a decoded image where width > 4096 or height > 4096 — e.g. a 6000×4000 DSLR photo as a wordmark, or a 8192×8192 print-resolution logo export.","commonSituations":"Print-design exports at 300 DPI; screenshots of 5K displays; AI-upscaled logos; photographers supplying original photos for branding.","solutions":["Downscale the image to at most 4096×4096 (and at least the kind's minimum) before uploading.","Export at 1x from the design tool instead of 2x/3x.","Use squoosh/ImageMagick (magick input.png -resize 4096x4096 output.png) to resize.","Check dimensions client-side before calling the draft creator so you can auto-resize instead of erroring."],"exampleFix":"// before\nawait draft(oversizedFile, \"wordmark\"); // throws at 6000x4000\n// after\nconst resized = await resizeImage(oversizedFile, { maxWidth: 4096, maxHeight: 4096 });\nawait draft(resized, \"wordmark\");","handlingStrategy":"validation","validationCode":"async function isWithinMaxSize(file: File): Promise<boolean> {\n  const bmp = await createImageBitmap(file);\n  const ok = bmp.width <= 4096 && bmp.height <= 4096;\n  bmp.close();\n  return ok;\n}","typeGuard":null,"tryCatchPattern":"try {\n  const asset = await createBrandAssetDraft(file, kind);\n} catch (error) {\n  showToast(error instanceof Error ? error.message : \"Could not use that image.\");\n}","preventionTips":["Downscale images to ≤4096×4096 in an editor or via canvas before upload","Export at 1x from design tools instead of 2x/3x print scale","State the 4096×4096 limit in the upload UI","Auto-resize oversized images client-side instead of rejecting them"],"tags":["image-validation","dimensions","file-validation"],"backgroundTag":"invalid-image-dimensions","analyzedSha":"2b7df46e8ae1517d64c896c7793d2d52ec845669","analyzedAt":"2026-09-01T07:59:23.713Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}