/// <summary> /// Outputs the properties to file. /// </summary> /// <param name="fileName">Name of the file.</param> /// <param name="imagingResponse">The imaging response.</param> protected void OutputPropertiesToFile(string fileName, ImagingResponse imagingResponse) { var path = Path.GetFullPath(Path.Combine(OutputFolder, fileName)); using (var fileStream = File.Create(path)) { var writer = new StreamWriter(fileStream); writer.WriteLine($"Width: {imagingResponse.Width}"); writer.WriteLine($"Height: {imagingResponse.Height}"); writer.WriteLine($"Horizontal resolution: {imagingResponse.HorizontalResolution}"); writer.WriteLine($"Vertical resolution: {imagingResponse.VerticalResolution}"); writer.WriteLine($"Bits per pixel: {imagingResponse.BitsPerPixel}"); if (imagingResponse.TiffProperties != null) { writer.WriteLine("Tiff properties:"); writer.WriteLine($"Frames count: {imagingResponse.TiffProperties.Frames.Count}"); writer.WriteLine($"Camera owner name: {imagingResponse.TiffProperties.ExifData?.CameraOwnerName}"); writer.WriteLine($"Byte order: {imagingResponse.TiffProperties.ByteOrder}"); } } Console.WriteLine($"File {fileName} is saved to {Path.GetDirectoryName(path)}"); }
public void AppendTiffTest() { bool passed = false; WriteLineEverywhere("AppendTiffTest"); string inputFileName = "test.tiff"; string folder = TempFolder; if (!CheckInputFileExists(inputFileName)) { throw new ArgumentException( $"Input file {inputFileName} doesn't exist in the specified storage folder: {folder}. Please, upload it first."); } string resultFileName = $"{inputFileName}_merged.tiff"; string outPath = null; string inputPath = TempFolder + "/" + inputFileName; string storage = this.TestStorage; try { WriteLineEverywhere($"Input image: {inputFileName}"); outPath = TempFolder + "/" + resultFileName; // remove output file from the storage (if exists) if (this.ImagingApi.ObjectExists(new ObjectExistsRequest(outPath, storage)).Exists.Value) { this.ImagingApi.DeleteFile(new DeleteFileRequest(outPath, storage)); } if (!this.ImagingApi.ObjectExists(new ObjectExistsRequest(inputPath, storage)).Exists.Value) { this.ImagingApi.CopyFile(new CopyFileRequest(OriginalDataFolder + "/" + inputFileName, folder + "/" + inputFileName, storage, storage)); } this.ImagingApi.CopyFile(new CopyFileRequest(inputPath, outPath, storage, storage)); Assert.IsTrue(this.ImagingApi.ObjectExists(new ObjectExistsRequest(outPath, storage)).Exists.Value); var request = new AppendTiffRequest(resultFileName, inputFileName, storage, folder); ImagingApi.AppendTiff(request); StorageFile resultInfo = this.GetStorageFileInfo(folder, resultFileName, storage); if (resultInfo == null) { throw new ArgumentException( $"Result file {resultFileName} doesn't exist in the specified storage folder: {folder}. Result isn't present in the storage by an unknown reason."); } ImagingResponse resultProperties = ImagingApi.GetImageProperties(new GetImagePropertiesRequest(resultFileName, folder, storage)); Assert.NotNull(resultProperties); ImagingResponse originalProperties = ImagingApi.GetImageProperties(new GetImagePropertiesRequest(inputFileName, folder, storage)); Assert.NotNull(originalProperties); Assert.NotNull(resultProperties.TiffProperties); Assert.NotNull(originalProperties.TiffProperties); Assert.AreEqual(originalProperties.TiffProperties.Frames.Count * 2, resultProperties.TiffProperties.Frames.Count); Assert.AreEqual(originalProperties.Width, resultProperties.Width); Assert.AreEqual(originalProperties.Height, resultProperties.Height); passed = true; } catch (Exception ex) { FailedAnyTest = true; WriteLineEverywhere(ex.Message); throw; } finally { if (this.RemoveResult && this.ImagingApi.ObjectExists(new ObjectExistsRequest(outPath, storage)).Exists.Value) { this.ImagingApi.DeleteFile(new DeleteFileRequest(outPath, storage)); } WriteLineEverywhere($"Test passed: {passed}"); } }