#262 allowing to retain resized images to be served as jpeg after webp conversion of original images
This commit is contained in:
parent
59d515b919
commit
e546293739
@ -21,17 +21,18 @@ namespace RMuseum.Controllers
|
||||
public class ImageController : Controller
|
||||
{
|
||||
/// <summary>
|
||||
/// returns image stream
|
||||
/// returns image stream with image/jpeg MIME type
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="size"></param>
|
||||
/// <param name="mimeForResized"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("{size}/{id}.jpg")]
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(FileStreamResult))]
|
||||
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
|
||||
|
||||
public async Task<IActionResult> Get(Guid id, string size)
|
||||
public async Task<IActionResult> Get(Guid id, string size, string mimeForResized = "image/jpeg")
|
||||
{
|
||||
RServiceResult<RPictureFile> img =
|
||||
await _pictureFileService.GetImage(id);
|
||||
@ -56,8 +57,29 @@ namespace RMuseum.Controllers
|
||||
return BadRequest(imgPath.ExceptionString);
|
||||
|
||||
|
||||
return new FileStreamResult(new FileStream(imgPath.Result, FileMode.Open, FileAccess.Read), img.Result.ContentType);
|
||||
|
||||
return new FileStreamResult(new FileStream(imgPath.Result, FileMode.Open, FileAccess.Read),
|
||||
size == "orig" ?
|
||||
img.Result.ContentType
|
||||
:
|
||||
mimeForResized
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// returns image stream with image/webp MIME type
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="size"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
[HttpGet("{size}/{id}.webp")]
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(FileStreamResult))]
|
||||
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
|
||||
|
||||
public async Task<IActionResult> GetWebp(Guid id, string size)
|
||||
{
|
||||
return await Get(id, size, "image/webp");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -1449,9 +1449,18 @@
|
||||
<param name="locationService"></param>
|
||||
<param name="configuration"></param>
|
||||
</member>
|
||||
<member name="M:RMuseum.Controllers.ImageController.Get(System.Guid,System.String)">
|
||||
<member name="M:RMuseum.Controllers.ImageController.Get(System.Guid,System.String,System.String)">
|
||||
<summary>
|
||||
returns image stream
|
||||
returns image stream with image/jpeg MIME type
|
||||
</summary>
|
||||
<param name="id"></param>
|
||||
<param name="size"></param>
|
||||
<param name="mimeForResized"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Controllers.ImageController.GetWebp(System.Guid,System.String)">
|
||||
<summary>
|
||||
returns image stream with image/webp MIME type
|
||||
</summary>
|
||||
<param name="id"></param>
|
||||
<param name="size"></param>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user