The Go backend provides the following methods that can be called from the frontend via Wails bindings:
Search for images using the Pixabay API.
Parameters:
query: Search query string (e.g., "nature", "mountains")page: Page number for pagination (starting from 1)perPage: Number of results per page (max 100)
Returns:
- Array of
ImageResultobjects containing image metadata - Error if the search fails
Example:
const images = await window.go.main.App.SearchImages("mountains", 1, 12);Download an image from a URL and return it as base64.
Parameters:
imageURL: Full URL to the image to download
Returns:
- Base64-encoded image data
- Error if download fails
Example:
const base64Data = await window.go.main.App.DownloadImage(imageURL);Classify an image as "anime", "photo", or "art".
Parameters:
base64Data: Base64-encoded image data
Returns:
- Classification type: "anime", "photo", or "art"
- Error if classification fails
Note: Falls back to "photo" if Python bridge is not available.
Example:
const imageType = await window.go.main.App.ClassifyImage(base64Data);Upscale an image using the appropriate AI model.
Parameters:
base64Data: Base64-encoded image dataimageType: Type of image ("anime" or "photo")scale: Upscaling factor (2, 4, or 8)
Returns:
- Base64-encoded upscaled image data
- Error if upscaling fails
Models Used:
- Anime: RealCUGAN-pro
- Photo: Real-ESRGAN (4xLSDIR)
Example:
const upscaled = await window.go.main.App.UpscaleImage(base64Data, "photo", 4);Complete processing pipeline: classify, upscale, and adjust aspect ratio.
Parameters:
base64Data: Base64-encoded input image datatargetResolution: Target resolution ("4K", "5K", or "8K")useSeamCarving: Use content-aware resize (true) or simple crop (false)
Returns:
- Base64-encoded processed image data
- Error if processing fails
Processing Steps:
- Classify image type (anime vs photo)
- Upscale using appropriate model
- Adjust aspect ratio to 16:9
- Return final result
Example:
const result = await window.go.main.App.ProcessImage(base64Data, "4K", true);interface ImageResult {
id: string; // Unique image ID
url: string; // Image page URL
downloadURL: string; // Direct download URL
previewURL: string; // Thumbnail preview URL
width: number; // Original width in pixels
height: number; // Original height in pixels
author: string; // Author/photographer name
source: string; // Source platform (e.g., "Pixabay")
tags: string[]; // Array of tags
}PIXABAY_API_KEY: Your Pixabay API key (get it from https://pixabay.com/api/docs/)
SWEETDESK_DEBUG: Enable debug logging (set to "1")SUPABASE_URL: Supabase project URL (for cloud storage)SUPABASE_KEY: Supabase anonymous key
All methods return errors that should be handled in the frontend:
try {
const result = await window.go.main.App.ProcessImage(data, "4K", false);
// Handle success
} catch (error) {
console.error("Processing failed:", error);
// Show error to user
}| Operation | Time (M1 Pro) | Time (Intel i7) |
|---|---|---|
| Classification | ~0.5s | ~1s |
| Upscale 2x | ~15s | ~25s |
| Upscale 4x | ~45s | ~60s |
| Upscale 8x | ~120s | ~180s |
| Seam Carving | ~10s | ~15s |
- Original image: ~10-20 MB
- 4K upscaled: ~30-50 MB
- All processing is in-memory (no disk I/O until save)
To add support for additional image APIs (Unsplash, Pexels, etc.):
- Implement the
APIProviderinterface in Go:
type APIProvider interface {
Search(query string, options SearchOptions) ([]ImageResult, error)
Download(imageURL string) ([]byte, error)
GetName() string
}-
Create a new provider struct (e.g.,
UnsplashProvider) -
Register it in
app.gostartup function -
Update frontend to allow provider selection
Classifies images using heuristic-based analysis. For production, consider using:
- DeepGHS/imgutils
- TensorFlow models
- PyTorch classifiers
Content-aware image resizing. For production, consider using:
- seam-carving library (faster)
- OpenCV implementations
- GPU-accelerated versions
AI upscaler binaries should be downloaded from official sources:
- Real-ESRGAN: https://github.com/xinntao/Real-ESRGAN/releases
- RealCUGAN: https://github.com/nihui/realcugan-ncnn-vulkan/releases
Place binaries in:
binaries/
├── darwin/ # macOS
├── linux/ # Linux
└── windows/ # Windows
| Component | License | Commercial Use |
|---|---|---|
| Real-ESRGAN-ncnn-vulkan | MIT-like | ✅ Yes |
| RealCUGAN-ncnn-vulkan | MIT-like | ✅ Yes |
| DeepGHS/imgutils | MIT | ✅ Yes |
| seam-carving | MIT | ✅ Yes |
| Pixabay API | Free | ✅ Yes (with attribution) |
Note: If using Universal-NCNN-Upscaler instead, be aware of AGPL-3.0 requirements.