Generate Book Cover Spreads

Generate print-ready book cover spreads with back cover, spine, and front cover in a single image.

Who this is for

Self-publishing platforms and print-on-demand services use this recipe to generate complete book cover spreads for KDP, IngramSpark, or other print-on-demand platforms. Calculate spine width from page count, compose back cover text with an ISBN barcode, add a rotated spine title, and place the front cover image — all in one API call at 300 DPI. Output is RGB (PNG, JPEG, or WebP); CMYK conversion for print-ready files can be done as a separate post-processing step.

Request
curl -X POST https://api.iterationlayer.com/image-generation/v1/render \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "dimensions": { "width": 3826, "height": 2775 },
    "output_format": "png",
    "layers": [
      {
        "index": 0,
        "type": "solid-color",
        "hex_color": "#1B2838"
      },
      {
        "index": 1,
        "type": "image",
        "buffer": "<base64-encoded-front-cover>",
        "position": { "x": 1988.0, "y": 0.0 },
        "dimensions": { "width": 1838, "height": 2775 }
      },
      {
        "index": 2,
        "type": "text",
        "text": "A THRILLER NOVEL",
        "font_name": "Montserrat",
        "font_size_in_px": 30,
        "text_color": "#94A3B8",
        "font_weight": "Bold",
        "text_align": "center",
        "position": { "x": 150.0, "y": 225.0 },
        "dimensions": { "width": 1575, "height": 50 }
      },
      {
        "index": 3,
        "type": "text",
        "text": "The Last Algorithm",
        "font_name": "PlayfairDisplay",
        "font_size_in_px": 72,
        "text_color": "#FFFFFF",
        "font_weight": "Bold",
        "text_align": "center",
        "position": { "x": 150.0, "y": 325.0 },
        "dimensions": { "width": 1575, "height": 150 }
      },
      {
        "index": 4,
        "type": "text",
        "text": "A rogue AI researcher discovers that the optimization algorithm she created has already escaped the lab — and it is rewriting the rules of global finance. Now she has 72 hours to shut it down before it becomes impossible to stop.",
        "font_name": "Lora",
        "font_size_in_px": 28,
        "text_color": "#CBD5E1",
        "text_align": "center",
        "position": { "x": 200.0, "y": 600.0 },
        "dimensions": { "width": 1475, "height": 500 }
      },
      {
        "index": 5,
        "type": "text",
        "text": "ELENA VASQUEZ",
        "font_name": "Montserrat",
        "font_size_in_px": 32,
        "text_color": "#94A3B8",
        "text_align": "center",
        "position": { "x": 150.0, "y": 1200.0 },
        "dimensions": { "width": 1575, "height": 50 }
      },
      {
        "index": 6,
        "type": "solid-color",
        "hex_color": "#FFFFFF",
        "position": { "x": 225.0, "y": 2250.0 },
        "dimensions": { "width": 450, "height": 350 }
      },
      {
        "index": 7,
        "type": "barcode",
        "value": "9781234567890",
        "format": "ean13",
        "position": { "x": 250.0, "y": 2275.0 },
        "dimensions": { "width": 400, "height": 250 },
        "foreground_hex_color": "#000000",
        "background_hex_color": "#FFFFFF"
      },
      {
        "index": 8,
        "type": "text",
        "text": "The Last Algorithm",
        "font_name": "Montserrat",
        "font_size_in_px": 24,
        "text_color": "#FFFFFF",
        "font_weight": "Bold",
        "text_align": "center",
        "vertical_align": "center",
        "rotation_in_degrees": -90,
        "position": { "x": 1838.0, "y": 375.0 },
        "dimensions": { "width": 150, "height": 2025 }
      },
      {
        "index": 9,
        "type": "text",
        "text": "ELENA VASQUEZ",
        "font_name": "Montserrat",
        "font_size_in_px": 18,
        "text_color": "#CBD5E1",
        "text_align": "center",
        "vertical_align": "center",
        "rotation_in_degrees": -90,
        "position": { "x": 1838.0, "y": 150.0 },
        "dimensions": { "width": 150, "height": 225 }
      }
    ]
  }'
Response
{
  "success": true,
  "data": {
    "buffer": "iVBORw0KGgoAAAANSUhEUgAA...",
    "mime_type": "image/png"
  }
}
Request
import { IterationLayer } from "iterationlayer";
const client = new IterationLayer({ apiKey: "YOUR_API_KEY" });

const BLEED_IN_PX = 38;
const TRIM_WIDTH_IN_PX = 1800;
const TRIM_HEIGHT_IN_PX = 2700;
const PAGE_COUNT = 200;
const SPINE_WIDTH_IN_PX = Math.round(PAGE_COUNT * 0.75);
const COVER_WIDTH_IN_PX = TRIM_WIDTH_IN_PX + BLEED_IN_PX;
const TOTAL_WIDTH_IN_PX = COVER_WIDTH_IN_PX * 2 + SPINE_WIDTH_IN_PX;
const TOTAL_HEIGHT_IN_PX = TRIM_HEIGHT_IN_PX + BLEED_IN_PX * 2;
const SPINE_X_IN_PX = COVER_WIDTH_IN_PX;
const FRONT_COVER_X_IN_PX = COVER_WIDTH_IN_PX + SPINE_WIDTH_IN_PX;

const result = await client.generateImage({
  dimensions: { width_in_px: TOTAL_WIDTH_IN_PX, height_in_px: TOTAL_HEIGHT_IN_PX },
  output_format: "png",
  layers: [
    {
      index: 0,
      type: "solid-color",
      hex_color: "#1B2838",
    },
    {
      index: 1,
      type: "image",
      buffer: frontCoverBase64,
      position: { x_in_px: FRONT_COVER_X_IN_PX, y_in_px: 0 },
      dimensions: { width_in_px: COVER_WIDTH_IN_PX, height_in_px: TOTAL_HEIGHT_IN_PX },
    },
    {
      index: 2,
      type: "text",
      text: "A THRILLER NOVEL",
      font_name: "Montserrat",
      font_size_in_px: 30,
      text_color: "#94A3B8",
      font_weight: "Bold",
      text_align: "center",
      position: { x_in_px: 150, y_in_px: 225 },
      dimensions: { width_in_px: 1575, height_in_px: 50 },
    },
    {
      index: 3,
      type: "text",
      text: "The Last Algorithm",
      font_name: "PlayfairDisplay",
      font_size_in_px: 72,
      text_color: "#FFFFFF",
      font_weight: "Bold",
      text_align: "center",
      position: { x_in_px: 150, y_in_px: 325 },
      dimensions: { width_in_px: 1575, height_in_px: 150 },
    },
    {
      index: 4,
      type: "text",
      text: "A rogue AI researcher discovers that the optimization algorithm she created has already escaped the lab — and it is rewriting the rules of global finance. Now she has 72 hours to shut it down before it becomes impossible to stop.",
      font_name: "Lora",
      font_size_in_px: 28,
      text_color: "#CBD5E1",
      text_align: "center",
      position: { x_in_px: 200, y_in_px: 600 },
      dimensions: { width_in_px: 1475, height_in_px: 500 },
    },
    {
      index: 5,
      type: "text",
      text: "ELENA VASQUEZ",
      font_name: "Montserrat",
      font_size_in_px: 32,
      text_color: "#94A3B8",
      text_align: "center",
      position: { x_in_px: 150, y_in_px: 1200 },
      dimensions: { width_in_px: 1575, height_in_px: 50 },
    },
    {
      index: 6,
      type: "solid-color",
      hex_color: "#FFFFFF",
      position: { x_in_px: 225, y_in_px: 2250 },
      dimensions: { width_in_px: 450, height_in_px: 350 },
    },
    {
      index: 7,
      type: "barcode",
      value: "9781234567890",
      format: "ean13",
      position: { x_in_px: 250, y_in_px: 2275 },
      dimensions: { width_in_px: 400, height_in_px: 250 },
      foreground_hex_color: "#000000",
      background_hex_color: "#FFFFFF",
    },
    {
      index: 8,
      type: "text",
      text: "The Last Algorithm",
      font_name: "Montserrat",
      font_size_in_px: 24,
      text_color: "#FFFFFF",
      font_weight: "Bold",
      text_align: "center",
      vertical_align: "center",
      rotation_in_degrees: -90,
      position: { x_in_px: SPINE_X_IN_PX, y_in_px: 375 },
      dimensions: { width_in_px: SPINE_WIDTH_IN_PX, height_in_px: 2025 },
    },
    {
      index: 9,
      type: "text",
      text: "ELENA VASQUEZ",
      font_name: "Montserrat",
      font_size_in_px: 18,
      text_color: "#CBD5E1",
      text_align: "center",
      vertical_align: "center",
      rotation_in_degrees: -90,
      position: { x_in_px: SPINE_X_IN_PX, y_in_px: 150 },
      dimensions: { width_in_px: SPINE_WIDTH_IN_PX, height_in_px: 225 },
    },
  ],
});

await Bun.write("cover-spread.png", Buffer.from(result.data.buffer, "base64"));
Response
{
  "success": true,
  "data": {
    "buffer": "iVBORw0KGgoAAAANSUhEUgAA...",
    "mime_type": "image/png"
  }
}
Request
import base64
import math

from iterationlayer import IterationLayer
client = IterationLayer(api_key="YOUR_API_KEY")

bleed_in_px = 38
trim_width_in_px = 1800
trim_height_in_px = 2700
page_count = 200
spine_width_in_px = round(page_count * 0.75)
cover_width_in_px = trim_width_in_px + bleed_in_px
total_width_in_px = cover_width_in_px * 2 + spine_width_in_px
total_height_in_px = trim_height_in_px + bleed_in_px * 2
spine_x_in_px = cover_width_in_px
front_cover_x_in_px = cover_width_in_px + spine_width_in_px

result = client.generate_image(
    dimensions={"width_in_px": total_width_in_px, "height_in_px": total_height_in_px},
    output_format="png",
    layers=[
        {
            "index": 0,
            "type": "solid-color",
            "hex_color": "#1B2838",
        },
        {
            "index": 1,
            "type": "image",
            "buffer": front_cover_base64,
            "position": {"x_in_px": front_cover_x_in_px, "y_in_px": 0},
            "dimensions": {"width_in_px": cover_width_in_px, "height_in_px": total_height_in_px},
        },
        {
            "index": 2,
            "type": "text",
            "text": "A THRILLER NOVEL",
            "font_name": "Montserrat",
            "font_size_in_px": 30,
            "text_color": "#94A3B8",
            "font_weight": "Bold",
            "text_align": "center",
            "position": {"x_in_px": 150, "y_in_px": 225},
            "dimensions": {"width_in_px": 1575, "height_in_px": 50},
        },
        {
            "index": 3,
            "type": "text",
            "text": "The Last Algorithm",
            "font_name": "PlayfairDisplay",
            "font_size_in_px": 72,
            "text_color": "#FFFFFF",
            "font_weight": "Bold",
            "text_align": "center",
            "position": {"x_in_px": 150, "y_in_px": 325},
            "dimensions": {"width_in_px": 1575, "height_in_px": 150},
        },
        {
            "index": 4,
            "type": "text",
            "text": "A rogue AI researcher discovers that the optimization algorithm she created has already escaped the lab — and it is rewriting the rules of global finance. Now she has 72 hours to shut it down before it becomes impossible to stop.",
            "font_name": "Lora",
            "font_size_in_px": 28,
            "text_color": "#CBD5E1",
            "text_align": "center",
            "position": {"x_in_px": 200, "y_in_px": 600},
            "dimensions": {"width_in_px": 1475, "height_in_px": 500},
        },
        {
            "index": 5,
            "type": "text",
            "text": "ELENA VASQUEZ",
            "font_name": "Montserrat",
            "font_size_in_px": 32,
            "text_color": "#94A3B8",
            "text_align": "center",
            "position": {"x_in_px": 150, "y_in_px": 1200},
            "dimensions": {"width_in_px": 1575, "height_in_px": 50},
        },
        {
            "index": 6,
            "type": "solid-color",
            "hex_color": "#FFFFFF",
            "position": {"x_in_px": 225, "y_in_px": 2250},
            "dimensions": {"width_in_px": 450, "height_in_px": 350},
        },
        {
            "index": 7,
            "type": "barcode",
            "value": "9781234567890",
            "format": "ean13",
            "position": {"x_in_px": 250, "y_in_px": 2275},
            "dimensions": {"width_in_px": 400, "height_in_px": 250},
            "foreground_hex_color": "#000000",
            "background_hex_color": "#FFFFFF",
        },
        {
            "index": 8,
            "type": "text",
            "text": "The Last Algorithm",
            "font_name": "Montserrat",
            "font_size_in_px": 24,
            "text_color": "#FFFFFF",
            "font_weight": "Bold",
            "text_align": "center",
            "vertical_align": "center",
            "rotation_in_degrees": -90,
            "position": {"x_in_px": spine_x_in_px, "y_in_px": 375},
            "dimensions": {"width_in_px": spine_width_in_px, "height_in_px": 2025},
        },
        {
            "index": 9,
            "type": "text",
            "text": "ELENA VASQUEZ",
            "font_name": "Montserrat",
            "font_size_in_px": 18,
            "text_color": "#CBD5E1",
            "text_align": "center",
            "vertical_align": "center",
            "rotation_in_degrees": -90,
            "position": {"x_in_px": spine_x_in_px, "y_in_px": 150},
            "dimensions": {"width_in_px": spine_width_in_px, "height_in_px": 225},
        },
    ],
)

with open("cover-spread.png", "wb") as f:
    f.write(base64.b64decode(result["data"]["buffer"]))
Response
{
  "success": true,
  "data": {
    "buffer": "iVBORw0KGgoAAAANSUhEUgAA...",
    "mime_type": "image/png"
  }
}
Request
package main

import (
    "encoding/base64"
    "math"
    "os"

    il "github.com/iterationlayer/sdk-go"
)

func main() {
    client := il.NewClient("YOUR_API_KEY")

    bleedInPx := 38
    trimWidthInPx := 1800
    trimHeightInPx := 2700
    pageCount := 200
    spineWidthInPx := int(math.Round(float64(pageCount) * 0.75))
    coverWidthInPx := trimWidthInPx + bleedInPx
    totalWidthInPx := coverWidthInPx*2 + spineWidthInPx
    totalHeightInPx := trimHeightInPx + bleedInPx*2
    spineXInPx := coverWidthInPx
    frontCoverXInPx := coverWidthInPx + spineWidthInPx

    result, err := client.GenerateImage(il.GenerateImageRequest{
        Dimensions:   il.Dimensions{WidthInPx: totalWidthInPx, HeightInPx: totalHeightInPx},
        OutputFormat: "png",
        Layers: []il.Layer{
            il.NewSolidColorBackgroundLayer(0, "#1B2838"),
            il.NewStaticImageLayer(1, frontCoverBase64,
                il.Position{XInPx: float64(frontCoverXInPx), YInPx: 0},
                il.Dimensions{WidthInPx: coverWidthInPx, HeightInPx: totalHeightInPx}),
            il.NewTextLayer(2, "A THRILLER NOVEL", "Montserrat", 30, "#94A3B8",
                il.Position{XInPx: 150, YInPx: 225},
                il.Dimensions{WidthInPx: 1575, HeightInPx: 50}),
            il.NewTextLayer(3, "The Last Algorithm", "PlayfairDisplay", 72, "#FFFFFF",
                il.Position{XInPx: 150, YInPx: 325},
                il.Dimensions{WidthInPx: 1575, HeightInPx: 150}),
            il.NewTextLayer(4,
                "A rogue AI researcher discovers that the optimization algorithm she created has already escaped the lab — and it is rewriting the rules of global finance. Now she has 72 hours to shut it down before it becomes impossible to stop.",
                "Lora", 28, "#CBD5E1",
                il.Position{XInPx: 200, YInPx: 600},
                il.Dimensions{WidthInPx: 1475, HeightInPx: 500}),
            il.NewTextLayer(5, "ELENA VASQUEZ", "Montserrat", 32, "#94A3B8",
                il.Position{XInPx: 150, YInPx: 1200},
                il.Dimensions{WidthInPx: 1575, HeightInPx: 50}),
            il.NewRectangleLayer(6, "#FFFFFF",
                il.Position{XInPx: 225, YInPx: 2250},
                il.Dimensions{WidthInPx: 450, HeightInPx: 350}),
            il.NewBarcodeLayer(7, "9781234567890", "ean13",
                il.Position{XInPx: 250, YInPx: 2275},
                il.Dimensions{WidthInPx: 400, HeightInPx: 250},
                "#000000", "#FFFFFF"),
            il.NewTextLayerWithRotation(8, "The Last Algorithm", "Montserrat", 24, "#FFFFFF",
                il.Position{XInPx: float64(spineXInPx), YInPx: 375},
                il.Dimensions{WidthInPx: spineWidthInPx, HeightInPx: 2025}, -90),
            il.NewTextLayerWithRotation(9, "ELENA VASQUEZ", "Montserrat", 18, "#CBD5E1",
                il.Position{XInPx: float64(spineXInPx), YInPx: 150},
                il.Dimensions{WidthInPx: spineWidthInPx, HeightInPx: 225}, -90),
        },
    })
    if err != nil {
        panic(err)
    }

    decoded, _ := base64.StdEncoding.DecodeString(result.Data.Buffer)
    os.WriteFile("cover-spread.png", decoded, 0644)
}
Response
{
  "success": true,
  "data": {
    "buffer": "iVBORw0KGgoAAAANSUhEUgAA...",
    "mime_type": "image/png"
  }
}

Related Recipes

Start building in minutes

Free trial credits included. No credit card required.