public void Setup() { IP = new ImageProcessing.ImageProcessing { Log = new LoggerConfiguration().CreateLogger() }; ImageUri = new Uri("file:///C:/Source/TremendousIIIF/TremendousIIIF.Benchmark/TestData/RoyalMS.jp2"); Quality = new Common.Configuration.ImageQuality(); Request = new ImageRequest("", new ImageRegion(ImageRegionMode.Full), new ImageSize(ImageSizeMode.Max, 1), new ImageRotation(0, false), ImageQuality.gray, ImageFormat.jpg); }
private async Task <dynamic> ImageInfo(dynamic parameters, CancellationToken token) { try { var filename = parameters.id; var imageUri = new Uri(new Uri(Conf.Location), filename); var requestId = Context.GetOwinEnvironment()["RequestId"] as string; (var maxWidth, var maxHeight, var maxArea) = GetSizeConstraints(Conf); var processor = new ImageProcessing.ImageProcessing { HttpClient = HttpClient, Log = Log }; var metadata = await processor.GetImageInfo(imageUri, Conf.DefaultTileWidth, requestId); var full_id = Conf.BaseUri == null? Request.Url.ToString().Replace("/info.json", "") : string.Format("{0}ark:/{1}/{2}", Conf.BaseUri.ToString(), parameters.naan, parameters.id); var info = new ImageInfo(metadata, Conf, maxWidth, maxHeight, maxArea) { ID = full_id, }; Log.Debug("{@ImageInfo}", info); return(await Negotiate .WithAllowedMediaRange(new MediaRange("application/json")) .WithAllowedMediaRange(new MediaRange("application/ld+json")) .WithHeader("Link", null) // hide nancy automatic Link: rel="alternative" .WithModel(info)); } catch (FileNotFoundException e) { Log.Error("Unable to load source image @{FileName}", e.FileName); return(HttpStatusCode.NotFound); } catch (NotImplementedException e) { Log.Information(e, "Un-implemented feature requested"); return(HttpStatusCode.BadRequest); } catch (ArgumentException e) { Log.Error(e, "Error parsing argument"); return(HttpStatusCode.BadRequest); } catch (Exception e) { Log.Error(e, "Unexpected exception"); return(HttpStatusCode.InternalServerError); } }
private void ClickButtonSync() { try { ImageProcessing.ImageProcessing ip = new ImageProcessing.ImageProcessing(); Stopwatch Timer = new Stopwatch(); ip.ImageOpen(_OldImage); Timer.Start(); ip.ToMainColors(); Timer.Stop(); TimeShow(Timer.ElapsedMilliseconds); LoadFromMemory(ip.bitMap); } catch (ArgumentNullException) { MessageBox.Show("You must load a image first"); } catch { MessageBox.Show("There was a problem with render picture"); } }
public void LoadBitmapTest() { ImageProcessing.ImageProcessing ip = new ImageProcessing.ImageProcessing(); ip.bitmap = new System.Drawing.Bitmap(400, 400); Assert.NotNull(ip.LoadBitmap()); }
public void CheckMaxRGBTest() { ImageProcessing.ImageProcessing ip = new ImageProcessing.ImageProcessing(); byte[] testByte = new byte[] { 22, 44, 33 }; Assert.AreEqual(1, ip.CheckMaxRGB(testByte)); }
public void ChangeColorTest() { ImageProcessing.ImageProcessing ip = new ImageProcessing.ImageProcessing(); byte[] bytes = { 0, 255, 0 }; Assert.AreEqual(bytes, ip.ChangeColor(1)); }
private async Task <dynamic> ImageRequest(dynamic parameters, CancellationToken token) { try { var filename = parameters.id; var identifier = string.Format("ark:/{0}/{1}", parameters.naan, parameters.id); (var maxWidth, var maxHeight, var maxArea) = GetSizeConstraints(Conf); var requestId = Context.GetOwinEnvironment()["RequestId"] as string; var request = ImageRequestValidator.Validate( parameters.region, parameters.size, parameters.rotation, parameters.quality, parameters.format, requestId, maxWidth, maxHeight, maxArea, Conf.SupportedFormats()); Log.Debug("{@Request}", request); var imageUri = new Uri(new Uri(Conf.Location), filename); var allowSizeAboveFull = Conf.AllowSizeAboveFull; var processor = new ImageProcessing.ImageProcessing { HttpClient = HttpClient, Log = Log }; Stream ms = await processor.ProcessImage(imageUri, request, Conf.ImageQuality, allowSizeAboveFull, Conf.PdfMetadata); ImageFormat f = request.Format; string mimetype = f.GetAttribute <ImageFormatMetadataAttribute>().MimeType; return(new StreamResponse(() => ms, mimetype) .WithHeader("Link", string.Format("<{0}>;rel=\"profile\"", new ImageInfo().Profile.First())) #if !DEBUG .AsAttachment(string.Format("{0}.{1}", (string)parameters.id, (string)parameters.format))); #else ; #endif } catch (FileNotFoundException e) { Log.Error("Unable to load source image @{FileName}", e.FileName); return(HttpStatusCode.NotFound); } catch (NotImplementedException e) { Log.Information(e, "Un-implemented feature requested"); return(Response.AsJson(e.Message, HttpStatusCode.BadRequest)); } catch (ArgumentException e) { Log.Error(e, "Error parsing argument"); return(Response.AsJson(e.Message, HttpStatusCode.BadRequest)); } catch (FormatException e) { Log.Error(e, "Error parsing argument"); return(Response.AsJson(e.Message, HttpStatusCode.BadRequest)); } catch (Exception e) { Log.Error(e, "Unexpected exception"); return(HttpStatusCode.InternalServerError); } }