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

# Migration Guide

> Migrate from Imgur, Gyazo, or other image hosts to Imperial

## Why Migrate to Imperial?

<CardGroup cols={2}>
  <Card title="Zero Egress Fees" icon="dollar-sign">
    Unlimited bandwidth with no surprise bills
  </Card>

  <Card title="No Compression" icon="image">
    Your images stay pristine (unless you choose compression)
  </Card>

  <Card title="Better Control" icon="sliders">
    Full API access, custom compression, detailed analytics
  </Card>

  <Card title="Fair Pricing" icon="scale-balanced">
    Transparent tier-based pricing, no hidden costs
  </Card>
</CardGroup>

## From Imgur

Imgur's free tier has become increasingly restrictive. Here's how to migrate:

### What You're Gaining

| Feature         | Imgur Free      | Imperial Pro     |
| --------------- | --------------- | ---------------- |
| **Storage**     | Unknown         | 10 GB            |
| **Bandwidth**   | Limited         | Unlimited        |
| **API Access**  | Restricted      | Full access      |
| **Compression** | Forced          | Your choice      |
| **Analytics**   | Basic           | Detailed         |
| **Price**       | Free (with ads) | \$6.99 / 30D key |

### Migration Steps

<Steps>
  <Step title="Sign Up for Imperial">
    Create your account at [app.imperial.gay](https://app.imperial.gay/register)
  </Step>

  <Step title="Export Your Imgur Images">
    Imgur doesn't offer bulk export, but you can: - Use [Imgur Mass
    Downloader](https://github.com/MatthewClarkMay/imgur-mass-downloader) - Or manually download
    important images
  </Step>

  <Step title="Upload to Imperial">
    Use our [batch upload tool](https://app.imperial.gay/images) or API: `bash # Upload single file
          curl -X POST https://api.imperial.gay/images/upload \ -H "Authorization: Bearer YOUR_KEY" \ -F
          "file=@image.jpg" `
  </Step>

  <Step title="Update Your Links">
    Replace Imgur URLs with Imperial URLs in your: - Websites and apps - Social media posts -
    Documentation - Databases
  </Step>
</Steps>

### Imgur API Equivalent

| Imgur Endpoint             | Imperial Equivalent   |
| -------------------------- | --------------------- |
| `POST /3/image`            | `POST /images/upload` |
| `GET /3/account/me/images` | `GET /images`         |
| `DELETE /3/image/{id}`     | `DELETE /images/{id}` |

<CodeGroup>
  ```javascript Imgur theme={null}
  // Imgur upload
  const response = await fetch('https://api.imgur.com/3/image', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer YOUR_IMGUR_TOKEN'
    },
    body: formData
  });
  ```

  ```javascript Imperial theme={null}
  // Imperial upload
  const response = await fetch("https://api.imperial.gay/images/upload", {
    method: "POST",
    headers: {
      Authorization: "Bearer YOUR_IMPERIAL_KEY",
    },
    body: formData,
  });
  ```
</CodeGroup>

## From Gyazo

Gyazo is great for quick screenshots but lacks flexibility. Here's your upgrade path:

### What You're Gaining

| Feature         | Gyazo Pro | Imperial Pro     |
| --------------- | --------- | ---------------- |
| **Storage**     | 10 GB     | 10 GB            |
| **Bandwidth**   | Limited   | Unlimited        |
| **Compression** | Auto      | Optional         |
| **API**         | Limited   | Full REST API    |
| **Price**       | \$4.99/mo | \$6.99 / 30D key |

### Migration Steps

<Steps>
  <Step title="Download Gyazo Images">
    Export from your [Gyazo library](https://gyazo.com/captures)
  </Step>

  <Step title="Configure ShareX">
    Imperial works with ShareX (Gyazo's alternative): 1. Download [ShareX](https://getsharex.com/) 2.
    Get your [Imperial config](https://app.imperial.gay/uploader) 3. Import to ShareX
  </Step>

  <Step title="Migrate Existing Images">
    Upload your Gyazo exports to Imperial via dashboard or API
  </Step>

  <Step title="Update Workflow">Use ShareX with Imperial for future screenshots</Step>
</Steps>

## From Lightshot / Prnt.sc

Lightshot is convenient but has reliability issues. Upgrade to Imperial:

### Migration Steps

<Steps>
  <Step title="Switch to ShareX">
    Lightshot doesn't support custom uploaders, but ShareX does: - Uninstall Lightshot - Install
    [ShareX](https://getsharex.com/) - Configure with [Imperial](https://app.imperial.gay/uploader)
  </Step>

  <Step title="Migrate Old Screenshots">
    Unfortunately, Prnt.sc doesn't allow bulk exports. You'll need to: - Manually save important
    screenshots - Re-upload to Imperial
  </Step>

  <Step title="Configure Hotkeys">
    Set up your preferred shortcuts in ShareX (e.g., `Ctrl+Shift+3`)
  </Step>
</Steps>

## From Self-Hosted Solutions

Migrating from your own infrastructure? Here's what changes:

### From Custom S3/R2 Setup

<Tabs>
  <Tab title="Benefits">
    **What you gain:**

    * No infrastructure management
    * Built-in compression
    * Upload analytics
    * Video thumbnail generation
    * No ops burden

    **What you might miss:**

    * Full infrastructure control
    * Custom CDN configuration
    * Direct bucket access
  </Tab>

  <Tab title="Migration">
    ```bash theme={null}
    #!/bin/bash
    # Migrate from S3 bucket to Imperial

    # 1. List all objects in your bucket
    aws s3 ls s3://your-bucket --recursive > files.txt

    # 2. Download and re-upload to Imperial
    while read -r line; do
      file=$(echo $line | awk '{print $4}')
      aws s3 cp "s3://your-bucket/$file" "/tmp/$file"
      
      curl -X POST https://api.imperial.gay/images/upload \
        -H "Authorization: Bearer YOUR_KEY" \
        -F "file=@/tmp/$file"
      
      rm "/tmp/$file"
    done < files.txt
    ```
  </Tab>

  <Tab title="Cost Comparison">
    **Your AWS Bill:**

    * S3 Storage: \$0.023/GB
    * CloudFront Transfer: \$0.085/GB
    * 10 GB storage + 1 TB traffic = \~\$87/mo

    **Imperial Pro:**

    * 10 GB storage + unlimited traffic = \$6.99 per 30 days
    * **Savings: \~\$80/month equivalent** 💰
  </Tab>
</Tabs>

### From ShareX + Custom Server

Already using ShareX with your own endpoint? Easy switch:

1. **Export your existing images** from your server
2. **Download** [Imperial config](https://app.imperial.gay/uploader) for ShareX
3. **Import** to replace your custom uploader
4. **Upload** your existing images to Imperial
5. **Decommission** your custom server

<Tip>
  Keep your server running temporarily while you update old links, then shut it down once migration
  is complete.
</Tip>

## Bulk Migration Tools

### Using the Dashboard

For small migrations (\< 100 files):

1. Navigate to [app.imperial.gay/images](https://app.imperial.gay/images)
2. Drag and drop multiple files
3. Wait for batch upload to complete

### Using the API

For large migrations (hundreds/thousands of files):

<CodeGroup>
  ```javascript Node.js theme={null}
  const fs = require('fs');
  const path = require('path');
  const FormData = require('form-data');
  const axios = require('axios');

  async function migrateDirectory(dirPath) {
  const files = fs.readdirSync(dirPath);

  for (const file of files) {
  const filePath = path.join(dirPath, file);
  const form = new FormData();
  form.append('file', fs.createReadStream(filePath));

      try {
        const response = await axios.post(
          'https://api.imperial.gay/images/upload',
          form,
          {
            headers: {
              'Authorization': `Bearer ${process.env.IMPERIAL_KEY}`,
              ...form.getHeaders()
            }
          }
        );

        console.log(`✅ Uploaded: ${file}`);
        console.log(`   URL: ${response.data.uploaded[0].url}`);

        // Optional: Save URL mapping for link updates
        fs.appendFileSync('url-mapping.txt',
          `${file} -> ${response.data.uploaded[0].url}\n`
        );

      } catch (error) {
        console.error(`❌ Failed: ${file}`, error.message);
      }

      // Rate limiting: wait 100ms between uploads
      await new Promise(resolve => setTimeout(resolve, 100));

  }
  }

  migrateDirectory('./images-to-migrate');

  ```

  ```python Python theme={null}
  import os
  import time
  import requests

  def migrate_directory(dir_path):
      api_key = os.environ['IMPERIAL_KEY']

      for filename in os.listdir(dir_path):
          file_path = os.path.join(dir_path, filename)

          try:
              with open(file_path, 'rb') as f:
                  response = requests.post(
                      'https://api.imperial.gay/images/upload',
                      headers={'Authorization': f'Bearer {api_key}'},
                      files={'file': f}
                  )

                  url = response.json()['uploaded'][0]['url']
                  print(f'✅ Uploaded: {filename}')
                  print(f'   URL: {url}')

                  # Save URL mapping
                  with open('url-mapping.txt', 'a') as mapping:
                      mapping.write(f'{filename} -> {url}\n')

          except Exception as e:
              print(f'❌ Failed: {filename} - {str(e)}')

          # Rate limiting
          time.sleep(0.1)

  migrate_directory('./images-to-migrate')
  ```

  ```bash Bash theme={null}
  #!/bin/bash
  # Simple bash migration script

  IMPERIAL_KEY="your_key_here"
  SOURCE_DIR="./images-to-migrate"

  for file in "$SOURCE_DIR"/*; do
    echo "Uploading: $file"

    response=$(curl -X POST https://api.imperial.gay/images/upload \
      -H "Authorization: Bearer $IMPERIAL_KEY" \
      -F "file=@$file" \
      -s)

    url=$(echo $response | jq -r '.uploaded[0].url')
    echo "  -> $url"
    echo "$file -> $url" >> url-mapping.txt

    sleep 0.1  # Rate limiting
  done
  ```
</CodeGroup>

## Updating Links

After migration, update your old URLs:

### Database Update

```sql theme={null}
-- MySQL/PostgreSQL
UPDATE posts
SET image_url = REPLACE(
  image_url,
  'https://i.imgur.com/',
  'https://origin.imperial.gay/uploads/'
);

-- MongoDB
db.posts.updateMany(
  { image_url: /^https:\/\/i\.imgur\.com\// },
  [{
    $set: {
      image_url: {
        $replaceAll: {
          input: "$image_url",
          find: "https://i.imgur.com/",
          replacement: "https://origin.imperial.gay/uploads/"
        }
      }
    }
  }]
);
```

### Code Update

```javascript theme={null}
// Before
const imageUrl = "https://i.imgur.com/abc123.jpg";

// After
const imageUrl = "https://origin.imperial.gay/uploads/user-id/upload-id-filename.jpg";
```

### URL Mapping File

Use the `url-mapping.txt` created during migration to find-and-replace:

```bash theme={null}
# Load mapping into a script
while IFS=' -> ' read old_url new_url; do
  # Update config files, databases, etc.
  sed -i "s|$old_url|$new_url|g" your-config-file.conf
done < url-mapping.txt
```

## Migration Checklist

<Steps>
  <Step title="Preparation">
    * [ ] Create Imperial account - \[ ] Choose appropriate tier - \[ ] Set up API key or upload key -
      \[ ] Test upload with single file
  </Step>

  <Step title="Migration">
    * [ ] Export images from old service - \[ ] Run bulk migration script - \[ ] Verify all files
      uploaded successfully - \[ ] Save URL mapping file
  </Step>

  <Step title="Update Links">
    * [ ] Update database records - \[ ] Update application code - \[ ] Update documentation - \[ ]
      Update external references
  </Step>

  <Step title="Verification">
    * [ ] Test image loading on your site/app - \[ ] Verify analytics/tracking still works - \[ ] Check
      CDN performance - \[ ] Monitor for broken links
  </Step>

  <Step title="Cleanup">
    * [ ] Keep old service for 30 days (redirect period) - \[ ] Cancel old subscriptions - \[ ]
      Archive migration logs - \[ ] Document the new setup
  </Step>
</Steps>

## Need Help?

<CardGroup cols={2}>
  <Card title="Join Discord" icon="discord" href="https://discord.gg/imperial">
    Get migration support from the community
  </Card>

  <Card title="Contact Support" icon="envelope" href="https://discord.gg/imperial">
    We can help with large migrations
  </Card>

  <Card title="API Docs" icon="book" href="/api-reference/introduction">
    Learn the Imperial API
  </Card>

  <Card title="Start Migration" icon="rocket" href="https://app.imperial.gay/register">
    Create your account now
  </Card>
</CardGroup>
