Commit Graph
3201 Commits
Author SHA1 Message Date
Dylan M. TaylorandAndy Ching 046a7229af fix(docx): integrate VML fallbacks without breaking linked text-box stories (#1864)
* craft-docx: write Word 2010 shapes inside mc:AlternateContent with a VML fallback

A shape was written as a bare `wps:wsp` in `w:drawing`. Word 2007, and
Word 2000-2003 with the Office Compatibility Pack, don't know `wps` and
refuse the whole file. Word writes such shapes in `mc:AlternateContent`.

`write_shape` now guards the drawing with `mc:Choice Requires="wps"` and,
for rectangles, text boxes, rounded rectangles and ellipses, adds an
`mc:Fallback` with the shape as VML: size, position, z-order, wrapping,
fill, outline and the text box's text (copied from the choice's output,
so the story isn't written twice). Other kinds get no fallback; an old
reader skips that shape and still opens the file.

Refs storytold/wordcraft#6849

* craft-docx: guard a shape only when it gets a VML fallback; keep more in the fallback

A shape guarded by `mc:AlternateContent` with no fallback is skipped by
a reader that doesn't know `wps`, and dropped on that reader's next save:
worse than refusing the file. Such shapes are written bare again; only
shapes with a VML form are guarded.

The VML fallback also keeps the shape's own stacking order (a floating
object in its text box moved `self.z` on), its wrap distances, its hidden
flag and its text box's text direction.

* craft-docx: keep behind-text shapes' order in the VML fallback

A behind-text shape's fallback `z-index` was the negated `z`, which
reverses the order of overlapping behind-text shapes. It is now `z`
shifted below zero within signed 32-bit range, so a higher `z` still
stacks higher; other shapes' `z-index` is capped at `i32::MAX`.

* fix(docx): preserve linked text boxes without an incomplete VML fallback

---------

Co-authored-by: Andy Ching <53651198+andyching168@users.noreply.github.com>
2026-11-16 08:16:40 -05:00
FredApps dd345db898 image-codecs: read a raster's resolution from its headers (resolution_probe) (#1838)
* image-codecs: read a raster's resolution from its headers (resolution_probe)

file_resolution(bytes) gives the pixels per inch a JPEG, PNG, WebP, BMP or
classic TIFF records without decoding pixels. JPEG uses the decoder's marker
scan (Photoshop, XMP, EXIF, then JFIF), PNG reads pHYs as the decoder does and
falls back to eXIf, WebP its EXIF chunk, TIFF its IFD0 tags; BMP reads the
info header's pixels per metre. Values outside 1-100000 ppi count as none.

DesignCraft (crates/images/src/resolution.rs) and FigCraft
(crates/format/src/density.rs) each carry their own marker and chunk walkers
for this; they can switch to the shared probe.

Part of #778 and #785.

* image-codecs: resolution_probe reads only a whole nine-byte pHYs, and a zero one leaves eXIf

A pHYs chunk that declares any other length, or is cut off before its
CRC, records nothing, and its data is no longer read from the bytes
after it. A zero pixels-per-metre count records nothing either, as in the
decoder, so the eXIf resolution still answers.
2026-11-16 08:14:38 -05:00
FredApps af8981f596 craft-drawingml: chart legend entries and engineering-format rounding from DeckCraft (#792) (#1871) 2026-11-16 08:13:29 -05:00
FredApps becf2a0a55 svg: recognise rectangles, rounded rectangles and ellipses in scene paths (#778, #789) (#1869)
tree::primitive::recognize (and Path::primitive) returns the axis-aligned
basic shape a path draws: one closed contour whose points all lie on a
(rounded) rectangle's or ellipse's outline and that encloses its area. usvg
turns rect, circle and ellipse into paths; apps that edit them as shapes get
them back from the segments.
2026-11-16 08:07:44 -05:00
Dylan M. Taylor 1939018e7f fix: remove unused_workspace_dependencies lint (removed from rustc) (#1866) 2026-11-16 07:54:14 -05:00
FredApps 402dfe46ad raw: charge short lossy JPEG DNG strips their declared rows (craft-libs #778) (#1857) 2026-11-16 07:52:02 -05:00
Dylan M. TayloranddotCooCoo a62de6c7c3 exr: integrate mixed deep/flat decoding with regression coverage (#1853)
* EXR: decode a flat part of a file that also holds deep parts

decode_part refused every part of a file with any deep part, and
decode_display_part, which checked only the selected part, still failed
because the exr crate's image reader validates every header and refuses
deep ones before it reads a chunk.

Both now decide from the selected part's own header. When any part is
deep, the selected flat part is read chunk by chunk: the flat headers are
validated, every part's offset table is walked from the end of the
headers, and only the selected table's chunks are read. A chunk must start
past the last offset table and inside the file, carry the selected part's
number and hold a block no other chunk of the part holds; anything else is
Malformed. Files with only flat parts keep the crate's reader.

The file-size ratio check, which was skipped for every part when any part
was deep, now applies to the flat parts of such a file; deep parts are not
counted.

* EXR: a flat part beside a deep part needs a chunk for each of its blocks

The chunk reader for a flat part of a file that also holds deep parts
refused only a second chunk for the same block. A tiled part's chunk that
named a level the part does not have was skipped without decompressing,
so the tile it took the place of had no chunk and the part decoded with
that tile left at zero.

Each chunk now has to hold one of the part's own blocks, taken from the
header, that no other chunk holds; anything else is Malformed. Since a
part has as many chunks as blocks, every block then has a chunk.

The mixed-file tests also run with a tiled flat part, and a new test
names a missing level and a repeated tile.

* EXR: a scan-line chunk beside a deep part must start at its block's first line

The block index of a scan-line chunk is its y offset divided by the
lines a block holds, rounded toward zero. A chunk whose y was not the
first line of a block, or lay up to 15 lines above the data window of
a ZIP part, still named a block and was decoded into it. Such a chunk
is now Malformed.

* EXR: a block too large to address is LimitExceeded instead of a panic

The exr crate bounds a flat chunk by a block's pixels times the bytes a
pixel takes, an unchecked product, before it reads the chunk. A 1 x 1
part with five float channels in 10^9 x 10^9 tiles passed every size
limit, and decode_part and decode_display_part then panicked with an
overflow, for files of flat parts only and for mixed files alike.
read_meta now computes the product with checked arithmetic for each
flat part and returns LimitExceeded when it does not fit in a usize.

* EXR: a chunk beside a deep part must fit the rest of the file

The exr crate allocates a chunk's declared payload, up to the size of a
block, before it reads it. In a mixed file whose flat part has large
tiles, a chunk declaring i32::MAX bytes made a 2 GiB allocation from a
file of a few hundred bytes. read_flat_part_chunks now reads the
declared length first and returns Malformed when it is longer than the
bytes left in the file.

* test(exr): verify mixed-part ratio and display block budgets

* fix(exr): bound mixed-part payload and block bookkeeping allocations

* fix(exr): expose internal ordinal helpers to regression tests

---------

Co-authored-by: dotCooCoo <RobertLeeLW@gmail.com>
2026-11-16 07:47:06 -05:00
FredApps 8e03cd016d craft-pdf: content streams (parse, serialize, matrices) from PDFCraft (#1852)
Adds the content feature and cos::content: PDFCraft's crates/content, moved
here so other apps can read and write page content streams. The parser keeps
operator spans, skips and counts unreadable bytes, and keeps inline images
whole; tests move with it.

Refs #778
2026-11-16 07:30:09 -05:00
FredApps 083920ebd7 psd: keep a layer record's blocks before an overlong one (#1845) 2026-11-16 07:19:08 -05:00
FredApps a80c0f25f1 ps: add a write feature for PostScript tokens (#778, #790) (#1840)
* ps: add a write feature for PostScript tokens

Numbers, strings, matrices, path data and Flate, so apps can emit a
PostScript or EPS program without owning the token serializer. Path and
paint operators can use the Language Reference names or the one-letter
names a bound prolog defines. Container concerns stay in craft-eps.

Part of #778 and #790.

* ps: tighten write-feature number trimming and Flate bounds

- Require flate2 1.1.10 so inflate rejects an incomplete zlib stream.
- Trim trailing zeros only when the token has a decimal point, so
  places=0 keeps integer zeros at the 1e15 boundary.
- Use saturating_add when bounding inflate, so max = u64::MAX does not
  overflow.
2026-11-16 07:12:00 -05:00
FredApps ddbe78231b craft-video: pass the packet's Adobe APP14 transform to the MJPEG decoder (#1847)
mjpeg::Decoder called craft_jpeg::decode with no Adobe transform, so a
packet with numeric component ids and APP14 transform 0 (RGB as stored)
was converted as YCbCr and came out in the wrong colours. The decoder
now reads the transform with craft_jpeg::adobe_transform, as the JPEG
image readers do. A regression test injects APP14 transforms 0 and 1;
it fails without the fix.
2026-11-16 07:10:48 -05:00
FredApps 431f704478 svg: let SvgWriter name the encoding and write a DOCTYPE subset (#778, #789) (#1842)
* svg: let SvgWriter name the encoding and write a DOCTYPE subset

VectorCraft's SVG document wrapper needs a Latin-1 declaration and a
<!DOCTYPE svg [ <!ENTITY …> ]> internal subset, including a minified
form with no extra newlines. The existing declaration was UTF-8 only,
and craft-xml's doctype helper writes only <!DOCTYPE name>.

Part of #778 and #789.

* svg: expose SvgWriter::as_str for a second pass on open markup

A consumer that rewrites character references or hashes the document
around a metadata element needs the text of an unclosed root. finish()
would close it first.
2026-11-16 07:04:35 -05:00
FredApps 57f94d5283 Merge pull request #1834 from andyching168/docx/wps-shape-vml-fallback
craft-docx: write Word 2010 shapes inside mc:AlternateContent with a VML fallback
2026-11-16 13:00:13 +01:00
FredApps b836a71856 craft-svg: a paths feature, and CSS colours with their alpha (#1848)
The geometry reader (craft_svg::paths) is the only part of the crate that
needs vectorcraft-geom and vectorcraft-pathops, and the tree is the only part
that needs craft-image-codecs. Both are now optional: paths is a default
feature and tree turns it on, so existing users build the same crate, while
an app that only needs SVG text, guards, path data, colours and the writer can
turn default features off and take no app crates or image codecs.

parse_color_alpha is parse_color keeping the alpha of #rgba, #rrggbbaa and
the fourth value of rgb()/hsl(). parse_color now calls it and still drops it.

Refs #778, #789
2026-11-16 06:54:06 -05:00
Dylan M. Taylor e409e74333 fix(print): opt-in bounded discovery for larger CUPS fleets (#1734)
* fix(print): allow explicitly bounded fleet discovery

* print: frame fleet discovery fixture as an HTTP reply
2026-11-16 06:49:02 -05:00
FredApps 070005125f Add craft-sniff: name a file's format, media type and extension from its first bytes (#1841) 2026-11-16 06:38:32 -05:00
FredApps 44d83fa8f6 Merge pull request #1323 from keithcsqueensu/xlsb-sizes
craft-xlsx: read row heights, column widths and default sizes of a binary sheet
2026-11-16 12:18:18 +01:00
FredApps eafb50aff3 Merge pull request #1653 from storytold/codex/dng-opcode-interpreter
Parse DNG opcode parameters into typed values
2026-11-16 12:03:21 +01:00
FredApps 806fa9a5a0 Merge pull request #1648 from storytold/codex/dng-capture-info
Share CinemaDNG capture metadata parsing
2026-11-16 12:02:33 +01:00
Dylan M. Taylor 37124f86d7 feat: add craft-mcp-server (JSON-RPC 2.0 MCP protocol) (#1649)
* feat: add craft-mcp-server (JSON-RPC 2.0 MCP protocol)

Port from solidcraft: MCP server machinery any app may share,
independent of transport and tools.

- JSON-RPC 2.0 over stdio (newline-delimited)
- MCP lifecycle: initialize, initialized, ping, notifications
- Tools: register, list, call with schema validation
- Resources: register, list, get by URI or template
- Prompts: register, list, get with argument completion
- Content blocks: text, image (base64), progress tokens

No external dependencies beyond serde_json.
Follows craft-libs safety pattern: #![deny(clippy::unwrap_used, ...)]

* retrigger CI

* retrigger CI

* Record MCP server dependencies in workspace lockfile

* chore: update rustls-webpki 0.103.15→0.103.16 and zip 9.1.0→9.1.3
2026-11-16 06:02:29 -05:00
FredApps 5ff3dd85b8 Merge pull request #1647 from storytold/codex/dng-metadata
Share bounded DNG processing and camera metadata
2026-11-16 11:56:50 +01:00
Dylan M. Taylor 731c4f262a Merge pull request #1758 from dotCooCoo/fix/exr-deep-part-tables-end
craft-exr: deep chunk offsets start after every part's offset table
2026-11-16 05:46:49 -05:00
Dylan M. Taylor 8a83e9178d Merge pull request #1837 from ljkx/image-codecs-bmp-resolution
image-codecs: BMP keeps its resolution in the header's pixels per metre
2026-11-16 05:45:26 -05:00
FredApps 341020b2c1 Merge pull request #1757 from el-j/feat/video-mjpeg
craft-video: Motion JPEG decoder and encoder (mjpeg)
2026-11-16 11:18:40 +01:00
FredApps 9b87ff0a0e raw: dng_metadata checks the LinearizationTable count before reading its entries 2026-11-16 10:34:00 +01:00
FredApps 57288edafd Merge pull request #1693 from storytold/codex/edl-bounded-report
Support bounded EDL parse diagnostics
2026-11-16 10:33:09 +01:00
FredApps 6abb8cf77e Merge main into XLSB sizes, preserving shared styles and regression coverage 2026-11-16 10:20:21 +01:00
FredApps 5689c73d29 Merge pull request #1685 from storytold/codex/fcp7-bounded-report
Support bounded FCP7 diagnostics
2026-11-16 10:17:11 +01:00
FredApps a4e74a5290 Merge pull request #1645 from storytold/codex/shared-dng-opcode-envelope
raw: share bounded DNG opcode envelopes
2026-11-16 10:09:02 +01:00
FredApps 4b69e41374 Merge pull request #1646 from storytold/codex/shared-raw-exif
Share explicit raw EXIF and JPEG APP metadata helpers
2026-11-16 10:05:47 +01:00
ljkx 7adcc9a6c2 image-codecs: BMP keeps its resolution in the header's pixels per metre
A BMP stores its resolution in biXPelsPerMeter and biYPelsPerMeter
(BITMAPINFOHEADER and later). The image crate writes 0 there and nothing
read the fields, so a 300 ppi image saved as BMP reopened at 72 ppi and an
opened BMP's resolution was lost (storytold/photocraft#13630).

decode now reads the fields into Metadata::dpi, encode writes
Metadata::dpi into them whatever embed_metadata says, and
caps(Format::Bmp).dpi is true. encode_bmp_indexed_with_dpi is the palette
writer with a resolution; encode_bmp_indexed keeps its signature and output.
2026-11-16 10:05:03 +01:00
FredApps a5c59b3d7c Merge pull request #1644 from storytold/codex/shared-dng-raw
raw: share bounded DNG strip and tile decoding
2026-11-16 10:00:06 +01:00
FredApps 80fea1fcab Merge pull request #1832 from storytold/fix/exr-display-block-bound
fix(exr): bound the display decoder by its largest block, not the whole part
2026-11-16 09:42:09 +01:00
FredApps a53b894e08 Merge remote-tracking branch 'origin/codex/fcp7-bounded-report' into w1693 2026-11-16 08:54:47 +01:00
FredApps 52fe6cb6cb Merge remote-tracking branch 'origin/main' into w1685
# Conflicts:
#	crates/timeline/src/fcp7.rs
#	crates/timeline/tests/it/fcp7.rs
2026-11-16 08:54:28 +01:00
FredApps 7d08706a3d Merge pull request #1681 from storytold/codex/fcpxml-bounded-report
Support bounded FCPXML diagnostics
2026-11-16 08:53:32 +01:00
FredApps cd845444f6 Merge remote-tracking branch 'origin/codex/dng-capture-info' into w1653 2026-11-16 08:52:13 +01:00
FredApps d8a2de2224 Merge remote-tracking branch 'origin/codex/dng-metadata' into w1648 2026-11-16 08:52:09 +01:00
FredApps 2686ac1f95 Merge remote-tracking branch 'origin/codex/shared-dng-opcode-envelope' into w1647 2026-11-16 08:52:05 +01:00
FredApps 456e71da87 Merge remote-tracking branch 'origin/codex/shared-dng-raw' into w1645 2026-11-16 08:52:01 +01:00
FredApps 8a067d58d0 raw: dng_lines checks unpack sizes, budgets each chunk's real decode allocation, and allows subsampled lossy JPEG
- unpack: checked sample, row-bit and output products, capped at MAX_SAMPLES before allocating
- every chunk is charged what its decoder may allocate (lossless: coded rows + 1/8; lossy: the
  32-pixel MCU-padded tile) against the aggregate budget before decoding, the lossless decoder
  is held to that, and truncated capacity is released
- the lossy encoded-size floor allows 64 x spp samples per two-bit block (chroma subsampling)
2026-11-16 08:51:58 +01:00
Andy Ching 5033f10bf2 craft-docx: keep behind-text shapes' order in the VML fallback
A behind-text shape's fallback `z-index` was the negated `z`, which
reverses the order of overlapping behind-text shapes. It is now `z`
shifted below zero within signed 32-bit range, so a higher `z` still
stacks higher; other shapes' `z-index` is capped at `i32::MAX`.
2026-11-16 15:51:31 +08:00
FredApps b952ca0231 Merge pull request #1728 from storytold/codex/fbx-ordered-placements
Preserve FBX placement and polygon order
2026-11-16 08:44:23 +01:00
FredApps 33f35d74f8 exr: clamp the scan-line block bound to the part height
A part shorter than its compression's scan-line group (a one-row ZIP16 part) only decodes its
own rows, so the all-channel block bound is min(scan_lines_per_block, layer_h) rows.
2026-11-16 08:38:50 +01:00
FredApps cb111c2ea6 Merge pull request #1733 from storytold/codex/shared-paragraph-composer
Share paragraph-wide line composition
2026-11-16 08:37:53 +01:00
FredApps 0153109e34 Merge pull request #1670 from storytold/codex/avif-coverage-features
Enable AVIF codec tests in coverage
2026-11-16 08:37:43 +01:00
FredApps 250fc97fa8 raw: opcode_params reads areas as the shared opcodes::Area and clamps them (Area::clamp); document how it differs from the typed opcodes model 2026-11-16 08:36:26 +01:00
FredApps 0e4b33fdf0 Merge remote-tracking branch 'origin/codex/dng-capture-info' into w1653 2026-11-16 08:35:30 +01:00
FredApps 7feff2a02d raw: dng_metadata::Timecode is the crate Timecode; share the CinemaDNG frame-rate range with dng.rs
Removes the duplicated Timecode type and BCD decoder (Sonar duplication 28%) and the copied
frame-rate plausibility check; capture_info is tested against the full reader's CinemaTags.
2026-11-16 08:35:12 +01:00
FredApps 77125b817f Merge remote-tracking branch 'origin/codex/dng-metadata' into w1648 2026-11-16 08:34:03 +01:00