private async Task <IActionResult> ReturnFile(string path, int h, int w, string realfileName, bool download, string suggestefFileName) { try { if (realfileName.IsStaticImage() && h > 0 && w > 0) { if (download) { return(await this.AiurFile(await _imageCompressor.Compress(path, realfileName, w, h), realfileName, suggestefFileName)); } else { return(await this.AiurFile(await _imageCompressor.Compress(path, realfileName, w, h), realfileName)); } } else if (realfileName.IsStaticImage()) { if (download) { return(await this.AiurFile(await _imageCompressor.ClearExif(path, realfileName), realfileName, suggestefFileName)); } else { return(await this.AiurFile(await _imageCompressor.ClearExif(path, realfileName), realfileName)); } } else { if (download) { return(await this.AiurFile(path, realfileName, suggestefFileName)); } else { return(await this.AiurFile(path, realfileName)); } } } catch (Exception e) when(e is DirectoryNotFoundException || e is FileNotFoundException) { return(NotFound()); } }
private async Task <IActionResult> FileWithImageCompressor(string path, string extension) { int.TryParse(Request.Query["w"], out int w); int.TryParse(Request.Query["h"], out int h); if (h >= 0 && w >= 0 && h + w > 0) { return(this.WebFile(await _imageCompressor.Compress(path, w, h), extension)); } else { return(this.WebFile(await _imageCompressor.ClearExif(path), extension)); } }
private async Task <IActionResult> FileWithImageCompressor(string path, string extension) { int.TryParse(Request.Query["w"], out int width); bool.TryParse(Request.Query["square"], out bool square); if (width > 0) { if (square) { return(this.WebFile(await _imageCompressor.Compress(path, width, width), extension)); } else { return(this.WebFile(await _imageCompressor.Compress(path, width, 0), extension)); } } else { return(this.WebFile(await _imageCompressor.ClearExif(path), extension)); } }