public static void Run(IImageMetadata input, IStringLocalizer localizer) { if (input.Name != input.Name.Trim()) { throw new InvalidOperationException("Invalid name: not trimmed"); } if (input.Name.Length < minNameLength || input.Name.Length > maxNameLength) { throw new RequestInputException(localizer["InvalidNameLength"] + $" {input.Name.Length}" + localizer["MustBeBetween"] + $" {minNameLength} " + localizer["And"] + $" {maxNameLength}"); } if (input.Description != input.Description.Trim()) { throw new InvalidOperationException("Invalid description: not trimmed"); } if (input.Description.Length < minDescriptionLength || input.Description.Length > maxDescriptionLength) { throw new RequestInputException(localizer["InvalidDescriptionLength"] + $" {input.Description.Length}" + localizer["MustBeBetween"] + $" {minDescriptionLength} " + localizer["And"] + $" {maxDescriptionLength}"); } if (input.Source != input.Source.Trim()) { throw new InvalidOperationException("Invalid source: not trimmed"); } if (input.Source.Length < minSourceLength || input.Source.Length > maxSourceLength) { throw new RequestInputException(localizer["InvalidSourceLength"] + $" {input.Source.Length}" + localizer["MustBeBetween"] + $" {minSourceLength} " + localizer["And"] + $" {maxSourceLength}"); } }
public void LoadImageMetadata() { SaveImageMetadata(); using (XmlReader reader = Helpers.CreateXmlReader(@"testImageMetadata.cxml")) { IImageMetadata metadata = (IImageMetadata) new ImageMetadata().Load("testImage.jpg", reader, null); Assert.AreEqual("33", metadata.Id); Assert.AreEqual("testImage.jpg", metadata.Filename); } }
public static int GetRotationAngle(string sourceFilePath) { int result = 0; try { IImageMetadata metadata = Sanselan.GetMetadata(new File(sourceFilePath)); if (metadata is JpegImageMetadata) { TiffField orientationValue = ((JpegImageMetadata)metadata).FindEXIFValue(ExifTagConstants.ExifTagOrientation); if (orientationValue != null) { int orientation = orientationValue.IntValue; switch (orientation) { case ExifTagConstants.OrientationValueRotate90Cw: result = 90; break; case ExifTagConstants.OrientationValueRotate180: result = 180; break; case ExifTagConstants.OrientationValueRotate270Cw: result = 270; break; default: break; } } } } catch { // gulp } return(result); }
public CachedImage(IImageMetadata metadata, Func <Task <Stream> > streamTask) { Metadata = metadata; StreamTask = streamTask; }