private async ValueTask <(string result, string error)> CreateImageByCompressPercentAsync(byte[] base64Image, string unq_name, string prefix, double percent = 1, bool cut = false) { var name = $"/resources/{prefix}/{unq_name}.png"; var bts = base64Image; var error = default(string); if (percent < 1) { (bts, error) = cut ? ImageCompressor.BinaryCutCompress(bts, percent, 320, 1600) : ImageCompressor.BinaryCompress(bts, percent, 800); } if (!string.IsNullOrEmpty(error)) { return(null, error); } using (var logFile = File.Create(this.env.WebRootPath + name)) using (var logWriter = new BufferedStream(logFile)) { await logWriter.WriteAsync(bts, 0, bts.Length); return(name, null); }; }