> ## Documentation Index
> Fetch the complete documentation index at: https://docs.garmint.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Analyze Design

> Analyze designs for printability and get recommendations

# Analyze Design

Analyze a design image for color count, complexity, and recommended print technique.

<Info>
  This endpoint is **free** — no tokens required.
</Info>

## Endpoint

```
POST https://garmint.app/api/v1/analyze
```

## Request Body

<ParamField body="imageUrl" type="string">
  URL of the design image to analyze. Must be publicly accessible.
</ParamField>

<ParamField body="imageData" type="string">
  Base64-encoded image data. Use this for direct uploads.
</ParamField>

<ParamField body="quantity" type="number" default="50">
  Target print quantity for pricing estimates (1-10,000).
</ParamField>

<Warning>
  Provide either `imageUrl` OR `imageData`, not both.
</Warning>

## Response

<ResponseField name="colors" type="object">
  Color analysis results.

  <Expandable title="Colors properties">
    <ResponseField name="count" type="number">
      Total number of distinct colors detected.
    </ResponseField>

    <ResponseField name="dominant" type="array">
      Top 5 dominant colors as hex values.
    </ResponseField>

    <ResponseField name="pantone" type="array">
      Closest Pantone color matches (if available).
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="dimensions" type="object">
  Image dimension analysis.

  <Expandable title="Dimensions properties">
    <ResponseField name="width" type="number">
      Image width in pixels.
    </ResponseField>

    <ResponseField name="height" type="number">
      Image height in pixels.
    </ResponseField>

    <ResponseField name="aspectRatio" type="number">
      Width/height ratio.
    </ResponseField>

    <ResponseField name="hasTransparency" type="boolean">
      Whether the image has transparent areas.
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="recommendation" type="object">
  Print technique recommendation.

  <Expandable title="Recommendation properties">
    <ResponseField name="technique" type="string">
      Recommended technique: `dtg`, `screen`, `embroidery`, or `vinyl`.
    </ResponseField>

    <ResponseField name="reason" type="string">
      Explanation for the recommendation.
    </ResponseField>

    <ResponseField name="complexity" type="string">
      Design complexity: `simple`, `moderate`, or `complex`.
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="pricing" type="object">
  Estimated pricing by technique.

  <Expandable title="Pricing properties">
    <ResponseField name="dtg" type="object">
      DTG (Direct-to-Garment) pricing.
    </ResponseField>

    <ResponseField name="screen" type="object">
      Screen printing pricing (includes setup cost).
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="warnings" type="array">
  Array of potential issues detected.
</ResponseField>

## Example

<CodeGroup>
  ```bash cURL theme={}
  curl -X POST https://garmint.app/api/v1/analyze \
    -H "Authorization: Bearer gm_live_xxx" \
    -H "Content-Type: application/json" \
    -d '{
      "imageUrl": "https://example.com/my-design.png",
      "quantity": 100
    }'
  ```

  ```typescript TypeScript theme={}
  const response = await fetch('https://garmint.app/api/v1/analyze', {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${GARMINT_API_KEY}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      imageUrl: 'https://example.com/my-design.png',
      quantity: 100,
    }),
  });

  const analysis = await response.json();
  console.log(`Recommended: ${analysis.recommendation.technique}`);
  console.log(`Colors: ${analysis.colors.count}`);
  ```

  ```python Python theme={}
  import requests

  response = requests.post(
      'https://garmint.app/api/v1/analyze',
      headers={'Authorization': f'Bearer {GARMINT_API_KEY}'},
      json={
          'imageUrl': 'https://example.com/my-design.png',
          'quantity': 100
      }
  )

  analysis = response.json()
  print(f"Recommended: {analysis['recommendation']['technique']}")
  ```
</CodeGroup>

## Response Example

```json theme={}
{
  "colors": {
    "count": 5,
    "dominant": ["#1a1a1a", "#ff6b6b", "#4ecdc4", "#ffffff", "#2c3e50"],
    "pantone": ["Black C", "Warm Red C", "3242 C"]
  },
  "dimensions": {
    "width": 2400,
    "height": 3000,
    "aspectRatio": 0.8,
    "hasTransparency": true
  },
  "recommendation": {
    "technique": "dtg",
    "reason": "Design has 5 colors with gradients - DTG handles color complexity well",
    "complexity": "moderate"
  },
  "pricing": {
    "dtg": {
      "perUnit": 8.50,
      "currency": "USD"
    },
    "screen": {
      "perUnit": 4.25,
      "setup": 125.00,
      "minimumQuantity": 24,
      "currency": "USD"
    }
  },
  "warnings": [
    "Design has significant transparency - consider the garment color"
  ]
}
```

## Use Cases

### Pre-flight Check

Run analysis before generation to catch issues:

```typescript theme={}
async function validateDesign(designUrl: string) {
  const analysis = await analyzeDesign(designUrl);
  
  if (analysis.colors.count > 12) {
    console.warn('High color count may increase costs');
  }
  
  if (analysis.dimensions.width < 1000) {
    throw new Error('Design resolution too low for quality print');
  }
  
  if (analysis.warnings.length > 0) {
    console.warn('Warnings:', analysis.warnings);
  }
  
  return analysis;
}
```

### Dynamic Pricing

Use analysis to show customers estimated costs:

```typescript theme={}
function calculateQuote(analysis: AnalysisResult, quantity: number) {
  const { pricing } = analysis;
  
  // Compare DTG vs Screen for this quantity
  const dtgTotal = pricing.dtg.perUnit * quantity;
  const screenTotal = pricing.screen.setup + (pricing.screen.perUnit * quantity);
  
  return {
    dtg: { total: dtgTotal, perUnit: pricing.dtg.perUnit },
    screen: { total: screenTotal, perUnit: screenTotal / quantity },
    recommended: quantity >= 50 ? 'screen' : 'dtg',
  };
}
```

## Print Technique Guide

| Technique      | Best For                      | Color Limit |
| -------------- | ----------------------------- | ----------- |
| **DTG**        | Full-color, photos, gradients | Unlimited   |
| **Screen**     | Simple designs, large runs    | 1-8 colors  |
| **Embroidery** | Logos, text, premium look     | 1-15 colors |
| **Vinyl**      | Names, numbers, simple shapes | 1-3 colors  |
