diff --git a/app/MindWork AI Studio/Chat/ContentImage.cs b/app/MindWork AI Studio/Chat/ContentImage.cs
index 6026e554..a6f385b8 100644
--- a/app/MindWork AI Studio/Chat/ContentImage.cs
+++ b/app/MindWork AI Studio/Chat/ContentImage.cs
@@ -1,6 +1,7 @@
using System.Text.Json.Serialization;
using AIStudio.Provider;
+using AIStudio.Tools.Validation;
namespace AIStudio.Chat;
@@ -50,6 +51,23 @@ public sealed class ContentImage : IContent, IImageSource
#endregion
+ ///
+ /// Creates a ContentImage from a local file path.
+ ///
+ /// The path to the image file.
+ /// A new ContentImage instance if the file is valid, null otherwise.
+ public static async Task CreateFromFileAsync(string filePath)
+ {
+ if (!await FileExtensionValidation.IsImageExtensionValidWithNotifyAsync(filePath))
+ return null;
+
+ return new ContentImage
+ {
+ SourceType = ContentImageSource.LOCAL_PATH,
+ Source = filePath,
+ };
+ }
+
///
/// The type of the image source.
///
diff --git a/app/MindWork AI Studio/Tools/Validation/FileExtensionValidation.cs b/app/MindWork AI Studio/Tools/Validation/FileExtensionValidation.cs
index cc40c959..741e596a 100644
--- a/app/MindWork AI Studio/Tools/Validation/FileExtensionValidation.cs
+++ b/app/MindWork AI Studio/Tools/Validation/FileExtensionValidation.cs
@@ -52,4 +52,31 @@ public static class FileExtensionValidation
return true;
}
+
+ ///
+ /// Validates that the file is a supported image format and sends appropriate MessageBus notifications when invalid.
+ ///
+ /// The file path to validate.
+ /// True if valid image, false if invalid (error already sent via MessageBus).
+ public static async Task IsImageExtensionValidWithNotifyAsync(string filePath)
+ {
+ var ext = Path.GetExtension(filePath).TrimStart('.');
+ if (string.IsNullOrWhiteSpace(ext))
+ {
+ await MessageBus.INSTANCE.SendError(new(
+ Icons.Material.Filled.ImageNotSupported,
+ TB("File has no extension")));
+ return false;
+ }
+
+ if (!Array.Exists(FileTypeFilter.AllImages.FilterExtensions, x => x.Equals(ext, StringComparison.OrdinalIgnoreCase)))
+ {
+ await MessageBus.INSTANCE.SendError(new(
+ Icons.Material.Filled.ImageNotSupported,
+ TB("Unsupported image format")));
+ return false;
+ }
+
+ return true;
+ }
}