{"id":26829436,"url":"https://github.com/saifsaidi/blazorimage","last_synced_at":"2025-03-30T13:16:38.562Z","repository":{"id":285121255,"uuid":"949727116","full_name":"SaifSaidi/BlazorImage","owner":"SaifSaidi","description":"Optimize images for lightning-fast Blazor applications — supporting static rendering and interactive server-side apps.","archived":false,"fork":false,"pushed_at":"2025-03-29T16:22:50.000Z","size":11289,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-29T17:27:25.266Z","etag":null,"topics":["blazor"],"latest_commit_sha":null,"homepage":"https://www.nuget.org/packages/BlazorImage","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SaifSaidi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-03-17T03:23:53.000Z","updated_at":"2025-03-29T16:22:53.000Z","dependencies_parsed_at":"2025-03-29T17:28:07.925Z","dependency_job_id":"d36e3b55-05cd-4eef-b716-24386bc5c5b9","html_url":"https://github.com/SaifSaidi/BlazorImage","commit_stats":null,"previous_names":["saifsaidi/blazorimage"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SaifSaidi%2FBlazorImage","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SaifSaidi%2FBlazorImage/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SaifSaidi%2FBlazorImage/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SaifSaidi%2FBlazorImage/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SaifSaidi","download_url":"https://codeload.github.com/SaifSaidi/BlazorImage/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246320198,"owners_count":20758410,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["blazor"],"created_at":"2025-03-30T13:16:38.070Z","updated_at":"2025-03-30T13:16:38.554Z","avatar_url":"https://github.com/SaifSaidi.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"﻿# BlazorImage - Blazor Images Optimization\n![BlazorImage](https://github.com/user-attachments/assets/355bdc29-2f02-41c9-8ba6-9095bb9d7961)\n\nBlazorImage is a powerful image optimization library for Blazor applications, supporting both static rendering and interactive server-side scenarios. It provides seamless image optimization with lazy loading, multiple format support, and responsive image handling.\n\n## Features\n\n- 🚀 Automatic image optimization\n- 🖼️ Multiple format support (WebP, JPEG, PNG, AVIF)\n- 🔄 Lazy loading built-in\n- 📱 Responsive images with art direction\n- ⚡ Static/Interactive rendering support\n- 🛠️ Developer mode for debugging\n- 🎨 Customizable image quality\n- 📏 Image dimensions control\n- 🖌️ Custom CSS classes and styles\n- 📦 Lightweight and easy to use\n- 📊 Progress tracking for image processing\n\n## Prerequisites\n\n- [.NET 9.0](https://dotnet.microsoft.com/en-us/download)\n\n## Limitations\n\n- BlazorImage is new and may have some limitations.\n- Local images only. Remote images are not supported yet.\n- Only dotnet 9.0 is supported or higher.\n\n## Installation\n\nTo install BlazorImage, add the following package reference to your project file:\n\n```xml\n\u003cPackageReference Include=\"BlazorImage\" Version=\"1.0.1\" /\u003e\n```\nThen, add the following namespace to your `_Imports.razor` file:\n\n```csharp\nusing BlazorImage;\n```\n\n## Setup Services\n\nTo use BlazorImage in your Blazor application, you need to register the required services:\n\n```csharp\nservices.AddBlazorImage();\n```\n\n### Endpoints (Optional, Development Stage)\n\nImages Cache Management Endpoints are available for managing cached images. To use these endpoints, add the following code:\n\n```csharp\napp.MapBlazorImage(\"/blazor/images\");\n```\n\n### Configuration\n\nconfigure the services with the following options:\n```csharp\nservices.AddBlazorImage(options =\u003e\n{\n    : Default quality for processed images (15-100). Default Value = 75\n    options.DefaultQuality = 80;\n\n    : Default file format for processed images (e.g., \"webp\", \"jpeg\"). Default is \"webp\n    options.DefaultFileFormat = FileFormat.webp;\n\n    : Path for storing processed images. Default is \"_blazor\".\n    options.Dir = \"_output\";\n\n    : Array of sizes for image configuration. Default [480, 640, 768, 1024, 1280, 1536] sizes\n    options.ConfigSizes = [640, 1024, 1280];\n\n    : Aspect ratio width for images. Default is 1.0\n    options.AspectWidth = 1.0'\n\n    : Aspect ratio height for images. Default is 1.0\n    options.AspectHeight = 1.0;\n\n    : Absolute expiration time relative to now for cached images. Default is 720 hours (30 days).\n    options.AbsoluteExpirationRelativeToNow = TimeSpan.FromHours(720);\n\n    : Sliding expiration time for cached images. Defualt is null.\n    options.SlidingExpiration = null;\n});\n```\n\n## Usage\n\n### Add script to App.razor\n```html\n\u003cscript src=\"_content/BlazorImage/BlazorImage.min.js\"\u003e\u003c/script\u003e\n```\n\n### CSS\n```html\n\u003clink rel=\"stylesheet\" href=\"@Assets[\"Assembly.styles.css\"]\" /\u003e\n```\n\n### Using `Image` Component\n\nThe `Image.razor` component is used to display optimized images.\n\n#### Parameters\n\n- `Src` (required): The source URL of the image (Local source only).\n- `Alt` (required): The alt text for the image.\n- `Width`: The width of the image.\n- `Height`: The height of the image.\n- `Fill`: A boolean indicating if the image should fill its container.\n- `EnableInteractiveState`: A boolean indicating if interactive state should be enabled. (default is `false`)\n- `LazyLoading`: A boolean indicating if lazy loading should be enabled (default is `true`).\n- `Title`: The title of the image.\n- `CssClass`: Additional CSS classes for the image.\n- `WrapperClass`: CSS classes for the wrapper element.\n- `Style`: Inline styles for the image.\n- `WrapperStyle`: Inline styles for the wrapper element.\n- `Quality`: The quality of the image.\n- `Format`: The format of the image (`webp`, `jpeg`, `png`, `avif`).\n- `Sizes`: The sizes attribute for responsive images.\n- `EnableDeveloperMode`: A boolean indicating if developer mode should be enabled.\n- `AdditionalAttributes`: Additional attributes for the image element.\n- \n#### Example\n\n```html\n\u003cImage Src=/image.jpg\" Alt=\"Example Image\" Width=\"800\" Height=\"600\" LazyLoading=\"true\" Title=\"Example Image Title\" CssClass=\"custom-image-class\" WrapperClass=\"custom-wrapper-class\" Style=\"border: 1px solid #ccc;\" WrapperStyle=\"padding: 10px;\" Quality=\"80\" Format=\"FileFormat.jpeg\" Sizes=\"(min-width: 1024px) 1024px, 100vw\" EnableDeveloperMode=\"true\" /\u003e\n``` \n### Using `Picture` Component\n\nThe `Picture.razor` component is used to display optimized images with support for multiple sources with figure.\n\n#### Parameters\n\n- `Src` (required): The source URL of the image (Local source only).\n- `Alt` (required): The alt text for the image.\n- `Width`: The width of the image.\n- `Height`: The height of the image.\n- `Fill`: A boolean indicating if the image should fill its container.\n- `EnableInteractiveState`: A boolean indicating if interactive state should be enabled. (default is `false`)\n- `LazyLoading`: A boolean indicating if lazy loading should be enabled (default is `true`).\n- `Title`: The title of the image.\n- `CssClass`: Additional CSS classes for the image.\n- `WrapperClass`: CSS classes for the wrapper element.\n- `Style`: Inline styles for the image.\n- `WrapperStyle`: Inline styles for the wrapper element.\n- `Quality`: The quality of the image.\n- `Format`: The format of the image (`webp`, `jpeg`, `png`, `avif`).\n- `Sizes`: The sizes attribute for responsive images.\n- `CaptionClass`: CSS classes for the caption element.\n- `Caption`: The caption text for the image.\n- `EnableDeveloperMode`: A boolean indicating if developer mode should be enabled.\n- `AdditionalAttributes`: Additional attributes for the image element.\n\n#### Example\n\n```html\n\u003cPicture Src=\"image.jpg\" Alt=\"Example Image\" Width=\"800\" Height=\"600\" LazyLoading=\"true\" Title=\"Example Image Title\" CssClass=\"custom-image-class\" WrapperClass=\"custom-wrapper-class\" Style=\"border: 1px solid #ccc;\" WrapperStyle=\"padding: 10px;\" Quality=\"80\" Format=\"FileFormat.jpeg\" Sizes=\"(min-width: 1024px) 1024px, 100vw\" CaptionClass=\"custom-caption-class\" Caption=\"This is an example caption.\" EnableDeveloperMode=\"true\" /\u003e\n```\n\n\n## License\n\nBlazorImage is licensed under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaifsaidi%2Fblazorimage","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsaifsaidi%2Fblazorimage","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaifsaidi%2Fblazorimage/lists"}