AzureImage 1.0.1

dotnet add package AzureImage --version 1.0.1
                    
NuGet\Install-Package AzureImage -Version 1.0.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="AzureImage" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AzureImage" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="AzureImage" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add AzureImage --version 1.0.1
                    
#r "nuget: AzureImage, 1.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package AzureImage@1.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=AzureImage&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=AzureImage&version=1.0.1
                    
Install as a Cake Tool

Azure Image SDK

<div align="center">

NuGet NuGet Downloads GitHub Wiki Changelog .NET

A powerful, comprehensive .NET SDK for Azure AI Foundry image services

Seamlessly integrate advanced AI-powered image generation, analysis, and processing capabilities into your applications

Azure Image SDK

๐Ÿš€ Quick Start โ€ข ๐Ÿ“– Documentation โ€ข ๐Ÿ”ง API Reference โ€ข ๐Ÿ’ฌ Discussions

</div>


๐ŸŒŸ What's New in v1.0.1

  • โœจ NEW: DALL-E 3 Support - Advanced OpenAI image generation with natural and vivid styles
  • โœจ NEW: GPT-Image-1 Support - Next-generation image generation and editing capabilities
  • ๐Ÿ”ง Enhanced Utilities - Comprehensive image processing toolset with quality analysis
  • ๐Ÿ“š Complete Documentation - Detailed wikis for all utilities and features
  • ๐Ÿ“ฆ NuGet Enhancements - README now included in NuGet package

๐Ÿ“ View complete changelog for detailed release notes and migration guides.


๐ŸŽฏ Overview

Azure Image SDK is a modern, feature-rich .NET library that enables developers to easily integrate Azure AI Foundry's cutting-edge image capabilities into their applications. Supporting .NET 6.0+, it provides a unified, type-safe, and performant way to work with multiple AI-powered image services.

โšก Why Choose Azure Image SDK?

  • ๐ŸŽจ Multi-Model Support - Unified API for Stable Image Ultra/Core, DALL-E 3, and GPT-Image-1
  • ๐Ÿ› ๏ธ Rich Utilities - Complete image processing toolkit built-in
  • ๐Ÿ”Œ DI Ready - First-class dependency injection support
  • ๐Ÿ”„ Resilient - Built-in retry logic and comprehensive error handling
  • ๐Ÿ“Š Observable - Integrated logging and monitoring capabilities
  • ๐Ÿงช Well Tested - Comprehensive test coverage for production reliability

โœจ Features

๐ŸŽจ AI-Powered Image Generation

Model Capabilities Best For
๐Ÿš€ DALL-E 3 Natural & vivid styles, high-quality outputs Creative projects, marketing content
โšก GPT-Image-1 Generation + editing, multiple formats Versatile applications, content editing
๐ŸŽฏ Stable Image Ultra Advanced customization, precise control Professional workflows, branded content
๐Ÿ’Ž Stable Image Core Essential generation, fast processing High-volume applications, prototyping
Key Generation Features
  • ๐ŸŽ›๏ธ Advanced Parameters - Size, style, quality, seeds, negative prompts
  • ๐Ÿ”„ Multiple Formats - PNG, JPEG, WebP support
  • ๐Ÿ“ Flexible Sizing - Square, landscape, portrait orientations
  • ๐ŸŽญ Style Control - Natural, vivid, artistic variations
  • ๐ŸŒฑ Reproducible - Seed-based generation for consistency

๐Ÿ‘๏ธ Computer Vision & AI Analysis

  • ๐Ÿท๏ธ Azure Vision Captioning - Generate descriptive captions with confidence scores
  • ๐ŸŽฏ Dense Captioning - Multiple region-specific captions with bounding boxes
  • ๐ŸŒ Multi-Input Support - Process images from streams, URLs, or file paths
  • ๐Ÿ—ฃ๏ธ Language Support - Multiple language options for international applications
  • โš–๏ธ Gender-Neutral Options - Inclusive captioning for diverse content

๐Ÿ› ๏ธ Professional Image Processing Utilities

  • ๐Ÿ”„ Format Conversion - Universal format and MIME type conversion (PNG, JPG, WebP, etc.)
  • ๐Ÿ“Š Quality Analysis - Advanced sharpness, brightness, contrast, and overall quality scoring
  • ๐Ÿ“‹ Metadata Extraction - Comprehensive EXIF data and image properties extraction
  • ๐Ÿ“ Size Validation - Smart dimension validation with customizable constraints
  • ๐Ÿ“ Aspect Ratio Tools - Professional aspect ratio calculation and validation

๐Ÿ—๏ธ Enterprise-Grade Architecture

  • ๐Ÿงฉ Modular Design - Easily extendable with new AI services and models
  • ๐Ÿ’‰ Dependency Injection - Full ASP.NET Core and .NET Host integration
  • ๐Ÿ”„ Resilient Operations - Exponential backoff retry with configurable policies
  • ๐Ÿšจ Error Handling - Comprehensive exception system with detailed diagnostics
  • ๐Ÿ“ Logging Integration - Microsoft.Extensions.Logging with structured data
  • ๐Ÿ”’ Type Safety - Strongly typed models, requests, and responses throughout
  • โšก Async/Await - Fully asynchronous operations for optimal performance
  • โš™๏ธ Flexible Configuration - appsettings.json, environment variables, and fluent APIs

๐Ÿ“ฆ Installation

Package Manager Console

Install-Package AzureImage

.NET CLI

dotnet add package AzureImage

PackageReference

<PackageReference Include="AzureImage" Version="1.0.1" />

Supported Frameworks

  • โœ… .NET 6.0+
  • โœ… .NET 7.0+
  • โœ… .NET 8.0+

๐Ÿš€ Quick Start

1. ๐ŸŽจ Image Generation - DALL-E 3

using AzureImage.Core;
using AzureImage.Inference.Models.DALLE3;

// Create DALL-E 3 model
var dalle3Model = DALLE3Model.Create(
    endpoint: "https://your-resource.openai.azure.com",
    apiKey: "your-api-key",
    deploymentName: "dalle3-deployment");

// Generate with advanced options
var request = new ImageGenerationRequest
{
    Prompt = "A majestic mountain landscape at sunset, painted in impressionist style",
    Size = "1024x1024",
    Quality = "hd",
    Style = "vivid"
};

var response = await client.GenerateImageAsync(dalle3Model, request);
await response.SaveImageAsync("masterpiece.png");

Console.WriteLine($"Generated with revised prompt: {response.RevisedPrompt}");

2. โšก Image Generation & Editing - GPT-Image-1

using AzureImage.Inference.Models.GPTImage1;

// Create GPT-Image-1 model (supports both generation and editing)
var gptImageModel = GPTImage1Model.Create(
    endpoint: "https://your-resource.openai.azure.com",
    apiKey: "your-api-key", 
    deploymentName: "gpt-image-1-deployment");

// Generate new image
var genRequest = new ImageGenerationRequest
{
    Prompt = "A modern office space with natural lighting",
    Size = "1024x1024",
    Quality = "high",
    OutputFormat = "png"
};

var genResponse = await client.GenerateImageAsync(gptImageModel, genRequest);

// Edit existing image
var editRequest = new ImageEditingRequest
{
    Image = File.ReadAllBytes("original.png"),
    Prompt = "Add a beautiful plant in the corner",
    Size = "1024x1024"
};

var editResponse = await client.EditImageAsync(gptImageModel, editRequest);
await editResponse.SaveImageAsync("edited.png");

3. ๐ŸŽฏ Professional Image Generation - Stable Image Ultra

using AzureImage.Inference.Models.StableImageUltra;

// Create Stable Image Ultra model with advanced configuration
var ultraModel = StableImageUltraModel.Create(
    endpoint: "https://your-endpoint.eastus.models.ai.azure.com",
    apiKey: "your-api-key",
    options =>
    {
        options.ApiVersion = "2024-05-01-preview";
        options.DefaultSize = "1024x1024";
        options.DefaultOutputFormat = "png";
        options.Timeout = TimeSpan.FromMinutes(5);
        options.MaxRetryAttempts = 3;
    });

// Generate with fine-grained control
var request = new ImageGenerationRequest
{
    Prompt = "A professional product photo of a luxury watch on marble surface",
    NegativePrompt = "blurry, low quality, distorted, watermark",
    Size = "1024x1024",
    OutputFormat = "png",
    Seed = 42 // For reproducible results
};

var response = await client.GenerateImageAsync(ultraModel, request);

// Access comprehensive metadata
if (response.Metadata != null)
{
    Console.WriteLine($"Generated: {response.Metadata.Width}x{response.Metadata.Height}");
    Console.WriteLine($"Seed used: {response.Metadata.Seed}");
    Console.WriteLine($"Format: {response.Metadata.Format}");
}

4. ๐Ÿ‘๏ธ Computer Vision - Image Analysis

using AzureImage.Inference.Models.AzureVisionCaptioning;

// Create Azure Vision model
var visionModel = AzureVisionCaptioningModel.Create(
    endpoint: "https://your-vision.cognitiveservices.azure.com",
    apiKey: "your-vision-api-key");

// Analyze image from URL
var captionResult = await visionModel.GenerateCaptionAsync(
    "https://example.com/image.jpg");

Console.WriteLine($"Caption: {captionResult.Caption.Text}");
Console.WriteLine($"Confidence: {captionResult.Caption.Confidence:P2}");

// Generate detailed dense captions
var denseCaptions = await visionModel.GenerateDenseCaptionsAsync(imageStream);
foreach (var caption in denseCaptions.Captions)
{
    Console.WriteLine($"Region: {caption.Text} (Confidence: {caption.Confidence:P2})");
    Console.WriteLine($"Location: X={caption.BoundingBox.X}, Y={caption.BoundingBox.Y}");
}

5. ๐Ÿ› ๏ธ Professional Image Processing

using AzureImage.Utilities;

// Format conversion and validation
string mimeType = ImageFormatConverter.GetMimeType(".jpg"); // "image/jpeg"
bool isValidFormat = ImageFormatConverter.IsValidImageFormat("webp"); // true
string[] supportedFormats = ImageFormatConverter.GetSupportedFormats();

// Comprehensive quality analysis
using var imageStream = File.OpenRead("photo.jpg");
var qualityMetrics = await ImageQualityAnalyzer.AnalyzeQualityAsync(imageStream);

Console.WriteLine($"๐Ÿ“Š Quality Analysis:");
Console.WriteLine($"   Sharpness: {qualityMetrics.Sharpness:P2}");
Console.WriteLine($"   Brightness: {qualityMetrics.Brightness:P2}");
Console.WriteLine($"   Contrast: {qualityMetrics.Contrast:P2}");
Console.WriteLine($"   Overall Score: {qualityMetrics.OverallScore:P2}");

// Extract detailed metadata
var metadata = await ImageMetadataExtractor.ExtractMetadataAsync(imageStream);
Console.WriteLine($"๐Ÿ“‹ Metadata:");
Console.WriteLine($"   Dimensions: {metadata.Width}x{metadata.Height}");
Console.WriteLine($"   Format: {metadata.Format}");
Console.WriteLine($"   File Size: {metadata.Size:N0} bytes");

// Smart size validation with constraints
var constraints = new SizeConstraints
{
    MinWidth = 320, MaxWidth = 1920,
    MinHeight = 240, MaxHeight = 1080,
    MinAspectRatio = 0.5, MaxAspectRatio = 2.0
};

bool isValidSize = ImageSizeValidator.IsWithinBounds(
    metadata.Width, metadata.Height, constraints);

// Intelligent scaling while preserving aspect ratio
var (scaledWidth, scaledHeight) = ImageSizeValidator.ScaleToFit(
    metadata.Width, metadata.Height, 1024, 1024);

โš™๏ธ Configuration

๐Ÿ“ appsettings.json Configuration

{
  "AzureImage": {
    "DALLE3": {
      "Endpoint": "https://your-resource.openai.azure.com",
      "ApiKey": "your-dalle3-api-key",
      "DeploymentName": "dalle3-deployment",
      "ApiVersion": "2024-02-01",
      "DefaultSize": "1024x1024",
      "DefaultQuality": "hd",
      "DefaultStyle": "vivid"
    },
    "GPTImage1": {
      "Endpoint": "https://your-resource.openai.azure.com", 
      "ApiKey": "your-gpt-image-api-key",
      "DeploymentName": "gpt-image-1-deployment",
      "ApiVersion": "2025-04-01-preview",
      "DefaultSize": "1024x1024",
      "DefaultQuality": "high"
    },
    "StableImageUltra": {
      "Endpoint": "https://your-stable-image-ultra.eastus.models.ai.azure.com",
      "ApiKey": "your-stable-image-ultra-api-key",
      "ApiVersion": "2024-05-01-preview",
      "DefaultSize": "1024x1024",
      "DefaultOutputFormat": "png"
    },
    "StableImageCore": {
      "Endpoint": "https://your-stable-image-core.eastus.models.ai.azure.com",
      "ApiKey": "your-stable-image-core-api-key"
    },
    "AzureVisionCaptioning": {
      "Endpoint": "https://your-vision.cognitiveservices.azure.com",
      "ApiKey": "your-vision-api-key",
      "ApiVersion": "2024-02-01"
    }
  },
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft": "Warning", 
      "AzureImage": "Debug"
    }
  }
}

๐ŸŒ Environment Variables

# DALL-E 3
export AZURE_IMAGE_DALLE3_ENDPOINT="https://your-resource.openai.azure.com"
export AZURE_IMAGE_DALLE3_API_KEY="your-dalle3-api-key"
export AZURE_IMAGE_DALLE3_DEPLOYMENT_NAME="dalle3-deployment"

# GPT-Image-1  
export AZURE_IMAGE_GPTIMAGE1_ENDPOINT="https://your-resource.openai.azure.com"
export AZURE_IMAGE_GPTIMAGE1_API_KEY="your-gpt-image-api-key"
export AZURE_IMAGE_GPTIMAGE1_DEPLOYMENT_NAME="gpt-image-1-deployment"

# Stable Image Ultra
export AZURE_IMAGE_STABLE_IMAGE_ULTRA_ENDPOINT="https://your-endpoint.eastus.models.ai.azure.com"
export AZURE_IMAGE_STABLE_IMAGE_ULTRA_API_KEY="your-api-key"

๐Ÿ’‰ Dependency Injection Setup

using AzureImage.Extensions;

// In Program.cs or Startup.cs
builder.Services.AddAzureImage(options =>
{
    options.DALLE3.Endpoint = "https://your-resource.openai.azure.com";
    options.DALLE3.ApiKey = "your-api-key";
    options.DALLE3.DeploymentName = "dalle3-deployment";
    
    options.GPTImage1.Endpoint = "https://your-resource.openai.azure.com";
    options.GPTImage1.ApiKey = "your-api-key";
    options.GPTImage1.DeploymentName = "gpt-image-1-deployment";
    
    options.Timeout = TimeSpan.FromMinutes(5);
    options.MaxRetryAttempts = 3;
});

// Or load from configuration
builder.Services.AddAzureImage(
    builder.Configuration.GetSection("AzureImage"));

๐ŸŽฎ Using in Controllers/Services

[ApiController]
[Route("api/[controller]")]
public class ImageController : ControllerBase
{
    private readonly IAzureImageClient _azureImageClient;

    public ImageController(IAzureImageClient azureImageClient)
    {
        _azureImageClient = azureImageClient;
    }

    [HttpPost("generate/dalle3")]
    public async Task<IActionResult> GenerateWithDALLE3([FromBody] GenerateImageRequest request)
    {
        var dalle3Model = DALLE3Model.Create(/* configuration */);
        var response = await _azureImageClient.GenerateImageAsync(dalle3Model, request);
        return File(response.GetImageBytes(), "image/png", "generated-image.png");
    }

    [HttpPost("edit/gpt-image")]
    public async Task<IActionResult> EditWithGPTImage(IFormFile image, [FromForm] string prompt)
    {
        var gptImageModel = GPTImage1Model.Create(/* configuration */);
        var editRequest = new ImageEditingRequest
        {
            Image = await image.GetBytesAsync(),
            Prompt = prompt
        };
        
        var response = await _azureImageClient.EditImageAsync(gptImageModel, editRequest);
        return File(response.GetImageBytes(), "image/png", "edited-image.png");
    }
}

๐Ÿ“Š Comprehensive API Reference

๐ŸŽจ Image Generation Models Comparison

Feature DALL-E 3 GPT-Image-1 Stable Image Ultra Stable Image Core
Generation โœ… Advanced โœ… Advanced โœ… Professional โœ… Essential
Editing โŒ โœ… Full Support โŒ โŒ
Styles Natural, Vivid Multiple Custom Standard
Sizes 1024x1024, 1792x1024, 1024x1792 1024x1024, 1024x1536, 1536x1024 Flexible Flexible
Quality Options Standard, HD Low, Medium, High Custom Standard
Batch Generation Single (n=1) 1-10 images Single Single
Response Format URL, Base64 PNG, JPEG Multiple Multiple

๐ŸŽ›๏ธ Model-Specific Parameters

DALL-E 3 Parameters
var request = new DALLE3.ImageGenerationRequest
{
    Prompt = "Your creative prompt",
    Size = "1024x1024", // 1024x1024, 1792x1024, 1024x1792
    Quality = "hd",      // standard, hd
    Style = "vivid",     // natural, vivid
    ResponseFormat = "url" // url, b64_json
};
GPT-Image-1 Parameters
// Generation
var genRequest = new GPTImage1.ImageGenerationRequest
{
    Prompt = "Your detailed prompt",
    Size = "1024x1024",     // 1024x1024, 1024x1536, 1536x1024
    Quality = "high",       // low, medium, high  
    N = 1,                  // 1-10 images
    OutputFormat = "png",   // png, jpeg
    OutputCompression = 100, // 0-100
    User = "user-123"       // Optional user ID
};

// Editing
var editRequest = new GPTImage1.ImageEditingRequest
{
    Image = imageBytes,     // Original image as byte array
    Mask = maskBytes,       // Optional mask (PNG, same dimensions)
    Prompt = "Edit description",
    Size = "1024x1024",
    Quality = "high"
};
Stable Image Ultra Parameters
var request = new StableImageUltra.ImageGenerationRequest
{
    Prompt = "Professional prompt",
    NegativePrompt = "unwanted, blurry, low quality",
    Size = "1024x1024",
    OutputFormat = "png",   // png, jpg, jpeg, webp
    Seed = 42               // For reproducible results
};

๐Ÿ‘๏ธ Computer Vision APIs

Azure Vision Captioning
// Single caption
var visionModel = AzureVisionCaptioningModel.Create(endpoint, apiKey);
var caption = await visionModel.GenerateCaptionAsync(imageStream);

// With options
var options = new ImageCaptionOptions
{
    Language = "en",              // Language code
    GenderNeutralCaption = true   // Inclusive language
};
var caption = await visionModel.GenerateCaptionAsync(imageStream, options);

// Dense captioning (multiple regions)
var denseCaptions = await visionModel.GenerateDenseCaptionsAsync(imageStream);

๐Ÿ› ๏ธ Utility APIs Deep Dive

๐Ÿ“‹ Image Format Converter
// Format detection and conversion
string mimeType = ImageFormatConverter.GetMimeType(".jpg");         // "image/jpeg"
string extension = ImageFormatConverter.GetFileExtension("image/png"); // ".png"
bool isSupported = ImageFormatConverter.IsValidImageFormat("webp");    // true
string[] formats = ImageFormatConverter.GetSupportedFormats();         // All supported
string[] mimeTypes = ImageFormatConverter.GetSupportedMimeTypes();     // All MIME types
๐Ÿ“Š Image Quality Analyzer
// Individual metrics
double sharpness = await ImageQualityAnalyzer.CalculateSharpnessAsync(stream);   // 0.0-1.0
double brightness = await ImageQualityAnalyzer.CalculateBrightnessAsync(stream); // 0.0-1.0  
double contrast = await ImageQualityAnalyzer.CalculateContrastAsync(stream);     // 0.0-1.0

// Comprehensive analysis
var metrics = await ImageQualityAnalyzer.AnalyzeQualityAsync(stream);
Console.WriteLine($"Overall Quality: {metrics.OverallScore:P2}");
๐Ÿ“‹ Image Metadata Extractor
// Extract comprehensive metadata
var metadata = await ImageMetadataExtractor.ExtractMetadataAsync(filePath);
Console.WriteLine($"Dimensions: {metadata.Width}x{metadata.Height}");
Console.WriteLine($"Format: {metadata.Format}");
Console.WriteLine($"File Size: {metadata.Size:N0} bytes");
Console.WriteLine($"Created: {metadata.CreationDate}");

// Validate metadata integrity
bool hasValidMetadata = await ImageMetadataExtractor.HasValidMetadataAsync(stream);
๐Ÿ“ Image Size Validator
// Simple validation
bool isValid = ImageSizeValidator.IsValidSize(1920, 1080, 2048, 2048);

// Advanced constraint validation
var constraints = new SizeConstraints
{
    MinWidth = 320, MaxWidth = 1920,
    MinHeight = 240, MaxHeight = 1080,
    MinAspectRatio = 0.5, MaxAspectRatio = 2.0
};
bool withinBounds = ImageSizeValidator.IsWithinBounds(width, height, constraints);

// Intelligent scaling
var (fitWidth, fitHeight) = ImageSizeValidator.ScaleToFit(3000, 2000, 1024, 1024);
var (fillWidth, fillHeight) = ImageSizeValidator.ScaleToFill(1920, 1080, 800, 600);
๐Ÿ“ Aspect Ratio Converter
// Calculate ratios
double ratio = AspectRatioConverter.CalculateAspectRatio(1920, 1080);              // 1.777...
var dimensions = AspectRatioConverter.GetDimensionsForAspectRatio(16.0/9.0, 1920); // (1920, 1080)
bool isValid = AspectRatioConverter.IsValidAspectRatio(1.77, tolerance: 0.01);     // true

๐Ÿ”ง Advanced Usage Examples

๐ŸŽจ Multi-Model Image Generation Pipeline

public class ImageGenerationPipeline
{
    private readonly IAzureImageClient _client;
    private readonly DALLE3Model _dalle3;
    private readonly GPTImage1Model _gptImage1; 
    private readonly StableImageUltraModel _stableUltra;

    public async Task<GenerationResult> GenerateWithFallback(string prompt)
    {
        var strategies = new[]
        {
            (Model: _dalle3, Name: "DALL-E 3"),
            (Model: _gptImage1, Name: "GPT-Image-1"), 
            (Model: _stableUltra, Name: "Stable Image Ultra")
        };

        foreach (var (model, name) in strategies)
        {
            try
            {
                Console.WriteLine($"Attempting generation with {name}...");
                var response = await _client.GenerateImageAsync(model, new { Prompt = prompt });
                
                // Analyze quality
                using var stream = new MemoryStream(response.GetImageBytes());
                var quality = await ImageQualityAnalyzer.AnalyzeQualityAsync(stream);
                
                if (quality.OverallScore > 0.7) // Quality threshold
                {
                    return new GenerationResult
                    {
                        Success = true,
                        ModelUsed = name,
                        ImageData = response.GetImageBytes(),
                        QualityScore = quality.OverallScore
                    };
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine($"{name} failed: {ex.Message}");
            }
        }

        return new GenerationResult { Success = false };
    }
}

๐Ÿ“Š Batch Image Quality Assessment

public class BatchImageProcessor
{
    public async Task<QualityReport> AnalyzeImageCollection(string[] imagePaths)
    {
        var results = new List<ImageAnalysisResult>();
        var semaphore = new SemaphoreSlim(Environment.ProcessorCount); // Limit concurrency

        var tasks = imagePaths.Select(async path =>
        {
            await semaphore.WaitAsync();
            try
            {
                return await AnalyzeSingleImage(path);
            }
            finally
            {
                semaphore.Release();
            }
        });

        var analysisResults = await Task.WhenAll(tasks);
        
        return new QualityReport
        {
            TotalImages = analysisResults.Length,
            AverageQuality = analysisResults.Average(r => r.QualityScore),
            HighQualityCount = analysisResults.Count(r => r.QualityScore > 0.8),
            LowQualityImages = analysisResults
                .Where(r => r.QualityScore < 0.5)
                .Select(r => r.FilePath)
                .ToList()
        };
    }

    private async Task<ImageAnalysisResult> AnalyzeSingleImage(string path)
    {
        using var stream = File.OpenRead(path);
        
        // Extract metadata
        var metadata = await ImageMetadataExtractor.ExtractMetadataAsync(stream);
        
        // Analyze quality
        stream.Position = 0;
        var quality = await ImageQualityAnalyzer.AnalyzeQualityAsync(stream);
        
        // Validate dimensions
        var constraints = new SizeConstraints { MinWidth = 100, MaxWidth = 4096 };
        bool validSize = ImageSizeValidator.IsWithinBounds(
            metadata.Width, metadata.Height, constraints);

        return new ImageAnalysisResult
        {
            FilePath = path,
            Metadata = metadata,
            QualityScore = quality.OverallScore,
            IsValidSize = validSize,
            Format = metadata.Format
        };
    }
}

๐Ÿšจ Error Handling & Diagnostics

The SDK provides comprehensive error handling with detailed diagnostics:

try
{
    var response = await client.GenerateImageAsync(model, request);
}
catch (AzureImageException ex)
{
    // Azure Image SDK specific errors
    Console.WriteLine($"SDK Error: {ex.Message}");
    Console.WriteLine($"Error Code: {ex.ErrorCode}");
    Console.WriteLine($"Status Code: {ex.StatusCode}");
    Console.WriteLine($"Request ID: {ex.RequestId}");
}
catch (ArgumentException ex)
{
    // Parameter validation errors
    Console.WriteLine($"Invalid parameters: {ex.Message}");
}
catch (HttpRequestException ex)
{
    // Network connectivity errors
    Console.WriteLine($"Network error: {ex.Message}");
}
catch (TaskCanceledException ex)
{
    // Timeout errors
    Console.WriteLine($"Request timeout: {ex.Message}");
}

๐Ÿ“ Structured Logging

// Configure logging in Program.cs
builder.Services.AddLogging(logging =>
{
    logging.AddConsole();
    logging.AddApplicationInsights(); // Optional: Azure Application Insights
    logging.SetMinimumLevel(LogLevel.Information);
});

// The SDK automatically logs:
// - Request/response details
// - Performance metrics  
// - Error diagnostics
// - Quality analysis results
// - Retry attempts

๐Ÿงช Testing & Development

๐Ÿ“ฆ Running the Samples

# Clone the repository
git clone https://github.com/DrHazemAli/AzureImageSDK.git
cd AzureImageSDK

# Navigate to samples
cd samples/SampleProject

# Configure your API keys in appsettings.json
# Then run the sample
dotnet run

๐Ÿ”ง Building from Source

# Restore dependencies
dotnet restore

# Build the solution
dotnet build

# Run tests
dotnet test

# Create NuGet package
dotnet pack --configuration Release

๐Ÿ“š Documentation & Resources

Resource Description Link
๐Ÿ“– Wiki Comprehensive documentation and guides GitHub Wiki
๐Ÿ”ง API Reference Detailed API documentation Wiki/API-Reference
๐Ÿš€ Getting Started Step-by-step setup guides Wiki/Getting-Started
๐Ÿ› ๏ธ Utilities Guide Image processing utilities documentation Wiki/Utilities
๐Ÿ’ก Best Practices Performance and security recommendations Wiki/Best-Practices
๐Ÿ› Troubleshooting Common issues and solutions Wiki/Troubleshooting
๐Ÿ“ Changelog Release notes and migration guides CHANGELOG.md

๐Ÿค Contributing

We welcome contributions! Here's how you can help:

๐Ÿ”ง Development Setup

  1. Fork & Clone

    git clone https://github.com/your-username/AzureImageSDK.git
    cd AzureImageSDK
    
  2. Install Dependencies

    dotnet restore
    
  3. Create Feature Branch

    git checkout -b feature/amazing-new-feature
    
  4. Make Changes & Test

    dotnet build
    dotnet test
    
  5. Submit Pull Request

๐Ÿ“‹ Contribution Guidelines

  • โœ… Follow C# coding conventions and best practices
  • โœ… Write comprehensive unit tests for new features
  • โœ… Update documentation for API changes
  • โœ… Ensure all tests pass before submitting
  • โœ… Add entry to CHANGELOG.md for significant changes

๐Ÿ› Reporting Issues

Found a bug? Have a feature request? Please:

  1. Search existing issues to avoid duplicates
  2. Use issue templates for consistency
  3. Provide detailed reproduction steps
  4. Include environment information (.NET version, OS, etc.)

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


๐Ÿ™ Acknowledgments

  • Azure AI Team - For providing excellent AI APIs and documentation
  • .NET Community - For outstanding tooling, libraries, and ecosystem
  • Contributors - Everyone who has contributed code, documentation, or feedback
  • Users - The developers and organizations using this SDK in production

๐Ÿ“ž Support & Community

Channel Purpose Link
๐Ÿ“– Documentation Comprehensive guides and API reference GitHub Wiki
๐Ÿ› Issues Bug reports and feature requests GitHub Issues
๐Ÿ’ฌ Discussions Q&A, ideas, and community chat GitHub Discussions
๐Ÿ“ Changelog Release notes and breaking changes CHANGELOG.md
๐Ÿ”— NuGet Package downloads and versions NuGet Gallery

<div align="center">

Made with โค๏ธ for the .NET community

โญ Star this repository if you find it useful!

๐Ÿš€ Get Started โ€ข ๐Ÿ“– Documentation โ€ข ๐Ÿ’ฌ Discussions

</div>

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.1 294 6/12/2025
1.0.0 275 6/11/2025