@yafh/image-map
Advanced tools
| //#region src/protocol.d.ts | ||
| type TileFormat = 'png' | 'jpg' | 'jpeg' | 'webp'; | ||
| type Origin = 'topLeft' | 'center'; | ||
| /** Resize filter used for downscaling between zoom levels. */ | ||
| type ResizeFilter = 'lanczos3' | 'catmullRom' | 'mitchell' | 'hamming' | 'bilinear' | 'box' | 'gaussian'; | ||
| /** Options for downscale sharpening. */ | ||
| interface DownscaleSharpenOptions { | ||
| /** Whether downscale sharpening is enabled. */ | ||
| enabled?: boolean; | ||
| /** Gaussian blur sigma for unsharp mask. */ | ||
| sigma?: number; | ||
| /** Unsharp mask amount multiplier. */ | ||
| amount?: number; | ||
| /** Threshold for minimal brightness change that will be sharpened. */ | ||
| threshold?: number; | ||
| } | ||
| interface GenerateOptions { | ||
| /** Whether to auto-orient input image pixels using EXIF orientation metadata. */ | ||
| autoOrient: boolean; | ||
| /** Resize filter for building lower zoom levels. */ | ||
| resizeFilter: ResizeFilter; | ||
| /** Downscale sharpening configuration. */ | ||
| downscaleSharpen: Required<DownscaleSharpenOptions>; | ||
| /** Tile size in pixels. */ | ||
| tileSize: number; | ||
| /** Output formats. */ | ||
| formats: TileFormat[]; | ||
| /** Origin position. */ | ||
| origin: Origin; | ||
| /** Minimum zoom level. */ | ||
| minZoom: number; | ||
| /** Maximum zoom level. */ | ||
| maxZoom: number; | ||
| } | ||
| interface GenerateResult { | ||
| /** Total number of tiles generated. */ | ||
| tilesGenerated: number; | ||
| /** Output directory path. */ | ||
| outputDir: string; | ||
| } | ||
| /** Resize by percentage of original size. */ | ||
| interface ResizeModePercentage { | ||
| type: 'percentage'; | ||
| /** Percentage value (e.g., 50 means 50% of original size). */ | ||
| value: number; | ||
| } | ||
| /** Resize by specifying the long edge in pixels. */ | ||
| interface ResizeModeLongEdge { | ||
| type: 'longEdge'; | ||
| /** Target long edge size in pixels. */ | ||
| pixels: number; | ||
| } | ||
| /** Resize by specifying both width and height (fit within, keep aspect ratio). */ | ||
| interface ResizeModeFit { | ||
| type: 'fit'; | ||
| /** Maximum width in pixels. */ | ||
| width: number; | ||
| /** Maximum height in pixels. */ | ||
| height: number; | ||
| } | ||
| /** Resize mode specification. */ | ||
| type ResizeMode = ResizeModePercentage | ResizeModeLongEdge | ResizeModeFit; | ||
| /** Options for resizing an image (without tiling). */ | ||
| interface ResizeImageOptions { | ||
| /** The resize mode specifying how to calculate output dimensions. */ | ||
| mode: ResizeMode; | ||
| /** Output format for the resized image. */ | ||
| format: TileFormat; | ||
| /** Whether to auto-orient input image pixels using EXIF orientation metadata. */ | ||
| autoOrient: boolean; | ||
| /** Resize filter for downscaling. */ | ||
| resizeFilter: ResizeFilter; | ||
| /** Sharpening configuration for downscaling. */ | ||
| sharpen: Required<DownscaleSharpenOptions>; | ||
| } | ||
| /** Result payload for a completed resize request. */ | ||
| interface ResizeResult { | ||
| /** Output file path. */ | ||
| outputPath: string; | ||
| /** Input image width after EXIF auto-orientation (if enabled). */ | ||
| originalWidth: number; | ||
| /** Input image height after EXIF auto-orientation (if enabled). */ | ||
| originalHeight: number; | ||
| /** Resized image width. */ | ||
| width: number; | ||
| /** Resized image height. */ | ||
| height: number; | ||
| } | ||
| interface GenerateRequestMessage { | ||
| /** Message type. */ | ||
| type: 'generate'; | ||
| /** Request id for correlating responses. */ | ||
| id: string; | ||
| /** Input image path. */ | ||
| input: string; | ||
| /** Output directory path. */ | ||
| output: string; | ||
| /** Generation options. */ | ||
| options: GenerateOptions; | ||
| } | ||
| interface ResizeRequestMessage { | ||
| /** Message type. */ | ||
| type: 'resize'; | ||
| /** Request id for correlating responses. */ | ||
| id: string; | ||
| /** Input image path. */ | ||
| input: string; | ||
| /** Output file path. */ | ||
| output: string; | ||
| /** Resize options. */ | ||
| options: ResizeImageOptions; | ||
| } | ||
| type RequestMessage = GenerateRequestMessage | ResizeRequestMessage; | ||
| interface ProgressResponseMessage { | ||
| /** Message type. */ | ||
| type: 'progress'; | ||
| /** Request id for correlating responses. */ | ||
| id: string; | ||
| /** Current progress value. */ | ||
| current: number; | ||
| /** Total progress value. */ | ||
| total: number; | ||
| /** Human readable message. */ | ||
| message: string; | ||
| } | ||
| interface CompleteResponseMessage { | ||
| /** Message type. */ | ||
| type: 'complete'; | ||
| /** Request id for correlating responses. */ | ||
| id: string; | ||
| /** Generation result payload. */ | ||
| result: GenerateResult; | ||
| } | ||
| interface ResizeCompleteResponseMessage { | ||
| /** Message type. */ | ||
| type: 'resizeComplete'; | ||
| /** Request id for correlating responses. */ | ||
| id: string; | ||
| /** Resize result payload. */ | ||
| result: ResizeResult; | ||
| } | ||
| interface ErrorResponseMessage { | ||
| /** Message type. */ | ||
| type: 'error'; | ||
| /** Request id for correlating responses. */ | ||
| id: string; | ||
| /** Error message. */ | ||
| error: string; | ||
| } | ||
| type ResponseMessage = ProgressResponseMessage | CompleteResponseMessage | ResizeCompleteResponseMessage | ErrorResponseMessage; | ||
| //#endregion | ||
| export { ResizeRequestMessage as _, GenerateRequestMessage as a, TileFormat as b, ProgressResponseMessage as c, ResizeFilter as d, ResizeImageOptions as f, ResizeModePercentage as g, ResizeModeLongEdge as h, GenerateOptions as i, RequestMessage as l, ResizeModeFit as m, DownscaleSharpenOptions as n, GenerateResult as o, ResizeMode as p, ErrorResponseMessage as r, Origin as s, CompleteResponseMessage as t, ResizeCompleteResponseMessage as u, ResizeResult as v, ResponseMessage as y }; |
+6
-0
@@ -25,2 +25,3 @@ import { t as ImageMap } from "./src-CRFV3_1p.mjs"; | ||
| const maxZoom = getNumberArg(args, "--max-zoom", 0); | ||
| const autoOrient = getBooleanArg(args, "--auto-orient", true); | ||
| const resizeFilter = getStringArg(args, "--resize-filter"); | ||
@@ -41,2 +42,3 @@ const downscaleSharpen = { | ||
| maxZoom, | ||
| autoOrient, | ||
| resizeFilter, | ||
@@ -57,2 +59,3 @@ downscaleSharpen, | ||
| const format = getStringArg(args, "--format") ?? "webp"; | ||
| const autoOrient = getBooleanArg(args, "--auto-orient", true); | ||
| const resizeFilter = getStringArg(args, "--resize-filter"); | ||
@@ -70,2 +73,3 @@ const sharpen = { | ||
| format, | ||
| autoOrient, | ||
| resizeFilter, | ||
@@ -173,2 +177,3 @@ sharpen, | ||
| " --max-zoom <n> Maximum zoom level (default: 0)", | ||
| " --auto-orient <bool> Auto-orient by EXIF metadata (default: true)", | ||
| " --resize-filter <f> One of: lanczos3 | catmullRom | mitchell | hamming | bilinear | box | gaussian (default: catmullRom)", | ||
@@ -191,2 +196,3 @@ " --downscale-sharpen <bool> Enable downscale sharpen (default: true)", | ||
| " --format <fmt> One of: png | jpg | jpeg | webp (default: webp)", | ||
| " --auto-orient <bool> Auto-orient by EXIF metadata (default: true)", | ||
| " --resize-filter <f> One of: lanczos3 | catmullRom | mitchell | hamming | bilinear | box | gaussian (default: catmullRom)", | ||
@@ -193,0 +199,0 @@ " --sharpen <bool> Enable sharpening (default: true)", |
+5
-1
@@ -1,2 +0,2 @@ | ||
| import { _ as ResizeRequestMessage, a as GenerateRequestMessage, b as TileFormat, c as ProgressResponseMessage, d as ResizeFilter, f as ResizeImageOptions, g as ResizeModePercentage, h as ResizeModeLongEdge, i as GenerateOptions, l as RequestMessage, m as ResizeModeFit, n as DownscaleSharpenOptions, o as GenerateResult, p as ResizeMode, r as ErrorResponseMessage, s as Origin, t as CompleteResponseMessage, u as ResizeCompleteResponseMessage, v as ResizeResult, y as ResponseMessage } from "./protocol-DsP6EbtC.mjs"; | ||
| import { _ as ResizeRequestMessage, a as GenerateRequestMessage, b as TileFormat, c as ProgressResponseMessage, d as ResizeFilter, f as ResizeImageOptions, g as ResizeModePercentage, h as ResizeModeLongEdge, i as GenerateOptions, l as RequestMessage, m as ResizeModeFit, n as DownscaleSharpenOptions, o as GenerateResult, p as ResizeMode, r as ErrorResponseMessage, s as Origin, t as CompleteResponseMessage, u as ResizeCompleteResponseMessage, v as ResizeResult, y as ResponseMessage } from "./protocol-DGZ6zXbr.mjs"; | ||
@@ -27,2 +27,4 @@ //#region src/pool.d.ts | ||
| maxZoom?: number; | ||
| /** Whether to auto-orient input image pixels using EXIF orientation metadata. */ | ||
| autoOrient?: boolean; | ||
| /** Progress callback. */ | ||
@@ -43,2 +45,4 @@ onProgress?: (current: number, total: number, message: string) => void; | ||
| format?: TileFormat; | ||
| /** Whether to auto-orient input image pixels using EXIF orientation metadata. */ | ||
| autoOrient?: boolean; | ||
| /** Resize filter for downscaling. */ | ||
@@ -45,0 +49,0 @@ resizeFilter?: ResizeFilter; |
@@ -1,2 +0,2 @@ | ||
| import { b as TileFormat, d as ResizeFilter, n as DownscaleSharpenOptions, o as GenerateResult, p as ResizeMode, s as Origin, v as ResizeResult } from "./protocol-DsP6EbtC.mjs"; | ||
| import { b as TileFormat, d as ResizeFilter, n as DownscaleSharpenOptions, o as GenerateResult, p as ResizeMode, s as Origin, v as ResizeResult } from "./protocol-DGZ6zXbr.mjs"; | ||
| import { MessagePort } from "node:worker_threads"; | ||
@@ -30,2 +30,4 @@ | ||
| maxZoom?: number; | ||
| /** Whether to auto-orient input image pixels using EXIF orientation metadata. */ | ||
| autoOrient?: boolean; | ||
| } | ||
@@ -46,2 +48,4 @@ /** | ||
| format?: TileFormat; | ||
| /** Whether to auto-orient input image pixels using EXIF orientation metadata. */ | ||
| autoOrient?: boolean; | ||
| /** Resize filter for downscaling. */ | ||
@@ -48,0 +52,0 @@ resizeFilter?: ResizeFilter; |
+12
-0
@@ -240,2 +240,3 @@ import { createRequire } from "node:module"; | ||
| const maxZoom = params.maxZoom ?? 0; | ||
| const autoOrient = normalizeAutoOrient(params.autoOrient); | ||
| const resizeFilter = normalizeResizeFilter(params.resizeFilter); | ||
@@ -248,2 +249,3 @@ const downscaleSharpen = normalizeDownscaleSharpen(params.downscaleSharpen); | ||
| return { | ||
| autoOrient, | ||
| resizeFilter, | ||
@@ -259,2 +261,10 @@ downscaleSharpen, | ||
| /** | ||
| * Normalize and validate auto-orient option. | ||
| */ | ||
| function normalizeAutoOrient(value) { | ||
| if (value == null) return true; | ||
| if (typeof value !== "boolean") throw new Error("autoOrient must be a boolean"); | ||
| return value; | ||
| } | ||
| /** | ||
| * Normalize and validate downscale sharpening options. | ||
@@ -319,2 +329,3 @@ */ | ||
| const format = normalizeFormat(params.format); | ||
| const autoOrient = normalizeAutoOrient(params.autoOrient); | ||
| const resizeFilter = normalizeResizeFilter(params.resizeFilter); | ||
@@ -334,2 +345,3 @@ const sharpen = normalizeDownscaleSharpen(params.sharpen); | ||
| format, | ||
| autoOrient, | ||
| resizeFilter, | ||
@@ -336,0 +348,0 @@ sharpen |
+6
-6
| { | ||
| "name": "@yafh/image-map", | ||
| "type": "module", | ||
| "version": "1.1.1", | ||
| "version": "1.1.2", | ||
| "description": "Image tile generator (SDK + CLI)", | ||
@@ -42,7 +42,7 @@ "author": "YanAndFish", | ||
| "optionalDependencies": { | ||
| "@yafh/image-map-darwin-arm64": "1.1.1", | ||
| "@yafh/image-map-linux-arm64": "1.1.1", | ||
| "@yafh/image-map-win32-arm64": "1.1.1", | ||
| "@yafh/image-map-win32-x64": "1.1.1", | ||
| "@yafh/image-map-linux-x64": "1.1.1" | ||
| "@yafh/image-map-darwin-arm64": "1.1.2", | ||
| "@yafh/image-map-linux-arm64": "1.1.2", | ||
| "@yafh/image-map-linux-x64": "1.1.2", | ||
| "@yafh/image-map-win32-x64": "1.1.2", | ||
| "@yafh/image-map-win32-arm64": "1.1.2" | ||
| }, | ||
@@ -49,0 +49,0 @@ "devDependencies": { |
+5
-0
@@ -17,2 +17,4 @@ # @yafh/image-map | ||
| 默认会根据 EXIF 方向元数据自动校准输入图像方向,输出像素方向已校准。 | ||
| 常用选项: | ||
@@ -25,2 +27,3 @@ | ||
| - `--max-zoom <n>`:最大缩放级别,默认 `0`。 | ||
| - `--auto-orient <bool>`:是否按 EXIF 自动校准方向,默认 `true`。 | ||
| - `-h, --help`:显示帮助。 | ||
@@ -41,2 +44,4 @@ | ||
| maxZoom: 4, | ||
| // 默认 true:按 EXIF 自动校准输入方向 | ||
| autoOrient: true, | ||
| }) | ||
@@ -43,0 +48,0 @@ |
| //#region src/protocol.d.ts | ||
| type TileFormat = 'png' | 'jpg' | 'jpeg' | 'webp'; | ||
| type Origin = 'topLeft' | 'center'; | ||
| /** Resize filter used for downscaling between zoom levels. */ | ||
| type ResizeFilter = 'lanczos3' | 'catmullRom' | 'mitchell' | 'hamming' | 'bilinear' | 'box' | 'gaussian'; | ||
| /** Options for downscale sharpening. */ | ||
| interface DownscaleSharpenOptions { | ||
| /** Whether downscale sharpening is enabled. */ | ||
| enabled?: boolean; | ||
| /** Gaussian blur sigma for unsharp mask. */ | ||
| sigma?: number; | ||
| /** Unsharp mask amount multiplier. */ | ||
| amount?: number; | ||
| /** Threshold for minimal brightness change that will be sharpened. */ | ||
| threshold?: number; | ||
| } | ||
| interface GenerateOptions { | ||
| /** Resize filter for building lower zoom levels. */ | ||
| resizeFilter: ResizeFilter; | ||
| /** Downscale sharpening configuration. */ | ||
| downscaleSharpen: Required<DownscaleSharpenOptions>; | ||
| /** Tile size in pixels. */ | ||
| tileSize: number; | ||
| /** Output formats. */ | ||
| formats: TileFormat[]; | ||
| /** Origin position. */ | ||
| origin: Origin; | ||
| /** Minimum zoom level. */ | ||
| minZoom: number; | ||
| /** Maximum zoom level. */ | ||
| maxZoom: number; | ||
| } | ||
| interface GenerateResult { | ||
| /** Total number of tiles generated. */ | ||
| tilesGenerated: number; | ||
| /** Output directory path. */ | ||
| outputDir: string; | ||
| } | ||
| /** Resize by percentage of original size. */ | ||
| interface ResizeModePercentage { | ||
| type: 'percentage'; | ||
| /** Percentage value (e.g., 50 means 50% of original size). */ | ||
| value: number; | ||
| } | ||
| /** Resize by specifying the long edge in pixels. */ | ||
| interface ResizeModeLongEdge { | ||
| type: 'longEdge'; | ||
| /** Target long edge size in pixels. */ | ||
| pixels: number; | ||
| } | ||
| /** Resize by specifying both width and height (fit within, keep aspect ratio). */ | ||
| interface ResizeModeFit { | ||
| type: 'fit'; | ||
| /** Maximum width in pixels. */ | ||
| width: number; | ||
| /** Maximum height in pixels. */ | ||
| height: number; | ||
| } | ||
| /** Resize mode specification. */ | ||
| type ResizeMode = ResizeModePercentage | ResizeModeLongEdge | ResizeModeFit; | ||
| /** Options for resizing an image (without tiling). */ | ||
| interface ResizeImageOptions { | ||
| /** The resize mode specifying how to calculate output dimensions. */ | ||
| mode: ResizeMode; | ||
| /** Output format for the resized image. */ | ||
| format: TileFormat; | ||
| /** Resize filter for downscaling. */ | ||
| resizeFilter: ResizeFilter; | ||
| /** Sharpening configuration for downscaling. */ | ||
| sharpen: Required<DownscaleSharpenOptions>; | ||
| } | ||
| /** Result payload for a completed resize request. */ | ||
| interface ResizeResult { | ||
| /** Output file path. */ | ||
| outputPath: string; | ||
| /** Original image width. */ | ||
| originalWidth: number; | ||
| /** Original image height. */ | ||
| originalHeight: number; | ||
| /** Resized image width. */ | ||
| width: number; | ||
| /** Resized image height. */ | ||
| height: number; | ||
| } | ||
| interface GenerateRequestMessage { | ||
| /** Message type. */ | ||
| type: 'generate'; | ||
| /** Request id for correlating responses. */ | ||
| id: string; | ||
| /** Input image path. */ | ||
| input: string; | ||
| /** Output directory path. */ | ||
| output: string; | ||
| /** Generation options. */ | ||
| options: GenerateOptions; | ||
| } | ||
| interface ResizeRequestMessage { | ||
| /** Message type. */ | ||
| type: 'resize'; | ||
| /** Request id for correlating responses. */ | ||
| id: string; | ||
| /** Input image path. */ | ||
| input: string; | ||
| /** Output file path. */ | ||
| output: string; | ||
| /** Resize options. */ | ||
| options: ResizeImageOptions; | ||
| } | ||
| type RequestMessage = GenerateRequestMessage | ResizeRequestMessage; | ||
| interface ProgressResponseMessage { | ||
| /** Message type. */ | ||
| type: 'progress'; | ||
| /** Request id for correlating responses. */ | ||
| id: string; | ||
| /** Current progress value. */ | ||
| current: number; | ||
| /** Total progress value. */ | ||
| total: number; | ||
| /** Human readable message. */ | ||
| message: string; | ||
| } | ||
| interface CompleteResponseMessage { | ||
| /** Message type. */ | ||
| type: 'complete'; | ||
| /** Request id for correlating responses. */ | ||
| id: string; | ||
| /** Generation result payload. */ | ||
| result: GenerateResult; | ||
| } | ||
| interface ResizeCompleteResponseMessage { | ||
| /** Message type. */ | ||
| type: 'resizeComplete'; | ||
| /** Request id for correlating responses. */ | ||
| id: string; | ||
| /** Resize result payload. */ | ||
| result: ResizeResult; | ||
| } | ||
| interface ErrorResponseMessage { | ||
| /** Message type. */ | ||
| type: 'error'; | ||
| /** Request id for correlating responses. */ | ||
| id: string; | ||
| /** Error message. */ | ||
| error: string; | ||
| } | ||
| type ResponseMessage = ProgressResponseMessage | CompleteResponseMessage | ResizeCompleteResponseMessage | ErrorResponseMessage; | ||
| //#endregion | ||
| export { ResizeRequestMessage as _, GenerateRequestMessage as a, TileFormat as b, ProgressResponseMessage as c, ResizeFilter as d, ResizeImageOptions as f, ResizeModePercentage as g, ResizeModeLongEdge as h, GenerateOptions as i, RequestMessage as l, ResizeModeFit as m, DownscaleSharpenOptions as n, GenerateResult as o, ResizeMode as p, ErrorResponseMessage as r, Origin as s, CompleteResponseMessage as t, ResizeCompleteResponseMessage as u, ResizeResult as v, ResponseMessage as y }; |
37546
4.59%728
2.54%56
9.8%