Beispiel #1
0
        public async Task <ActionResult> ProcessImage(string key)
        {
            if (!dbcontext.Access.FirstOrDefault().Key.Equals(key))
            {
                return(Unauthorized("You can't access to this api!"));
            }

            MediaInfo mediaInfo = new MediaInfo();
            DominantRGBColorCalculator colorInfo = new DominantRGBColorCalculator();
            Image img;
            await mediaApi.ProcessMedia(".jpg", "image");

            foreach (Media media in mediaApi.mediaList)
            {
                try
                {
                    img = await mediaInfo.GetImageFromURL(media.Path);

                    media.Orientation = mediaInfo.GetImageOrientation(img);
                    media.ImageText   = await mediaInfo.GetImageTextUrlAsync(media.Path, ".jpg");

                    media.Colors = colorInfo.GetMostUsedColorName(new Bitmap(img));
                    await dbcontext.Media.AddAsync(media);
                }
                catch (ArgumentException) {}
            }
            await dbcontext.SaveChangesAsync();

            return(Ok("Success"));
        }