zone5 1.4.0 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -17
- package/dist/cli/index.js +9 -1
- package/dist/components/Zone5.svelte +1 -1
- package/dist/config.d.ts +3 -0
- package/dist/processor/config.d.ts +2 -0
- package/dist/processor/config.js +1 -0
- package/dist/processor/index.d.ts +2 -2
- package/dist/processor/index.js +7 -3
- package/dist/processor/variants.d.ts +2 -2
- package/dist/processor/variants.js +3 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -94,7 +94,23 @@ widths = [400, 800, 1200, 1600, 2400]
|
|
|
94
94
|
|
|
95
95
|
Zone5 supports three layout modes:
|
|
96
96
|
|
|
97
|
-
####
|
|
97
|
+
#### Justified Mode (Default)
|
|
98
|
+
|
|
99
|
+
Row-based layout (like Flickr/Google Photos). Each row fills the full width while preserving aspect ratios. Panoramic images (aspect ratio > 3) automatically get their own row.
|
|
100
|
+
|
|
101
|
+
```svelte
|
|
102
|
+
<Zone5 images={images} mode="justified" />
|
|
103
|
+
|
|
104
|
+
<!-- With custom row height and gap -->
|
|
105
|
+
<Zone5
|
|
106
|
+
images={images}
|
|
107
|
+
mode="justified"
|
|
108
|
+
targetRowHeight={250}
|
|
109
|
+
gap={12}
|
|
110
|
+
/>
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
#### Wall Mode
|
|
98
114
|
|
|
99
115
|
Fixed-height grid layout. Images are cropped to fill their containers.
|
|
100
116
|
|
|
@@ -117,22 +133,6 @@ Column-based masonry layout. Images are distributed across columns and maintain
|
|
|
117
133
|
/>
|
|
118
134
|
```
|
|
119
135
|
|
|
120
|
-
#### Justified Mode
|
|
121
|
-
|
|
122
|
-
Row-based layout (like Flickr/Google Photos). Each row fills the full width while preserving aspect ratios. Panoramic images (aspect ratio > 3) automatically get their own row.
|
|
123
|
-
|
|
124
|
-
```svelte
|
|
125
|
-
<Zone5 images={images} mode="justified" />
|
|
126
|
-
|
|
127
|
-
<!-- With custom row height and gap -->
|
|
128
|
-
<Zone5
|
|
129
|
-
images={images}
|
|
130
|
-
mode="justified"
|
|
131
|
-
targetRowHeight={250}
|
|
132
|
-
gap={12}
|
|
133
|
-
/>
|
|
134
|
-
```
|
|
135
|
-
|
|
136
136
|
### Setting Mode in Markdown
|
|
137
137
|
|
|
138
138
|
Use the `zone5mode` frontmatter property:
|
package/dist/cli/index.js
CHANGED
|
@@ -8198,7 +8198,15 @@ async function vh(t, i, a, n) {
|
|
|
8198
8198
|
}
|
|
8199
8199
|
}
|
|
8200
8200
|
async function wh(t, i) {
|
|
8201
|
-
const n =
|
|
8201
|
+
const n = `---
|
|
8202
|
+
# Zone5 Gallery Configuration
|
|
8203
|
+
# https://cwygoda.github.io/zone5/docs/reference/remark-plugin-api#frontmatter-options
|
|
8204
|
+
|
|
8205
|
+
# Gallery layout mode: "justified" (default) | "wall" | "waterfall"
|
|
8206
|
+
# zone5mode: justified
|
|
8207
|
+
---
|
|
8208
|
+
|
|
8209
|
+
# Photo Gallery
|
|
8202
8210
|
|
|
8203
8211
|
${i.map(({ relativePath: s }) => {
|
|
8204
8212
|
const l = Rt(s);
|
package/dist/config.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ declare const ConfigSchema: z.ZodObject<{
|
|
|
17
17
|
}>>;
|
|
18
18
|
resize_gamma: z.ZodOptional<z.ZodNumber>;
|
|
19
19
|
variants: z.ZodDefault<z.ZodArray<z.ZodNumber>>;
|
|
20
|
+
strip_gps: z.ZodDefault<z.ZodBoolean>;
|
|
20
21
|
}, z.core.$strip>>>;
|
|
21
22
|
gallery: z.ZodPrefault<z.ZodPipe<z.ZodPrefault<z.ZodObject<{
|
|
22
23
|
mode: z.ZodOptional<z.ZodEnum<{
|
|
@@ -55,6 +56,7 @@ export declare const load: (configDir?: string | undefined) => Promise<{
|
|
|
55
56
|
processor: {
|
|
56
57
|
resize_kernel: any;
|
|
57
58
|
variants: number[];
|
|
59
|
+
strip_gps: boolean;
|
|
58
60
|
resize_gamma?: number | undefined;
|
|
59
61
|
};
|
|
60
62
|
gallery: {
|
|
@@ -76,6 +78,7 @@ export declare const load: (configDir?: string | undefined) => Promise<{
|
|
|
76
78
|
processor: {
|
|
77
79
|
resize_kernel: any;
|
|
78
80
|
variants: number[];
|
|
81
|
+
strip_gps: boolean;
|
|
79
82
|
resize_gamma?: number | undefined;
|
|
80
83
|
};
|
|
81
84
|
gallery: {
|
|
@@ -5,6 +5,8 @@ export declare const ProcessorConfigSchema: z.ZodPrefault<z.ZodObject<{
|
|
|
5
5
|
}>>;
|
|
6
6
|
resize_gamma: z.ZodOptional<z.ZodNumber>;
|
|
7
7
|
variants: z.ZodDefault<z.ZodArray<z.ZodNumber>>;
|
|
8
|
+
strip_gps: z.ZodDefault<z.ZodBoolean>;
|
|
8
9
|
}, z.core.$strip>>;
|
|
9
10
|
export type ProcessorConfig = z.infer<typeof ProcessorConfigSchema>;
|
|
11
|
+
export type ProcessorConfigInput = z.input<typeof ProcessorConfigSchema>;
|
|
10
12
|
export declare const configHash: (config: ProcessorConfig) => string;
|
package/dist/processor/config.js
CHANGED
|
@@ -6,6 +6,7 @@ export const ProcessorConfigSchema = z
|
|
|
6
6
|
resize_kernel: z.enum(Object.values(sharp.kernel)).default(sharp.kernel.mks2021),
|
|
7
7
|
resize_gamma: z.number().min(1.0).max(3.0).optional(),
|
|
8
8
|
variants: z.array(z.number().int().min(1)).default([640, 768, 1280, 1920, 2560]),
|
|
9
|
+
strip_gps: z.boolean().default(false),
|
|
9
10
|
})
|
|
10
11
|
.prefault({});
|
|
11
12
|
export const configHash = (config) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { BaseConfigType } from '../config.js';
|
|
2
2
|
import { type DominantColor } from './color.js';
|
|
3
|
-
import { type
|
|
3
|
+
import { type ProcessorConfigInput } from './config.js';
|
|
4
4
|
import type { ExifItem } from './exif/exif.js';
|
|
5
5
|
import type { GeojsonPoint } from './exif/types.js';
|
|
6
6
|
export interface ItemFeature {
|
|
@@ -19,7 +19,7 @@ export interface ItemFeature {
|
|
|
19
19
|
}
|
|
20
20
|
declare const processor: (options: {
|
|
21
21
|
base: BaseConfigType;
|
|
22
|
-
processor:
|
|
22
|
+
processor: ProcessorConfigInput;
|
|
23
23
|
sourceFile: string;
|
|
24
24
|
clear?: boolean;
|
|
25
25
|
forceOverwrite?: boolean;
|
package/dist/processor/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import { join, parse, relative } from 'path';
|
|
|
4
4
|
import sharp from 'sharp';
|
|
5
5
|
import { generateBlurhash } from './blurhash.js';
|
|
6
6
|
import { getDominantColors } from './color.js';
|
|
7
|
-
import { configHash } from './config.js';
|
|
7
|
+
import { configHash, ProcessorConfigSchema } from './config.js';
|
|
8
8
|
import exifFromFilePath from './exif/index.js';
|
|
9
9
|
import { fileExists, sourceFileHash } from './file.js';
|
|
10
10
|
import { generateImageVariants } from './variants.js';
|
|
@@ -12,7 +12,9 @@ const tracer = trace.getTracer('zone5-processor');
|
|
|
12
12
|
const processor = async (options) => {
|
|
13
13
|
return tracer.startActiveSpan('zone5.processor', async (span) => {
|
|
14
14
|
try {
|
|
15
|
-
const { base, processor:
|
|
15
|
+
const { base, processor: processorInput, sourceFile, clear = false, forceOverwrite = false } = options;
|
|
16
|
+
// Parse config to apply defaults
|
|
17
|
+
const processorConfig = ProcessorConfigSchema.parse(processorInput);
|
|
16
18
|
const { name: fileBasename } = parse(sourceFile);
|
|
17
19
|
const sourceHash = sourceFileHash(base.root, sourceFile);
|
|
18
20
|
const procConfigHash = configHash(processorConfig);
|
|
@@ -35,9 +37,11 @@ const processor = async (options) => {
|
|
|
35
37
|
generateImageVariants({ sourceFile, processor: processorConfig, cacheDir, clear, forceOverwrite }),
|
|
36
38
|
sharp(sourceFile).metadata(),
|
|
37
39
|
]);
|
|
40
|
+
// Strip GPS data if configured (for privacy)
|
|
41
|
+
const geometry = processorConfig.strip_gps ? null : exifFeature.geometry;
|
|
38
42
|
const feature = {
|
|
39
43
|
type: 'Feature',
|
|
40
|
-
geometry
|
|
44
|
+
geometry,
|
|
41
45
|
id: sourceHash,
|
|
42
46
|
properties: {
|
|
43
47
|
...exifFeature.properties,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ProcessorConfigInput } from './config.js';
|
|
2
2
|
export interface GeneratedVariant {
|
|
3
3
|
width: number;
|
|
4
4
|
path: string;
|
|
5
5
|
}
|
|
6
6
|
export declare function generateImageVariants(options: {
|
|
7
|
-
processor:
|
|
7
|
+
processor: ProcessorConfigInput;
|
|
8
8
|
sourceFile: string;
|
|
9
9
|
cacheDir: string;
|
|
10
10
|
clear?: boolean;
|
|
@@ -2,6 +2,7 @@ import { SpanStatusCode, trace } from '@opentelemetry/api';
|
|
|
2
2
|
import { rm } from 'fs/promises';
|
|
3
3
|
import { join, parse } from 'path';
|
|
4
4
|
import sharp from 'sharp';
|
|
5
|
+
import { ProcessorConfigSchema } from './config.js';
|
|
5
6
|
import { ensureDirectoryExists, fileExists } from './file.js';
|
|
6
7
|
const tracer = trace.getTracer('zone5-processor-variants');
|
|
7
8
|
const addDebugText = async (img, width, height) => {
|
|
@@ -13,7 +14,8 @@ const addDebugText = async (img, width, height) => {
|
|
|
13
14
|
export async function generateImageVariants(options) {
|
|
14
15
|
return tracer.startActiveSpan('zone5.generateImageVariants', async (span) => {
|
|
15
16
|
try {
|
|
16
|
-
const { processor, sourceFile, cacheDir, clear = false, forceOverwrite = false } = options;
|
|
17
|
+
const { processor: processorInput, sourceFile, cacheDir, clear = false, forceOverwrite = false } = options;
|
|
18
|
+
const processor = ProcessorConfigSchema.parse(processorInput);
|
|
17
19
|
// Parse file path components
|
|
18
20
|
const { name: fileBasename, ext: fileExtension } = parse(sourceFile);
|
|
19
21
|
// Get source image metadata to check dimensions
|