png_conform 0.1.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.
- checksums.yaml +7 -0
- data/.rspec +3 -0
- data/.rubocop.yml +19 -0
- data/.rubocop_todo.yml +197 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/CONTRIBUTING.md +323 -0
- data/Gemfile +13 -0
- data/LICENSE +43 -0
- data/README.adoc +859 -0
- data/Rakefile +10 -0
- data/SECURITY.md +147 -0
- data/docs/ARCHITECTURE.adoc +681 -0
- data/docs/CHUNK_TYPES.adoc +450 -0
- data/docs/CLI_OPTIONS.adoc +913 -0
- data/docs/COMPATIBILITY.adoc +616 -0
- data/examples/README.adoc +398 -0
- data/examples/advanced_usage.rb +304 -0
- data/examples/basic_usage.rb +210 -0
- data/exe/png_conform +6 -0
- data/lib/png_conform/analyzers/comparison_analyzer.rb +230 -0
- data/lib/png_conform/analyzers/metrics_analyzer.rb +176 -0
- data/lib/png_conform/analyzers/optimization_analyzer.rb +190 -0
- data/lib/png_conform/analyzers/resolution_analyzer.rb +274 -0
- data/lib/png_conform/bindata/chunk_structure.rb +153 -0
- data/lib/png_conform/bindata/jng_file.rb +79 -0
- data/lib/png_conform/bindata/mng_file.rb +97 -0
- data/lib/png_conform/bindata/png_file.rb +162 -0
- data/lib/png_conform/cli.rb +116 -0
- data/lib/png_conform/commands/check_command.rb +323 -0
- data/lib/png_conform/commands/list_command.rb +67 -0
- data/lib/png_conform/models/chunk.rb +84 -0
- data/lib/png_conform/models/chunk_info.rb +71 -0
- data/lib/png_conform/models/compression_info.rb +49 -0
- data/lib/png_conform/models/decoded_chunk_data.rb +143 -0
- data/lib/png_conform/models/file_analysis.rb +181 -0
- data/lib/png_conform/models/file_info.rb +91 -0
- data/lib/png_conform/models/image_info.rb +52 -0
- data/lib/png_conform/models/validation_error.rb +89 -0
- data/lib/png_conform/models/validation_result.rb +137 -0
- data/lib/png_conform/readers/full_load_reader.rb +113 -0
- data/lib/png_conform/readers/streaming_reader.rb +180 -0
- data/lib/png_conform/reporters/base_reporter.rb +53 -0
- data/lib/png_conform/reporters/color_reporter.rb +65 -0
- data/lib/png_conform/reporters/json_reporter.rb +18 -0
- data/lib/png_conform/reporters/palette_reporter.rb +48 -0
- data/lib/png_conform/reporters/quiet_reporter.rb +18 -0
- data/lib/png_conform/reporters/reporter_factory.rb +108 -0
- data/lib/png_conform/reporters/summary_reporter.rb +65 -0
- data/lib/png_conform/reporters/text_reporter.rb +66 -0
- data/lib/png_conform/reporters/verbose_reporter.rb +87 -0
- data/lib/png_conform/reporters/very_verbose_reporter.rb +33 -0
- data/lib/png_conform/reporters/visual_elements.rb +66 -0
- data/lib/png_conform/reporters/yaml_reporter.rb +18 -0
- data/lib/png_conform/services/profile_manager.rb +242 -0
- data/lib/png_conform/services/validation_service.rb +457 -0
- data/lib/png_conform/services/zlib_validator.rb +270 -0
- data/lib/png_conform/validators/ancillary/bkgd_validator.rb +140 -0
- data/lib/png_conform/validators/ancillary/chrm_validator.rb +178 -0
- data/lib/png_conform/validators/ancillary/cicp_validator.rb +202 -0
- data/lib/png_conform/validators/ancillary/gama_validator.rb +105 -0
- data/lib/png_conform/validators/ancillary/hist_validator.rb +147 -0
- data/lib/png_conform/validators/ancillary/iccp_validator.rb +243 -0
- data/lib/png_conform/validators/ancillary/itxt_validator.rb +280 -0
- data/lib/png_conform/validators/ancillary/mdcv_validator.rb +201 -0
- data/lib/png_conform/validators/ancillary/offs_validator.rb +132 -0
- data/lib/png_conform/validators/ancillary/pcal_validator.rb +289 -0
- data/lib/png_conform/validators/ancillary/phys_validator.rb +107 -0
- data/lib/png_conform/validators/ancillary/sbit_validator.rb +176 -0
- data/lib/png_conform/validators/ancillary/scal_validator.rb +180 -0
- data/lib/png_conform/validators/ancillary/splt_validator.rb +223 -0
- data/lib/png_conform/validators/ancillary/srgb_validator.rb +117 -0
- data/lib/png_conform/validators/ancillary/ster_validator.rb +111 -0
- data/lib/png_conform/validators/ancillary/text_validator.rb +129 -0
- data/lib/png_conform/validators/ancillary/time_validator.rb +132 -0
- data/lib/png_conform/validators/ancillary/trns_validator.rb +154 -0
- data/lib/png_conform/validators/ancillary/ztxt_validator.rb +173 -0
- data/lib/png_conform/validators/apng/actl_validator.rb +81 -0
- data/lib/png_conform/validators/apng/fctl_validator.rb +155 -0
- data/lib/png_conform/validators/apng/fdat_validator.rb +117 -0
- data/lib/png_conform/validators/base_validator.rb +241 -0
- data/lib/png_conform/validators/chunk_registry.rb +219 -0
- data/lib/png_conform/validators/critical/idat_validator.rb +77 -0
- data/lib/png_conform/validators/critical/iend_validator.rb +68 -0
- data/lib/png_conform/validators/critical/ihdr_validator.rb +160 -0
- data/lib/png_conform/validators/critical/plte_validator.rb +120 -0
- data/lib/png_conform/validators/jng/jdat_validator.rb +66 -0
- data/lib/png_conform/validators/jng/jhdr_validator.rb +116 -0
- data/lib/png_conform/validators/jng/jsep_validator.rb +66 -0
- data/lib/png_conform/validators/mng/back_validator.rb +87 -0
- data/lib/png_conform/validators/mng/clip_validator.rb +65 -0
- data/lib/png_conform/validators/mng/clon_validator.rb +45 -0
- data/lib/png_conform/validators/mng/defi_validator.rb +104 -0
- data/lib/png_conform/validators/mng/dhdr_validator.rb +104 -0
- data/lib/png_conform/validators/mng/disc_validator.rb +44 -0
- data/lib/png_conform/validators/mng/endl_validator.rb +65 -0
- data/lib/png_conform/validators/mng/fram_validator.rb +91 -0
- data/lib/png_conform/validators/mng/loop_validator.rb +75 -0
- data/lib/png_conform/validators/mng/mend_validator.rb +31 -0
- data/lib/png_conform/validators/mng/mhdr_validator.rb +69 -0
- data/lib/png_conform/validators/mng/move_validator.rb +61 -0
- data/lib/png_conform/validators/mng/save_validator.rb +39 -0
- data/lib/png_conform/validators/mng/seek_validator.rb +42 -0
- data/lib/png_conform/validators/mng/show_validator.rb +52 -0
- data/lib/png_conform/validators/mng/term_validator.rb +84 -0
- data/lib/png_conform/version.rb +5 -0
- data/lib/png_conform.rb +101 -0
- data/png_conform.gemspec +43 -0
- metadata +201 -0
|
@@ -0,0 +1,913 @@
|
|
|
1
|
+
= CLI, API, and Environment Options Reference
|
|
2
|
+
|
|
3
|
+
== Purpose
|
|
4
|
+
|
|
5
|
+
Comprehensive reference for all command-line interface options, Ruby API methods, and environment variables in MECE (Mutually Exclusive, Collectively Exhaustive) organization.
|
|
6
|
+
|
|
7
|
+
== Command-Line Interface (CLI)
|
|
8
|
+
|
|
9
|
+
=== General
|
|
10
|
+
|
|
11
|
+
All CLI commands follow the pattern:
|
|
12
|
+
[source,shell]
|
|
13
|
+
----
|
|
14
|
+
png_conform COMMAND [OPTIONS] [ARGUMENTS]
|
|
15
|
+
----
|
|
16
|
+
|
|
17
|
+
=== Commands
|
|
18
|
+
|
|
19
|
+
==== General
|
|
20
|
+
|
|
21
|
+
Commands are mutually exclusive - use exactly one per invocation.
|
|
22
|
+
|
|
23
|
+
==== check
|
|
24
|
+
|
|
25
|
+
**Purpose**: Validate PNG/MNG/JNG files
|
|
26
|
+
|
|
27
|
+
**Syntax**:
|
|
28
|
+
[source,shell]
|
|
29
|
+
----
|
|
30
|
+
png_conform check [OPTIONS] FILE [FILE...]
|
|
31
|
+
----
|
|
32
|
+
|
|
33
|
+
**Arguments**:
|
|
34
|
+
|
|
35
|
+
* `FILE`: Path to PNG/MNG/JNG file(s) to validate (required, multiple allowed)
|
|
36
|
+
|
|
37
|
+
==== list
|
|
38
|
+
|
|
39
|
+
**Purpose**: Display available validation profiles
|
|
40
|
+
|
|
41
|
+
**Syntax**:
|
|
42
|
+
[source,shell]
|
|
43
|
+
----
|
|
44
|
+
png_conform list
|
|
45
|
+
----
|
|
46
|
+
|
|
47
|
+
**Arguments**: None
|
|
48
|
+
|
|
49
|
+
==== version
|
|
50
|
+
|
|
51
|
+
**Purpose**: Display version information
|
|
52
|
+
|
|
53
|
+
**Syntax**:
|
|
54
|
+
[source,shell]
|
|
55
|
+
----
|
|
56
|
+
png_conform version
|
|
57
|
+
----
|
|
58
|
+
|
|
59
|
+
**Arguments**: None
|
|
60
|
+
|
|
61
|
+
=== Options
|
|
62
|
+
|
|
63
|
+
==== General
|
|
64
|
+
|
|
65
|
+
Options are organized by category in MECE structure.
|
|
66
|
+
|
|
67
|
+
==== Output Format Options
|
|
68
|
+
|
|
69
|
+
Mutually exclusive - select exactly one:
|
|
70
|
+
|
|
71
|
+
`-f, --format FORMAT`::
|
|
72
|
+
Output format selection
|
|
73
|
+
+
|
|
74
|
+
**Values**: `text` (default), `yaml`, `json`
|
|
75
|
+
+
|
|
76
|
+
**Default**: `text`
|
|
77
|
+
+
|
|
78
|
+
**Example**:
|
|
79
|
+
[source,shell]
|
|
80
|
+
----
|
|
81
|
+
png_conform check --format yaml image.png
|
|
82
|
+
png_conform check --format json image.png
|
|
83
|
+
----
|
|
84
|
+
|
|
85
|
+
==== Verbosity Options
|
|
86
|
+
|
|
87
|
+
Mutually exclusive - select at most one:
|
|
88
|
+
|
|
89
|
+
`-v, --verbose`::
|
|
90
|
+
Display chunk-level information
|
|
91
|
+
+
|
|
92
|
+
**Example**:
|
|
93
|
+
[source,shell]
|
|
94
|
+
----
|
|
95
|
+
png_conform check --verbose image.png
|
|
96
|
+
# Shows: chunk list with offsets and sizes
|
|
97
|
+
----
|
|
98
|
+
|
|
99
|
+
`-vv, --very-verbose`::
|
|
100
|
+
Display detailed chunk data including filters
|
|
101
|
+
+
|
|
102
|
+
**Example**:
|
|
103
|
+
[source,shell]
|
|
104
|
+
----
|
|
105
|
+
png_conform check --very-verbose image.png
|
|
106
|
+
# Shows: chunks + filter details
|
|
107
|
+
----
|
|
108
|
+
|
|
109
|
+
`-q, --quiet`::
|
|
110
|
+
Suppress all output except errors
|
|
111
|
+
+
|
|
112
|
+
**Example**:
|
|
113
|
+
[source,shell]
|
|
114
|
+
----
|
|
115
|
+
png_conform check --quiet images/*.png
|
|
116
|
+
# Only shows files with errors
|
|
117
|
+
----
|
|
118
|
+
|
|
119
|
+
==== Display Enhancement Options
|
|
120
|
+
|
|
121
|
+
Can be combined:
|
|
122
|
+
|
|
123
|
+
`--no-color`::
|
|
124
|
+
Disable colored output
|
|
125
|
+
+
|
|
126
|
+
**Default**: Colors enabled
|
|
127
|
+
+
|
|
128
|
+
**Example**:
|
|
129
|
+
[source,shell]
|
|
130
|
+
----
|
|
131
|
+
png_conform check --no-color image.png
|
|
132
|
+
----
|
|
133
|
+
|
|
134
|
+
`-p, --palette`::
|
|
135
|
+
Display palette, transparency, and histogram chunks
|
|
136
|
+
+
|
|
137
|
+
**Example**:
|
|
138
|
+
[source,shell]
|
|
139
|
+
----
|
|
140
|
+
png_conform check --palette indexed.png
|
|
141
|
+
----
|
|
142
|
+
|
|
143
|
+
`-t, --text`::
|
|
144
|
+
Display text chunk contents
|
|
145
|
+
+
|
|
146
|
+
**Example**:
|
|
147
|
+
[source,shell]
|
|
148
|
+
----
|
|
149
|
+
png_conform check --text image.png
|
|
150
|
+
# Shows: tEXt, zTXt, iTXt chunks
|
|
151
|
+
----
|
|
152
|
+
|
|
153
|
+
`-7, --seven-bit`::
|
|
154
|
+
Escape characters >= 128 for 7-bit terminals
|
|
155
|
+
+
|
|
156
|
+
**Used with**: `-t` or `-p`
|
|
157
|
+
|
|
158
|
+
==== Validation Profile Options
|
|
159
|
+
|
|
160
|
+
Mutually exclusive - select at most one:
|
|
161
|
+
|
|
162
|
+
`--profile PROFILE`::
|
|
163
|
+
Use specific validation profile
|
|
164
|
+
+
|
|
165
|
+
**Values**: `minimal`, `web`, `print`, `archive`, `strict`, `default`
|
|
166
|
+
+
|
|
167
|
+
**Example**:
|
|
168
|
+
[source,shell]
|
|
169
|
+
----
|
|
170
|
+
png_conform check --profile web image.png
|
|
171
|
+
png_conform check --profile print document.png
|
|
172
|
+
----
|
|
173
|
+
|
|
174
|
+
`--strict`::
|
|
175
|
+
Shortcut for `--profile strict`
|
|
176
|
+
+
|
|
177
|
+
**Equivalent to**: `--profile strict`
|
|
178
|
+
|
|
179
|
+
==== Analysis Options
|
|
180
|
+
|
|
181
|
+
Can be combined:
|
|
182
|
+
|
|
183
|
+
`--resolution`::
|
|
184
|
+
Show resolution and Retina analysis
|
|
185
|
+
+
|
|
186
|
+
**Shows**: @1x/@2x/@3x calculations, iOS/Android suggestions, DPI info
|
|
187
|
+
+
|
|
188
|
+
**Default**: Enabled for text output
|
|
189
|
+
+
|
|
190
|
+
**Example**:
|
|
191
|
+
[source,shell]
|
|
192
|
+
----
|
|
193
|
+
png_conform check --resolution icon@2x.png
|
|
194
|
+
----
|
|
195
|
+
|
|
196
|
+
`--optimize`::
|
|
197
|
+
Show file size optimization suggestions
|
|
198
|
+
+
|
|
199
|
+
**Shows**: Chunk removal, bit depth reduction, palette conversion opportunities
|
|
200
|
+
+
|
|
201
|
+
**Default**: Enabled for text output
|
|
202
|
+
+
|
|
203
|
+
**Example**:
|
|
204
|
+
[source,shell]
|
|
205
|
+
----
|
|
206
|
+
png_conform check --optimize large-photo.png
|
|
207
|
+
----
|
|
208
|
+
|
|
209
|
+
`--metrics`::
|
|
210
|
+
Display comprehensive metrics
|
|
211
|
+
+
|
|
212
|
+
**Shows**: File, image, chunk, validation, compression, and quality metrics
|
|
213
|
+
+
|
|
214
|
+
**Formats**: Text, JSON, YAML
|
|
215
|
+
+
|
|
216
|
+
**Example**:
|
|
217
|
+
[source,shell]
|
|
218
|
+
----
|
|
219
|
+
png_conform check --metrics --format json image.png
|
|
220
|
+
----
|
|
221
|
+
|
|
222
|
+
`--mobile-ready`::
|
|
223
|
+
Check mobile and Retina readiness
|
|
224
|
+
+
|
|
225
|
+
**Shows**: Overall readiness, retina densities, screen coverage, load time
|
|
226
|
+
+
|
|
227
|
+
**Example**:
|
|
228
|
+
[source,shell]
|
|
229
|
+
----
|
|
230
|
+
png_conform check --mobile-ready app-icon.png
|
|
231
|
+
----
|
|
232
|
+
|
|
233
|
+
==== Option Combinations
|
|
234
|
+
|
|
235
|
+
===== Common Combinations
|
|
236
|
+
|
|
237
|
+
**Quiet mode** (errors only):
|
|
238
|
+
[source,shell]
|
|
239
|
+
----
|
|
240
|
+
png_conform check -q images/*.png
|
|
241
|
+
----
|
|
242
|
+
|
|
243
|
+
**Comprehensive analysis**:
|
|
244
|
+
[source,shell]
|
|
245
|
+
----
|
|
246
|
+
png_conform check --verbose --metrics --resolution image.png
|
|
247
|
+
----
|
|
248
|
+
|
|
249
|
+
**CI/CD mode**:
|
|
250
|
+
[source,shell]
|
|
251
|
+
----
|
|
252
|
+
png_conform check --format json --metrics images/*.png > report.json
|
|
253
|
+
----
|
|
254
|
+
|
|
255
|
+
**Mobile development**:
|
|
256
|
+
[source,shell]
|
|
257
|
+
----
|
|
258
|
+
png_conform check --mobile-ready icons/*.png
|
|
259
|
+
----
|
|
260
|
+
|
|
261
|
+
===== Invalid Combinations
|
|
262
|
+
|
|
263
|
+
**Conflicting verbosity**:
|
|
264
|
+
[source,shell]
|
|
265
|
+
----
|
|
266
|
+
png_conform check -q -v image.png
|
|
267
|
+
# Warning: --quiet and --verbose are mutually exclusive, using --quiet
|
|
268
|
+
----
|
|
269
|
+
|
|
270
|
+
**Conflicting formats**:
|
|
271
|
+
[source,shell]
|
|
272
|
+
----
|
|
273
|
+
png_conform check --format yaml --format json image.png
|
|
274
|
+
# Error: Only one format allowed
|
|
275
|
+
----
|
|
276
|
+
|
|
277
|
+
== Ruby API
|
|
278
|
+
|
|
279
|
+
=== General
|
|
280
|
+
|
|
281
|
+
Object-oriented API for programmatic integration.
|
|
282
|
+
|
|
283
|
+
=== Validation Service
|
|
284
|
+
|
|
285
|
+
==== General
|
|
286
|
+
|
|
287
|
+
Main entry point for validation.
|
|
288
|
+
|
|
289
|
+
==== Basic Usage
|
|
290
|
+
|
|
291
|
+
[source,ruby]
|
|
292
|
+
----
|
|
293
|
+
require "png_conform"
|
|
294
|
+
|
|
295
|
+
# Validate a file
|
|
296
|
+
service = PngConform::Services::ValidationService.new
|
|
297
|
+
result = service.validate_file("image.png")
|
|
298
|
+
|
|
299
|
+
# Check if valid
|
|
300
|
+
if result.valid?
|
|
301
|
+
puts "File is valid"
|
|
302
|
+
else
|
|
303
|
+
puts "Errors: #{result.error_count}"
|
|
304
|
+
end
|
|
305
|
+
----
|
|
306
|
+
|
|
307
|
+
==== Methods
|
|
308
|
+
|
|
309
|
+
`ValidationService.validate_file(filepath)`::
|
|
310
|
+
Class method for quick validation
|
|
311
|
+
+
|
|
312
|
+
**Parameters**: `filepath` (String)
|
|
313
|
+
+
|
|
314
|
+
**Returns**: FileAnalysis object
|
|
315
|
+
+
|
|
316
|
+
**Example**:
|
|
317
|
+
[source,ruby]
|
|
318
|
+
----
|
|
319
|
+
result = PngConform::Services::ValidationService.validate_file("image.png")
|
|
320
|
+
----
|
|
321
|
+
|
|
322
|
+
`ValidationService#validate`::
|
|
323
|
+
Instance method for validation with reader
|
|
324
|
+
+
|
|
325
|
+
**Returns**: FileAnalysis object
|
|
326
|
+
+
|
|
327
|
+
**Example**:
|
|
328
|
+
[source,ruby]
|
|
329
|
+
----
|
|
330
|
+
reader = PngConform::Readers::StreamingReader.new("image.png")
|
|
331
|
+
service = PngConform::Services::ValidationService.new(reader)
|
|
332
|
+
result = service.validate
|
|
333
|
+
----
|
|
334
|
+
|
|
335
|
+
=== FileAnalysis Object
|
|
336
|
+
|
|
337
|
+
==== General
|
|
338
|
+
|
|
339
|
+
Complete analysis result with validation, image info, and analyzer results.
|
|
340
|
+
|
|
341
|
+
==== Attributes
|
|
342
|
+
|
|
343
|
+
`file_path`::
|
|
344
|
+
Path to analyzed file (String)
|
|
345
|
+
|
|
346
|
+
`file_size`::
|
|
347
|
+
File size in bytes (Integer)
|
|
348
|
+
|
|
349
|
+
`file_type`::
|
|
350
|
+
File type: "PNG", "MNG", "JNG" (String)
|
|
351
|
+
|
|
352
|
+
`validation_result`::
|
|
353
|
+
Detailed validation results (ValidationResult object)
|
|
354
|
+
|
|
355
|
+
`image_info`::
|
|
356
|
+
Image dimensions and properties (ImageInfo object)
|
|
357
|
+
|
|
358
|
+
`compression_info`::
|
|
359
|
+
Compression statistics (CompressionInfo object)
|
|
360
|
+
|
|
361
|
+
`resolution_analysis`::
|
|
362
|
+
Resolution and Retina analysis (Hash)
|
|
363
|
+
|
|
364
|
+
`optimization_analysis`::
|
|
365
|
+
File size optimization suggestions (Hash)
|
|
366
|
+
|
|
367
|
+
`metrics`::
|
|
368
|
+
Comprehensive metrics for CI/CD (Hash)
|
|
369
|
+
|
|
370
|
+
==== Methods
|
|
371
|
+
|
|
372
|
+
`valid?`::
|
|
373
|
+
Check if file passed validation (Boolean)
|
|
374
|
+
|
|
375
|
+
`error_count`::
|
|
376
|
+
Number of errors found (Integer)
|
|
377
|
+
|
|
378
|
+
`warning_count`::
|
|
379
|
+
Number of warnings found (Integer)
|
|
380
|
+
|
|
381
|
+
`chunks`::
|
|
382
|
+
Array of chunks in file (Array<Chunk>)
|
|
383
|
+
|
|
384
|
+
`to_h`::
|
|
385
|
+
Convert to hash for serialization (Hash)
|
|
386
|
+
|
|
387
|
+
=== Profile Manager
|
|
388
|
+
|
|
389
|
+
==== General
|
|
390
|
+
|
|
391
|
+
Manages validation profiles.
|
|
392
|
+
|
|
393
|
+
==== Methods
|
|
394
|
+
|
|
395
|
+
`ProfileManager.profile_exists?(name)`::
|
|
396
|
+
Check if profile exists
|
|
397
|
+
+
|
|
398
|
+
**Parameters**: `name` (String or Symbol)
|
|
399
|
+
+
|
|
400
|
+
**Returns**: Boolean
|
|
401
|
+
|
|
402
|
+
`ProfileManager.available_profiles`::
|
|
403
|
+
List all available profiles
|
|
404
|
+
+
|
|
405
|
+
**Returns**: Array<String>
|
|
406
|
+
|
|
407
|
+
`ProfileManager#load_profile(name)`::
|
|
408
|
+
Load specific profile
|
|
409
|
+
+
|
|
410
|
+
**Parameters**: `name` (String)
|
|
411
|
+
+
|
|
412
|
+
**Returns**: Profile object
|
|
413
|
+
|
|
414
|
+
=== Analyzers
|
|
415
|
+
|
|
416
|
+
==== General
|
|
417
|
+
|
|
418
|
+
Analyzers compute specific analysis from validation results.
|
|
419
|
+
|
|
420
|
+
==== ResolutionAnalyzer
|
|
421
|
+
|
|
422
|
+
[source,ruby]
|
|
423
|
+
----
|
|
424
|
+
analyzer = PngConform::Analyzers::ResolutionAnalyzer.new(file_analysis)
|
|
425
|
+
analysis = analyzer.analyze
|
|
426
|
+
|
|
427
|
+
# Access Retina info
|
|
428
|
+
retina = analysis[:retina]
|
|
429
|
+
puts "At @2x: #{retina[:at_2x][:dimensions_pt]}"
|
|
430
|
+
puts "iOS: #{retina[:ios_asset_catalog].join(', ')}"
|
|
431
|
+
----
|
|
432
|
+
|
|
433
|
+
==== OptimizationAnalyzer
|
|
434
|
+
|
|
435
|
+
[source,ruby]
|
|
436
|
+
----
|
|
437
|
+
analyzer = PngConform::Analyzers::OptimizationAnalyzer.new(file_analysis)
|
|
438
|
+
analysis = analyzer.analyze
|
|
439
|
+
|
|
440
|
+
# Get suggestions
|
|
441
|
+
analysis[:suggestions].each do |suggestion|
|
|
442
|
+
puts "[#{suggestion[:priority]}] #{suggestion[:description]}"
|
|
443
|
+
puts "Savings: #{suggestion[:savings_bytes]} bytes"
|
|
444
|
+
end
|
|
445
|
+
----
|
|
446
|
+
|
|
447
|
+
==== MetricsAnalyzer
|
|
448
|
+
|
|
449
|
+
[source,ruby]
|
|
450
|
+
----
|
|
451
|
+
analyzer = PngConform::Analyzers::MetricsAnalyzer.new(file_analysis)
|
|
452
|
+
metrics = analyzer.analyze
|
|
453
|
+
|
|
454
|
+
# Access metrics
|
|
455
|
+
puts "File: #{metrics[:file][:size_kb]} KB"
|
|
456
|
+
puts "Image: #{metrics[:image][:dimensions]}"
|
|
457
|
+
puts "Chunks: #{metrics[:chunks][:total_count]}"
|
|
458
|
+
----
|
|
459
|
+
|
|
460
|
+
==== ComparisonAnalyzer
|
|
461
|
+
|
|
462
|
+
[source,ruby]
|
|
463
|
+
----
|
|
464
|
+
result1 = service.validate_file("before.png")
|
|
465
|
+
result2 = service.validate_file("after.png")
|
|
466
|
+
|
|
467
|
+
analyzer = PngConform::Analyzers::ComparisonAnalyzer.new(result1, result2)
|
|
468
|
+
comparison = analyzer.analyze
|
|
469
|
+
|
|
470
|
+
# Check differences
|
|
471
|
+
puts comparison[:files][:size_change]
|
|
472
|
+
puts "Chunks added: #{comparison[:chunks][:added].join(', ')}"
|
|
473
|
+
----
|
|
474
|
+
|
|
475
|
+
== Environment Variables
|
|
476
|
+
|
|
477
|
+
=== General
|
|
478
|
+
|
|
479
|
+
Environment variables for runtime configuration.
|
|
480
|
+
|
|
481
|
+
=== Available Variables
|
|
482
|
+
|
|
483
|
+
`PNGCONFORM_DEFAULT_PROFILE`::
|
|
484
|
+
Set default validation profile
|
|
485
|
+
+
|
|
486
|
+
**Values**: Profile names (`minimal`, `web`, `print`, `archive`, `strict`, `default`)
|
|
487
|
+
+
|
|
488
|
+
**Default**: `default`
|
|
489
|
+
+
|
|
490
|
+
**Example**:
|
|
491
|
+
[source,shell]
|
|
492
|
+
----
|
|
493
|
+
export PNGCONFORM_DEFAULT_PROFILE=web
|
|
494
|
+
png_conform check image.png # Uses web profile
|
|
495
|
+
----
|
|
496
|
+
|
|
497
|
+
`PNGCONFORM_COLOR`::
|
|
498
|
+
Enable/disable colored output
|
|
499
|
+
+
|
|
500
|
+
**Values**: `true`, `false`, `1`, `0`
|
|
501
|
+
+
|
|
502
|
+
**Default**: `true`
|
|
503
|
+
+
|
|
504
|
+
**Example**:
|
|
505
|
+
[source,shell]
|
|
506
|
+
----
|
|
507
|
+
export PNGCONFORM_COLOR=false
|
|
508
|
+
png_conform check image.png # No colors
|
|
509
|
+
----
|
|
510
|
+
|
|
511
|
+
`PNGCONFORM_FORMAT`::
|
|
512
|
+
Set default output format
|
|
513
|
+
+
|
|
514
|
+
**Values**: `text`, `yaml`, `json`
|
|
515
|
+
+
|
|
516
|
+
**Default**: `text`
|
|
517
|
+
+
|
|
518
|
+
**Example**:
|
|
519
|
+
[source,shell]
|
|
520
|
+
----
|
|
521
|
+
export PNGCONFORM_FORMAT=json
|
|
522
|
+
png_conform check image.png # JSON output
|
|
523
|
+
----
|
|
524
|
+
|
|
525
|
+
== Option Precedence
|
|
526
|
+
|
|
527
|
+
=== General
|
|
528
|
+
|
|
529
|
+
When the same option is specified multiple ways, precedence is:
|
|
530
|
+
|
|
531
|
+
. Command-line flags (highest priority)
|
|
532
|
+
. Environment variables
|
|
533
|
+
. Configuration files (if implemented)
|
|
534
|
+
. Built-in defaults (lowest priority)
|
|
535
|
+
|
|
536
|
+
=== Examples
|
|
537
|
+
|
|
538
|
+
[example]
|
|
539
|
+
====
|
|
540
|
+
[source,shell]
|
|
541
|
+
----
|
|
542
|
+
# Environment variable
|
|
543
|
+
export PNGCONFORM_FORMAT=yaml
|
|
544
|
+
|
|
545
|
+
# Command-line flag overrides
|
|
546
|
+
png_conform check --format json image.png
|
|
547
|
+
# Output: JSON (flag wins)
|
|
548
|
+
----
|
|
549
|
+
====
|
|
550
|
+
|
|
551
|
+
== Exit Codes
|
|
552
|
+
|
|
553
|
+
=== General
|
|
554
|
+
|
|
555
|
+
PngConform uses standard Unix exit codes.
|
|
556
|
+
|
|
557
|
+
=== Exit Code Values
|
|
558
|
+
|
|
559
|
+
`0`::
|
|
560
|
+
Success - all files valid
|
|
561
|
+
|
|
562
|
+
`1`::
|
|
563
|
+
Failure - one or more files invalid or error occurred
|
|
564
|
+
|
|
565
|
+
`2`::
|
|
566
|
+
Usage error - invalid command or options
|
|
567
|
+
|
|
568
|
+
=== Examples
|
|
569
|
+
|
|
570
|
+
[example]
|
|
571
|
+
====
|
|
572
|
+
[source,shell]
|
|
573
|
+
----
|
|
574
|
+
#!/bin/bash
|
|
575
|
+
png_conform check image.png
|
|
576
|
+
if [ $? -eq 0 ]; then
|
|
577
|
+
echo "Valid"
|
|
578
|
+
else
|
|
579
|
+
echo "Invalid or error"
|
|
580
|
+
fi
|
|
581
|
+
----
|
|
582
|
+
====
|
|
583
|
+
|
|
584
|
+
== Configuration
|
|
585
|
+
|
|
586
|
+
=== Validation Profiles
|
|
587
|
+
|
|
588
|
+
==== General
|
|
589
|
+
|
|
590
|
+
Profiles define validation requirements for different use cases.
|
|
591
|
+
|
|
592
|
+
==== Available Profiles
|
|
593
|
+
|
|
594
|
+
`minimal`::
|
|
595
|
+
Basic PNG structure validation
|
|
596
|
+
+
|
|
597
|
+
**Required**: IHDR, IDAT, IEND
|
|
598
|
+
+
|
|
599
|
+
**Use Case**: Minimal valid PNG checking
|
|
600
|
+
|
|
601
|
+
`web`::
|
|
602
|
+
Browser-optimized validation
|
|
603
|
+
+
|
|
604
|
+
**Required**: IHDR, IDAT, IEND
|
|
605
|
+
+
|
|
606
|
+
**Optional**: gAMA, sRGB, pHYs, tEXt, zTXt, iTXt, tIME, bKGD, tRNS, PLTE
|
|
607
|
+
+
|
|
608
|
+
**Prohibited**: iCCP, cHRM, sBIT
|
|
609
|
+
+
|
|
610
|
+
**Use Case**: Web-ready images
|
|
611
|
+
|
|
612
|
+
`print`::
|
|
613
|
+
Print-quality validation
|
|
614
|
+
+
|
|
615
|
+
**Required**: IHDR, IDAT, IEND, pHYs
|
|
616
|
+
+
|
|
617
|
+
**Optional**: gAMA, sRGB, cHRM, iCCP, sBIT, tEXt, zTXt, iTXt, tIME, bKGD, tRNS, PLTE
|
|
618
|
+
+
|
|
619
|
+
**Use Case**: Print-ready images with physical dimensions
|
|
620
|
+
|
|
621
|
+
`archive`::
|
|
622
|
+
Long-term preservation
|
|
623
|
+
+
|
|
624
|
+
**Required**: IHDR, IDAT, IEND, tIME
|
|
625
|
+
+
|
|
626
|
+
**Optional**: All standard chunks
|
|
627
|
+
+
|
|
628
|
+
**Use Case**: Archival storage with complete metadata
|
|
629
|
+
|
|
630
|
+
`strict`::
|
|
631
|
+
Full specification compliance
|
|
632
|
+
+
|
|
633
|
+
**Required**: IHDR, IDAT, IEND
|
|
634
|
+
+
|
|
635
|
+
**Optional**: All standard PNG chunks
|
|
636
|
+
+
|
|
637
|
+
**Prohibited**: Unknown chunks
|
|
638
|
+
+
|
|
639
|
+
**Use Case**: Strict spec compliance
|
|
640
|
+
|
|
641
|
+
`default`::
|
|
642
|
+
Permissive validation
|
|
643
|
+
+
|
|
644
|
+
**Required**: IHDR, IDAT, IEND
|
|
645
|
+
+
|
|
646
|
+
**Optional**: All chunks
|
|
647
|
+
+
|
|
648
|
+
**Prohibited**: None
|
|
649
|
+
+
|
|
650
|
+
**Use Case**: General validation
|
|
651
|
+
|
|
652
|
+
== Complete Option Matrix
|
|
653
|
+
|
|
654
|
+
=== Validation Options
|
|
655
|
+
|
|
656
|
+
[cols="2,3,2,3",options="header"]
|
|
657
|
+
|===
|
|
658
|
+
|Category |Option |Type |Purpose
|
|
659
|
+
|
|
660
|
+
|Format
|
|
661
|
+
|`--format FORMAT`
|
|
662
|
+
|Choice
|
|
663
|
+
|Output format (text/yaml/json)
|
|
664
|
+
|
|
665
|
+
|Verbosity
|
|
666
|
+
|`-v, --verbose`
|
|
667
|
+
|Flag
|
|
668
|
+
|Show chunk details
|
|
669
|
+
|
|
670
|
+
|Verbosity
|
|
671
|
+
|`-vv, --very-verbose`
|
|
672
|
+
|Flag
|
|
673
|
+
|Show filter details
|
|
674
|
+
|
|
675
|
+
|Verbosity
|
|
676
|
+
|`-q, --quiet`
|
|
677
|
+
|Flag
|
|
678
|
+
|Errors only
|
|
679
|
+
|
|
680
|
+
|Display
|
|
681
|
+
|`--no-color`
|
|
682
|
+
|Flag
|
|
683
|
+
|Disable colors
|
|
684
|
+
|
|
685
|
+
|Display
|
|
686
|
+
|`-p, --palette`
|
|
687
|
+
|Flag
|
|
688
|
+
|Show palette
|
|
689
|
+
|
|
690
|
+
|Display
|
|
691
|
+
|`-t, --text`
|
|
692
|
+
|Flag
|
|
693
|
+
|Show text chunks
|
|
694
|
+
|
|
695
|
+
|Display
|
|
696
|
+
|`-7, --seven-bit`
|
|
697
|
+
|Flag
|
|
698
|
+
|Escape high chars
|
|
699
|
+
|
|
700
|
+
|Profile
|
|
701
|
+
|`--profile PROFILE`
|
|
702
|
+
|Choice
|
|
703
|
+
|Validation profile
|
|
704
|
+
|
|
705
|
+
|Profile
|
|
706
|
+
|`--strict`
|
|
707
|
+
|Flag
|
|
708
|
+
|Strict mode
|
|
709
|
+
|
|
710
|
+
|Analysis
|
|
711
|
+
|`--resolution`
|
|
712
|
+
|Flag
|
|
713
|
+
|Retina analysis
|
|
714
|
+
|
|
715
|
+
|Analysis
|
|
716
|
+
|`--optimize`
|
|
717
|
+
|Flag
|
|
718
|
+
|Optimization tips
|
|
719
|
+
|
|
720
|
+
|Analysis
|
|
721
|
+
|`--metrics`
|
|
722
|
+
|Flag
|
|
723
|
+
|Comprehensive metrics
|
|
724
|
+
|
|
725
|
+
|Analysis
|
|
726
|
+
|`--mobile-ready`
|
|
727
|
+
|Flag
|
|
728
|
+
|Mobile readiness check
|
|
729
|
+
|===
|
|
730
|
+
|
|
731
|
+
=== Option Categories (MECE)
|
|
732
|
+
|
|
733
|
+
==== Output Control
|
|
734
|
+
|
|
735
|
+
Determines what gets output and how:
|
|
736
|
+
|
|
737
|
+
* Format selection (`--format`)
|
|
738
|
+
* Verbosity level (`-v`, `-vv`, `-q`)
|
|
739
|
+
* Color control (`--no-color`)
|
|
740
|
+
|
|
741
|
+
==== Content Selection
|
|
742
|
+
|
|
743
|
+
Determines which content to display:
|
|
744
|
+
|
|
745
|
+
* Palette display (`-p`)
|
|
746
|
+
* Text chunks (`-t`)
|
|
747
|
+
* Character encoding (`-7`)
|
|
748
|
+
|
|
749
|
+
==== Validation Mode
|
|
750
|
+
|
|
751
|
+
Determines validation strictness:
|
|
752
|
+
|
|
753
|
+
* Profile selection (`--profile`)
|
|
754
|
+
* Strict mode (`--strict`)
|
|
755
|
+
|
|
756
|
+
==== Analysis Features
|
|
757
|
+
|
|
758
|
+
Determines which analysis to perform:
|
|
759
|
+
|
|
760
|
+
* Resolution analysis (`--resolution`)
|
|
761
|
+
* Optimization analysis (`--optimize`)
|
|
762
|
+
* Metrics generation (`--metrics`)
|
|
763
|
+
* Mobile readiness (`--mobile-ready`)
|
|
764
|
+
|
|
765
|
+
== Ruby API Reference
|
|
766
|
+
|
|
767
|
+
=== Modules and Classes
|
|
768
|
+
|
|
769
|
+
==== Module Hierarchy
|
|
770
|
+
|
|
771
|
+
[source]
|
|
772
|
+
----
|
|
773
|
+
PngConform
|
|
774
|
+
├── Services
|
|
775
|
+
│ ├── ValidationService
|
|
776
|
+
│ └── ProfileManager
|
|
777
|
+
├── Analyzers
|
|
778
|
+
│ ├── ResolutionAnalyzer
|
|
779
|
+
│ ├── OptimizationAnalyzer
|
|
780
|
+
│ ├── MetricsAnalyzer
|
|
781
|
+
│ └── ComparisonAnalyzer
|
|
782
|
+
├── Models
|
|
783
|
+
│ ├── FileAnalysis
|
|
784
|
+
│ ├── ValidationResult
|
|
785
|
+
│ ├── ImageInfo
|
|
786
|
+
│ └── ...
|
|
787
|
+
└── Reporters
|
|
788
|
+
├── YamlReporter
|
|
789
|
+
├── JsonReporter
|
|
790
|
+
└── ...
|
|
791
|
+
----
|
|
792
|
+
|
|
793
|
+
=== Complete API Methods (MECE)
|
|
794
|
+
|
|
795
|
+
==== Validation Operations
|
|
796
|
+
|
|
797
|
+
`ValidationService.validate_file(path)`::
|
|
798
|
+
Validate file by path
|
|
799
|
+
+
|
|
800
|
+
**Returns**: FileAnalysis
|
|
801
|
+
|
|
802
|
+
`ValidationService#validate`::
|
|
803
|
+
Validate with custom reader
|
|
804
|
+
+
|
|
805
|
+
**Returns**: FileAnalysis
|
|
806
|
+
|
|
807
|
+
==== Profile Operations
|
|
808
|
+
|
|
809
|
+
`ProfileManager.profile_exists?(name)`::
|
|
810
|
+
Check profile existence
|
|
811
|
+
+
|
|
812
|
+
**Returns**: Boolean
|
|
813
|
+
|
|
814
|
+
`ProfileManager.available_profiles`::
|
|
815
|
+
List all profiles
|
|
816
|
+
+
|
|
817
|
+
**Returns**: Array<String>
|
|
818
|
+
|
|
819
|
+
`ProfileManager#load_profile(name)`::
|
|
820
|
+
Load specific profile
|
|
821
|
+
+
|
|
822
|
+
**Returns**: Profile
|
|
823
|
+
|
|
824
|
+
==== Analysis Operations
|
|
825
|
+
|
|
826
|
+
`ResolutionAnalyzer#analyze`::
|
|
827
|
+
Compute resolution analysis
|
|
828
|
+
+
|
|
829
|
+
**Returns**: Hash
|
|
830
|
+
|
|
831
|
+
`OptimizationAnalyzer#analyze`::
|
|
832
|
+
Compute optimization suggestions
|
|
833
|
+
+
|
|
834
|
+
**Returns**: Hash
|
|
835
|
+
|
|
836
|
+
`MetricsAnalyzer#analyze`::
|
|
837
|
+
Compute comprehensive metrics
|
|
838
|
+
+
|
|
839
|
+
**Returns**: Hash
|
|
840
|
+
|
|
841
|
+
`ComparisonAnalyzer#analyze`::
|
|
842
|
+
Compare two files
|
|
843
|
+
+
|
|
844
|
+
**Returns**: Hash
|
|
845
|
+
|
|
846
|
+
==== Reporting Operations
|
|
847
|
+
|
|
848
|
+
`Reporter#report(file_analysis)`::
|
|
849
|
+
Generate formatted output
|
|
850
|
+
+
|
|
851
|
+
**Input**: FileAnalysis
|
|
852
|
+
+
|
|
853
|
+
**Output**: Formatted string
|
|
854
|
+
|
|
855
|
+
== Usage Patterns
|
|
856
|
+
|
|
857
|
+
=== By Use Case
|
|
858
|
+
|
|
859
|
+
==== Web Development
|
|
860
|
+
|
|
861
|
+
[source,shell]
|
|
862
|
+
----
|
|
863
|
+
# Validation
|
|
864
|
+
png_conform check --profile web --optimize images/*.png
|
|
865
|
+
|
|
866
|
+
# Get metrics for CI
|
|
867
|
+
png_conform check --format json --metrics images/*.png > metrics.json
|
|
868
|
+
----
|
|
869
|
+
|
|
870
|
+
==== Mobile Development
|
|
871
|
+
|
|
872
|
+
[source,shell]
|
|
873
|
+
----
|
|
874
|
+
# Check Retina readiness
|
|
875
|
+
png_conform check --mobile-ready icons/*.png
|
|
876
|
+
|
|
877
|
+
# Verify icon sizes
|
|
878
|
+
png_conform check --resolution icon@2x.png
|
|
879
|
+
----
|
|
880
|
+
|
|
881
|
+
==== Quality Assurance
|
|
882
|
+
|
|
883
|
+
[source,shell]
|
|
884
|
+
----
|
|
885
|
+
# Comprehensive validation
|
|
886
|
+
png_conform check -vv --metrics test-images/*.png
|
|
887
|
+
|
|
888
|
+
# Compare before/after
|
|
889
|
+
png_conform check original.png
|
|
890
|
+
png_conform check optimized.png
|
|
891
|
+
----
|
|
892
|
+
|
|
893
|
+
==== Print Production
|
|
894
|
+
|
|
895
|
+
[source,shell]
|
|
896
|
+
----
|
|
897
|
+
# Check print readiness
|
|
898
|
+
png_conform check --profile print --resolution document.png
|
|
899
|
+
----
|
|
900
|
+
|
|
901
|
+
==== Archival
|
|
902
|
+
|
|
903
|
+
[source,shell]
|
|
904
|
+
----
|
|
905
|
+
# Verify complete metadata
|
|
906
|
+
png_conform check --profile archive -t archive/*.png
|
|
907
|
+
----
|
|
908
|
+
|
|
909
|
+
== See Also
|
|
910
|
+
|
|
911
|
+
* link:../README.adoc[PngConform Documentation]
|
|
912
|
+
* link:CHUNK_TYPES.adoc[Chunk Types Reference]
|
|
913
|
+
* link:COMPATIBILITY.adoc[Tool Compatibility]
|