From 860b724bd0b04e5c04e6e99cd3f737597651e1b2 Mon Sep 17 00:00:00 2001 From: David Vogel Date: Mon, 15 Jan 2024 21:27:44 +0100 Subject: [PATCH] Change DZI to encode tiles to WebP --- bin/stitch/dzi.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bin/stitch/dzi.go b/bin/stitch/dzi.go index cf53230..58da262 100644 --- a/bin/stitch/dzi.go +++ b/bin/stitch/dzi.go @@ -1,4 +1,4 @@ -// Copyright (c) 2023 David Vogel +// Copyright (c) 2023-2024 David Vogel // // This software is released under the MIT License. // https://opensource.org/licenses/MIT @@ -35,7 +35,7 @@ func NewDZI(stitchedImage *StitchedImage, dziTileSize, dziOverlap int) DZI { dzi := DZI{ stitchedImage: stitchedImage, - fileExtension: ".png", + fileExtension: ".webp", overlap: dziOverlap, tileSize: dziTileSize, @@ -82,7 +82,7 @@ func (d DZI) ExportDZIDescriptor(outputPath string) error { } dziDescriptor.Image.XMLNS = "http://schemas.microsoft.com/deepzoom/2008" - dziDescriptor.Image.Format = "png" + dziDescriptor.Image.Format = "webp" dziDescriptor.Image.Overlap = strconv.Itoa(d.overlap) dziDescriptor.Image.TileSize = strconv.Itoa(d.tileSize) dziDescriptor.Image.Size.Width = strconv.Itoa(d.stitchedImage.bounds.Dx()) @@ -121,8 +121,8 @@ func (d DZI) ExportDZITiles(outputDir string) error { rect = rect.Inset(-d.overlap) img := stitchedImage.SubStitchedImage(rect) filePath := filepath.Join(levelBasePath, fmt.Sprintf("%d_%d%s", iX, iY, d.fileExtension)) - if err := exportPNGSilent(img, filePath); err != nil { - return fmt.Errorf("failed to export PNG: %w", err) + if err := exportWebPSilent(img, filePath); err != nil { + return fmt.Errorf("failed to export WebP: %w", err) } scaleDivider := 2