{"record":{"id":"2c57e500bed00dc9","repo":"lovell/sharp","slug":"expected-create-height-inputoptions-create-heigh","errorCode":null,"errorMessage":"Expected create.height ${inputOptions.create.height} to be a multiple of create.pageHeight ${inputOptions.create.pageHeight}","messagePattern":"Expected create\\.height (.+?) to be a multiple of create\\.pageHeight (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"lib/input.mjs","lineNumber":343,"sourceCode":"        throw is.invalidParameterError('jp2.oneshot', 'boolean', inputOptions.jp2.oneshot);\n      }\n    }\n    // Create new image\n    if (is.defined(inputOptions.create)) {\n      if (\n        is.object(inputOptions.create) &&\n        is.integer(inputOptions.create.width) && is.inRange(inputOptions.create.width, 1, 100000000) &&\n        is.integer(inputOptions.create.height) && is.inRange(inputOptions.create.height, 1, 100000000) &&\n        is.integer(inputOptions.create.channels)\n      ) {\n        inputDescriptor.createWidth = inputOptions.create.width;\n        inputDescriptor.createHeight = inputOptions.create.height;\n        inputDescriptor.createChannels = inputOptions.create.channels;\n        inputDescriptor.createPageHeight = 0;\n        if (is.defined(inputOptions.create.pageHeight)) {\n          if (is.integer(inputOptions.create.pageHeight) && inputOptions.create.pageHeight > 0 && inputOptions.create.pageHeight <= inputOptions.create.height) {\n            if (inputOptions.create.height % inputOptions.create.pageHeight !== 0) {\n              throw new Error(`Expected create.height ${inputOptions.create.height} to be a multiple of create.pageHeight ${inputOptions.create.pageHeight}`);\n            }\n            inputDescriptor.createPageHeight = inputOptions.create.pageHeight;\n          } else {\n            throw is.invalidParameterError('create.pageHeight', 'positive integer', inputOptions.create.pageHeight);\n          }\n        }\n        // Noise\n        if (is.defined(inputOptions.create.noise)) {\n          if (!is.object(inputOptions.create.noise)) {\n            throw new Error('Expected noise to be an object');\n          }\n          if (inputOptions.create.noise.type !== 'gaussian') {\n            throw new Error('Only gaussian noise is supported at the moment');\n          }\n          inputDescriptor.createNoiseType = inputOptions.create.noise.type;\n          if (!is.inRange(inputOptions.create.channels, 1, 4)) {\n            throw is.invalidParameterError('create.channels', 'number between 1 and 4', inputOptions.create.channels);\n          }","sourceCodeStart":325,"sourceCodeEnd":361,"githubUrl":"https://github.com/lovell/sharp/blob/56676c69180a32b468123e090f87bfee30539b49/lib/input.mjs#L325-L361","documentation":"Mirror of the raw.pageHeight rule but for synthetic image creation via inputOptions.create. When create.pageHeight is provided, create.height must be an exact multiple of it because created multi-page images are internally laid out as stacked equal pages. The check is `create.height % create.pageHeight !== 0` after confirming pageHeight is a positive integer not exceeding height.","triggerScenarios":"sharp({ create: { width: 100, height: 100, channels: 3, background: 'red', pageHeight: 30 } }) — 100 % 30 != 0. Setting pageHeight to a non-divisor while intending N equal pages.","commonSituations":"Generating placeholder animation frames where the per-frame height was rounded. Confusing pageHeight with a margin/padding concept. Setting pageHeight less than height intending a crop rather than a page split.","solutions":["Set create.height = create.pageHeight * desiredPageCount (e.g., pageHeight 50, height 150 for 3 pages).","For a single-page created image, omit pageHeight entirely.","Validate the divisibility before constructing the options object."],"exampleFix":"// before\nsharp({ create: { width: 100, height: 100, channels: 3, background: 'red', pageHeight: 30 } })\n\n// after\nsharp({ create: { width: 100, height: 90, channels: 3, background: 'red', pageHeight: 30 } })","handlingStrategy":"validation","validationCode":"function createPages({ width, pageHeight, pages, channels, background }) {\n  const height = pageHeight * pages;\n  if (height % pageHeight !== 0) throw new Error('create.height must be a multiple of create.pageHeight');\n  return sharp({ create: { width, height, channels, background, pageHeight } });\n}","typeGuard":"function createHeightDividesPageHeight(create) {\n  return Number.isInteger(create.height) && Number.isInteger(create.pageHeight) && create.height % create.pageHeight === 0;\n}","tryCatchPattern":null,"preventionTips":["Set create.height = create.pageHeight * desiredPages.","Omit pageHeight for single-page created images.","Treat pageHeight as the per-frame height, not padding."],"tags":["create","input","pageheight","multipage","validation"],"backgroundTag":null,"analyzedSha":"56676c69180a32b468123e090f87bfee30539b49","analyzedAt":"2026-08-13T04:44:31.201Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}