noita-mapcap/bin/stitch/export-dzi.go
David Vogel b1a10870c1 Several changes
- Add compatibility for newest Noita beta
- Modify STREAMING_CHUNK_TARGET, GRID_MAX_UPDATES_PER_FRAME and GRID_MIN_UPDATES_PER_FRAME magic numbers for a more robust capturing process
- Add LimitGroup to util.go
- Add webp-level command line flag to define the webp compression level
- Rework progress bar to make it work in DZI export mode
- Refactor image exporter functions
- Use LimitGroup to make DZI export multithreaded
- Add BlendMethodFast which doesn't mix tile pixels
- Up Go version to 1.22
- Use Dadido3/go-libwebp for WebP encoding
2024-02-08 00:50:11 +01:00

41 lines
1.1 KiB
Go

// Copyright (c) 2023-2024 David Vogel
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
package main
import (
"fmt"
"os"
"path/filepath"
"strings"
"github.com/cheggaaa/pb/v3"
)
func exportDZIStitchedImage(stitchedImage *StitchedImage, outputPath string, bar *pb.ProgressBar, dziTileSize, dziOverlap int, webPLevel int) error {
descriptorPath := outputPath
extension := filepath.Ext(outputPath)
outputTilesPath := strings.TrimSuffix(outputPath, extension) + "_files"
dzi := NewDZI(stitchedImage, dziTileSize, dziOverlap)
// Create base directory of all DZI files.
if err := os.MkdirAll(outputTilesPath, 0755); err != nil {
return fmt.Errorf("failed to create output directory: %w", err)
}
// Export DZI descriptor.
if err := dzi.ExportDZIDescriptor(descriptorPath); err != nil {
return fmt.Errorf("failed to export DZI descriptor: %w", err)
}
// Export DZI tiles.
if err := dzi.ExportDZITiles(outputTilesPath, bar, webPLevel); err != nil {
return fmt.Errorf("failed to export DZI tiles: %w", err)
}
return nil
}