protected Stream OutputImage(Image SourceImage)
 {
     MemoryStream imageStream = new MemoryStream();
     if (LosslessFormat)
     { // Lossless Format - PNG
         SourceImage.SavePng(imageStream);
     }
     else
     { // Lossy Format - JPG
         byte quality = Math.Min((byte)100, Math.Max((byte)1, this.Quality));
         SourceImage.SaveJpg(quality, imageStream);
     }
     imageStream.Position = 0;
     return imageStream;
 }
 public static string SaveThumbnailAttachment(this IAttachment Attachment, DiscoDataContext Database, Image Thumbnail)
 {
     string filePath = Attachment.RepositoryThumbnailFilename(Database);
     Thumbnail.SaveJpg(90, filePath);
     return filePath;
 }