public async Task <bool> WriteAndCropFile(string fileHash, OffsetModel offsetData, int sourceWidth, int sourceHeight, FileIndexItem.Rotation rotation, string reference = null) { try { using (var thumbnailStream = new MemoryStream(offsetData.Data, offsetData.Index, offsetData.Count)) using (var smallImage = await Image.LoadAsync(thumbnailStream)) using (var outputStream = new MemoryStream()) { var smallImageWidth = smallImage.Width; var smallImageHeight = smallImage.Height; var result = NewImageSize.NewImageSizeCalc(smallImageWidth, smallImageHeight, sourceWidth, sourceHeight); smallImage.Mutate( i => i.Resize(smallImageWidth, smallImageHeight, KnownResamplers.Lanczos3) .Crop(new Rectangle(result.DestX, result.DestY, result.DestWidth, result.DestHeight))); var larger = (int)Math.Round(result.DestWidth * 1.2, 0); smallImage.Mutate( i => i.Resize(larger, 0, KnownResamplers.Lanczos3)); var rotate = RotateEnumToDegrees(rotation); smallImage.Mutate( i => i.Rotate(rotate)); await smallImage.SaveAsJpegAsync(outputStream); await _thumbnailStorage.WriteStreamAsync(outputStream, ThumbnailNameHelper.Combine(fileHash, ThumbnailSize.TinyMeta)); if (_appSettings.ApplicationType == AppSettings.StarskyAppType.WebController) { _logger.LogInformation($"[WriteAndCropFile] fileHash: {fileHash} is written"); } } return(true); } catch (Exception ex) { var message = ex.Message; if (message.StartsWith("Image cannot be loaded")) { message = "Image cannot be loaded"; } _logger.LogError($"[WriteFile@meta] Exception {reference} {message}", ex); return(false); } }
public JsonResult FetchClientSearchTypes(OffsetModel offmodel) { string errMessage = string.Empty; if (ModelState.IsValid) { var validation = SecurityController.ValidateToken(offmodel.TokenCode); try { if (validation.Validated == true) { //var AccListResult = _db.Query<AccountListModel>("Supreme_AccountListing",commandType: CommandType.StoredProcedure).ToList(); var AccListResult = _db.Query <SubCodeModel>(";Exec Supreme_getClientSearchTypes").ToList(); return(Json(AccListResult, JsonRequestBehavior.AllowGet)); } else { GenericResultModel AccListResult2 = new GenericResultModel(); AccListResult2.Status = "Fail"; AccListResult2.Remarks = validation.Errors[0].ToString(); logger.LogWrite(JsonConvert.SerializeObject(validation).ToString()); return(Json(AccListResult2, JsonRequestBehavior.AllowGet)); } } catch (Exception ee) { GenericResultModel AccListResult2 = new GenericResultModel(); AccListResult2.Status = "Fail"; AccListResult2.Remarks = ee.Message; GeneralService.WriteErrorLog(ref ee); return(Json(AccListResult2, JsonRequestBehavior.AllowGet)); } } else { var message = string.Join(" | ", ModelState.Values .SelectMany(v => v.Errors) .Select(e => e.ErrorMessage)); GenericResultModel AccListResult2 = new GenericResultModel(); AccListResult2.Status = "Fail"; AccListResult2.Remarks = message; logger.LogWrite(message); return(Json(AccListResult2, JsonRequestBehavior.AllowGet)); } }
public Task <bool> WriteAndCropFile(string fileHash, OffsetModel offsetData, int sourceWidth, int sourceHeight, FileIndexItem.Rotation rotation, string reference = null) { return(Task.FromResult(true)); }
public Tab(float value, UnitType units, OffsetModel offset_model) { handle = NativeMethods.XmTabCreate(value, (byte)units, (byte)offset_model, (byte)Native.Motif.Constant.XmALIGNMENT_BEGINNING, "."); }