public void Save() { var words = reader.Read(configuration.PathToWordsFile); var preparedWords = preprocessor.PrepareWords(words); var wordsFrequency = wordsCounter.GetWordsFrequency(preparedWords); var tags = tagsGenerator.GenerateTags(wordsFrequency); var image = visualizer.Visualize(tags); imageWriter.Write(image, configuration.OutFileName, configuration.ImageFormat.ToString(), configuration.DirectoryToSave); }
private async Task <ImageInfo> SaveImages(SKImage image, SKImage miniature, string directory) { string formatStr = reader.Format == SKEncodedImageFormat.Jpeg ? "jpg" : reader.Format.ToString().ToLower(); string id = GenerateId(); string path = $"{directory}/{id}.{formatStr}"; var tasks = new List <Task>() { writer.Write(image, path, reader.Format) }; string minipath; if (miniature != null) { minipath = $"{directory}/{options.MiniaturePrefix}{id}.{formatStr}"; tasks.Add(writer.Write(miniature, minipath, reader.Format)); } else { minipath = path; } try { await Task.WhenAll(tasks); } catch { await writer.TryClearUp(path, minipath); throw; } return(new ImageInfo { Id = id, Path = path, MiniaturePath = minipath, Format = formatStr }); }
public async Task <IActionResult> UploadPhoto(Guid id, [FromForm] IFormFile file) { var uploadedImageName = await _imageWriter.Write(file); if (uploadedImageName == null) { return(StatusCode(Status500InternalServerError)); } ((Customer)HttpContext.Items["entity"]).PhotoName = uploadedImageName; _repositories.Customer.Update((Customer)HttpContext.Items["entity"]); _repositories.Customer.Save(); return(NoContent()); }
public Result <None> Save() { var pathToSave = Path.Combine(configuration.DirectoryToSave, $"{configuration.OutFileName}.{configuration.ImageFormat}"); return(reader.Read(configuration.PathToWordsFile) .Then(words => preprocessor.PrepareWords(words)) .Then(preparedWords => wordsCounter.GetWordsFrequency(preparedWords)) .Then(wordsFrequency => tagsGenerator.GenerateTags(wordsFrequency)) .Then(tags => visualizer.Visualize(tags)) .Then(image => imageWriter.Write( image, pathToSave) .RefineError("Failed to save file"))); }
public void WriteScene(string source, string writeTo) { LoadObj(source); var matrix = Draw(); var config = _configProvider.Get(); var pixels = new List <RGBA>(); for (var i = 0; i < matrix.GetLength(0); i++) { var tmp = new List <RGBA>(); for (var j = 0; j < matrix.GetLength(1); j++) { tmp.Add(matrix[i, j]); } tmp.Reverse(); pixels.InsertRange(0, tmp); } _imageWriter.Write(writeTo, pixels, config.Width, config.Height); }
public void Convert(Image image, string destinationPath) { _writer.Write(destinationPath, image); }
public void Convert(string source, string output) { _reader.Read(source); _writer.Write(output, _reader.Pixels, _reader.Width, _reader.Depth); }