Guides/3 min

Export without surprises

PNG from canvas is easy until it is tainted, the wrong size, or the wrong color space.

canvas.toBlob('image/png') is the right API. toDataURL is fine for tiny snippets and rude for 3× 1080p frames. Always draw to an offscreen canvas at the export size — do not screenshot the preview. The preview is DPR-scaled for the operator’s monitor; the file should be the IAB size you bought, times 1, 2, or 3.

Tainting

Fonts do not taint a canvas. Cross-origin images without crossOrigin = 'anonymous' do. If you later composite a photograph behind type, host it with CORS or the PNG export will throw. CanvasFont’s current studio is type-only, which is why export always works.

Ads

Humming (and most display networks) want the declared IAB pixel size, flattened, PNG or JPEG, under a weight cap. Export 1× for the tag, keep a 2× master in your files. Do not upload a 1080 square and hope the network crops it into a 300×250 — it will, and it will look like it.

The Ads page of this studio sets the canvas to the unit you are buying. Design at the real size. That is the whole trick.