![]() VP of Solution Architecture at Episerver Most Valued Professional (EMVP) alumni. I think it would be great to wire this in as an extension to ImageResizer plug in for Episerver but that's another blog! Comments This is just a quick example to show how the TinyPNG API can be used to automatically optimise images when they are uploaded in Episerver, it doesn't take image resizing into account. Public void Uninitialize(InitializationEngine context)ĬontentEvents.CreatedContent -= Optimise Repo.Save(writeableImage, SaveAction.Patch, AccessLevel.NoAccess) Var blob = blobFactory.CreateBlob(writeableImage.BinaryDataContainer, Path.GetExtension(image.Name)) Var writeableImage = image.CreateWritableClone() as ImageFile Var optimisedImage = client.DownloadData(client.ResponseHeaders) ![]() Using (var memoryStream = new MemoryStream()) Var auth = Convert.ToBase64String(("api:" + key)) Ĭ(HttpRequestHeader.Authorization, "Basic " + auth) ![]() Private void OptimiseImage(ImageData image) If (extension.Equals(".PNG", StringComparison.InvariantCultureIgnoreCase) ||Įxtension.Equals(".JPG", StringComparison.InvariantCultureIgnoreCase)) Var extension = Path.GetExtension(image.Name) Private void Optimise(object sender, ContentEventArgs e) Var contentEvents = () ĬontentEvents.CreatedContent += Optimise Public void Initialize(InitializationEngine context) Public class ImageOptimiseInit : IInitializableModule From the popup, set your expected dimension and click on the scale button. So this blog shares some code that shows how it's possible to optimise image size on upload using the API: sharp - High performance Node.js image processing, the fastest module to resize and compress JPEG, PNG, WebP, AVIF and TIFF images. Go to Image > Scale Image to resize the image. On testing it particularly seems to excel with transparent PNG's. One of best tools around for compressing PNG's is TinyPNG. However, when working on some recent proof of concepts it was noticed that the ImageResizer plugin did not perform too well with transparent PNGs. Episerver already has the awesome ImageResizer plugin for Episerver which can be used to compress and resize images. So it's always recommended that images are optimised. We all know that large image size is a killer for site performance. Reduce image size to share it with friends or upload it to your social networks. Resize JPG, PNG, GIF or BMP images online. iOS 12 Shortcuts script to compress (and resize) images with TinyPNG or TinyJPG on your iPhone or iPad. iOS Shortcut for iPhone & iPad By Daniel Setzermann. You will get a versatile image with great quality, that you can send to anyone without taking too much time. The Tiny Image Processor is a Desktop App, allowing you to (batch) resize images and use your API key to up and download images from the TinyPNG servers. ![]() Using TinyPNG to automatically compress images in Episerver If you have a huge photo, we recommend resizing it to about 1900 by 1100 pixels, with JPG format and 90 quality. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |