Commit Graph
91 Commits
Author SHA1 Message Date
aiongg 829e5b86c3 Merge remote-tracking branch 'upstream/main' into image-perf
# Conflicts:
#	crates/render/src/decode.rs
2026-11-14 12:47:03 +00:00
aiongg b73c3dd87a Build: restore designcraft_format::write; render decode without the image crate (#2780)
* Build: restore designcraft_format::write for recovery; render decodes without naming the image crate

* Build: collapse the nested if in images tone (clippy)

* IDML export: placements in cells and footnotes embed their PDF layer choices

* Tests: Word fixtures carry the document relationships part

* PDF/X-4: untagged WebP images carry sRGB

* Images: CMYK TIFFs with other inks fall back to RGB; associated alpha keeps its inks

craft-image-codecs' TiffPage lists InkSet (storytold/craft-libs#1307), so decode_cmyk_tiff
again refuses InkSet 2 instead of reading other inks as C, M, Y and K. Associated alpha
is made straight by the decoder; the PDF tests check those inks and that alpha.

* PDF tests: CMYK fallback expects the screen's RGB; alpha images read the masked image

The RGB fallback for other inks converts through the working CMYK space, as decode_rgba
does, so the test takes its expected samples from decode_rgba. image_color_samples took the
first image stream, which for an image with alpha is its soft mask.

* Images: repin craft-image-codecs to the InkSet enum (storytold/craft-libs#1307)

* Pin craft-image-codecs to storytold/craft-libs ea1c842 (#1307)
2026-11-14 07:42:07 -05:00
aiongg dc43db30da Build: collapse the nested if in images tone (clippy)
(cherry picked from commit de33682242)
2026-11-14 05:15:29 +00:00
aiongg 1a156fa564 Merge remote-tracking branch 'upstream/main' into image-perf
# Conflicts:
#	crates/images/src/jpeg.rs
#	crates/images/src/lib.rs
2026-11-14 04:29:08 +00:00
Dylan M. Taylor 382fc27a5b fix(idml,images,pptx,textimport): update adapters and tests for craft-libs cutover 2026-11-14 03:35:09 +00:00
Dylan M. Taylor 32274e843a Merge codex/designcraft-craft-libs into origin/main: cut over document formats and codecs to craft-libs 2026-11-14 02:13:28 +00:00
Dylan M. Taylor 2769d0b88f Move DTD and raster encoding to craft-libs 2026-11-13 04:13:55 -05:00
Dylan M. Taylor 581ba450cd Delegate screen SVG parsing and rendering 2026-11-13 03:55:54 -05:00
Dylan M. Taylor 275b907c57 Use shared PDF SVG adapter and CSV sniffing 2026-11-13 03:43:21 -05:00
Dylan M. Taylor aff7435b81 Route file dispatch through shared format APIs 2026-11-13 01:34:50 -05:00
Dylan M. Taylor fcb571c52a Delegate raster codecs and text interchange to craft-libs 2026-11-13 01:11:49 -05:00
Dylan M. Taylor 9b0c6ee2a7 Delegate EPS preview parsing to craft-eps 2026-11-13 00:40:26 -05:00
Dylan M. Taylor 3617464d73 Use craft-eps for EPS section and box parsing 2026-11-13 00:35:54 -05:00
Dylan M. Taylor 9889488f5d Fix lockfile and EPS test after rebase 2026-11-13 00:18:41 -05:00
Dylan M. Taylor 1883719699 Move IDML package IO and SVG preflight to craft-libs 2026-11-13 00:16:41 -05:00
Dylan M. Taylor 2eff7e822f Name reduced JPEG estimate API 2026-11-12 17:55:36 -05:00
Dylan M. Taylor 1c3285d8a3 Count progressive JPEG buffers in warm budget 2026-11-12 17:55:11 -05:00
Dylan M. Taylor 764b06526b Estimate reduced JPEG warm reservations 2026-11-12 17:41:55 -05:00
Dylan M. Taylor a656db2be4 Merge upstream changes into parallel image decode 2026-11-12 17:19:59 -05:00
Dylan M. Taylor 982dbc6c3c Merge main into parallel image decoding 2026-11-12 17:04:58 -05:00
Dylan M. Taylor 49764b0b37 Merge main into reduced JPEG proxy decoding 2026-11-12 17:03:41 -05:00
dotCooCoo 2b6fb6fa06 Images: count a decode's buffers at their peak before decoding in parallel
The gate that limits parallel decodes counted each image at its cached
size (4 bytes a pixel and a third more for the smaller levels). A decode
holds more than that while it converts the pixels: an 8-bit image keeps
its RGBA copy beside the decoded or the premultiplied pixels, 8 bytes a
pixel. Two 5,500 pixel square images passed the gate together and could
hold more than half the cache budget at once.

- decode_sizes returns the cached size and the peak size from one size
  read. The peak counts the samples as stored beside their converted
  copy (designcraft_images::decode_bytes_per_pixel): 8 bytes a pixel for
  8-bit color, 10 for 16-bit RGB, 12 for 16-bit CMYK TIFFs and 16-bit
  RGBA, 10 for 8-bit CMYKA TIFFs, 15 for 16-bit CMYKA TIFFs, 9 for
  PSDs. An EPS counts as its TIFF preview. PDF pages, SVGs and EPS
  files without a preview count 8.
- warm budgets the cache with the cached size and gates decodes with
  the peak size.
- Every warm call in the process shares one gate, so the canvas
  worker, thumbnails and exports together stay within half the budget
  while they decode. warm returns the most its own call had decoding.
- An EPS without a preview is sized at the larger of its drawn
  PostScript and its placeholder. The placeholder is clamped to 4000
  pixels on each side, so a 10,000 by 4,000 point EPS that is not drawn
  takes 4000 by 4000 pixels, not the 4000 by 1600 counted before.
2026-11-12 13:53:38 -08:00
dotCooCoo 55963c4918 Images: pick a reduced JPEG's scale by its long side
The JPEG decoder takes the smallest scale that meets either requested
side. A short side rounds up to the same size at several scales, so a
100 x 2 JPEG asked for at a half decoded at an eighth (13 x 1). The
long side alone now picks the scale, and a decode whose size differs
from the requested reduction is refused, which falls back to the full
decode.
2026-11-12 12:57:16 -08:00
Dylan M. Taylor 6790d009fe Merge pull request #2651 from dotCooCoo/fix/placed-image-resolution
Place: images come in at the resolution stored in the file
2026-11-12 15:25:55 -05:00
dotCooCoo 855d017d5b Images: limit reduced JPEG decodes by the full image size
A reduced decode now applies the full decode's size limits before it
reads any image data:

- A file whose size pixel_size cannot read is refused, so the 256 Mpx
  check always has a size to compare. The JPEG decoder's own reading of
  the frame size is checked against the same limit.
- A progressive JPEG keeps the coefficients of the full-size image until
  its last scan, whatever the output size. When those take more than
  512 MiB (each component counted at full size, each side rounded up to
  32 pixels), the reduced decode is refused and the full decode, with
  its own limits, applies.
2026-11-12 10:34:02 -08:00
dotCooCoo d3a073470c Images: decode JPEG screen proxies at a reduced size
A placed JPEG drawn at a fraction of its pixel size was decoded at full
size first and then halved down to the level the screen needs. For a
24 MP photo that is a 96 MB decode per image, and with several such
images on a page the decoded pixels outgrow the image cache.

A YCbCr or grayscale JPEG whose wanted level is a half, a quarter or an
eighth of its size (or smaller) is now decoded at that size straight
from its compressed blocks with jpeg-decoder's scaled IDCT, cut to the
size the halving path gives the same level, and halved from there for
smaller levels. The embedded ICC profile is applied as in a full
decode. CMYK and YCCK JPEGs, other formats and the full size still
decode in full.
2026-11-12 10:18:07 -08:00
dotCooCoo 58cf0ba28a Place: WebP EXIF stops at the declared RIFF end
The RIFF size counts the bytes after its own field, so the container ends at
offset 8 plus the size, not 12. An EXIF chunk that ran up to four bytes past
the declared container was read when trailing bytes followed it. A new test
covers an exact size with and without trailing bytes, a size declared four
bytes short, and a file cut inside the EXIF chunk.
2026-11-12 09:08:51 -08:00
FredApps 31d4c7f7f4 Merge pull request #2665 from dotCooCoo/feat/paste-clipboard-image
Paste: images on the system clipboard paste as embedded images
2026-11-12 18:03:55 +01:00
Dylan M. Taylor eb0ea78d9a Images: a WebP with an ICC chunk longer than the file is read without its profile
* Images: a WebP whose ICC chunk declares more than the file holds is read without it
2026-11-12 06:27:29 -05:00
dotCooCoo 630b5dfc43 Paste: images on the system clipboard paste as embedded images (#2204)
Paste ignored a bitmap on the system clipboard: a screenshot or an image
copied in a browser had to be saved and placed. Paste now places it.

- edit.pasteImage {base64, name?, spread?, at?} embeds the image in the
  selected empty frame, or in a new frame centered on `at` at its stored
  resolution (72 ppi when none) and at most 60% of the page width, as
  File > Place sizes it. Save and reopen and IDML export keep the pixels.
  Images over 64 million pixels and names without an image extension are
  refused.
- Ctrl/Cmd+V pastes the image egui delivers with no text, and Edit >
  Paste reads the clipboard's bitmap, or the first image file of a copied
  file list, when there is no text or the text is only an address.
- The menu read waits at most 1.5 s on its own thread, with one read in
  flight at a time.
- With a native menu, objects copied here still paste as objects until
  the pasteboard's change count shows a newer copy.
- ui.paste takes {image} for the control channel.
2026-11-11 20:50:24 -08:00
dotCooCoo 7ba1f8b96f Place: test PNG and WebP resolution past 64 chunks
Tests read a pHYs chunk behind 100 text chunks in a PNG, ignore a pHYs
after the image data, and read an EXIF chunk stored after 100 frames of
an animated WebP.
2026-11-11 19:07:29 -08:00
autocraft-bot[bot] 81f0d766cf Apply review fixes
- crates/images/src/resolution.rs
- crates/render/src/decode.rs
2026-11-12 02:47:57 +00:00
dotCooCoo c8136c538b Place: an unusable EXIF resolution falls back to the JFIF density
A JPEG whose EXIF resolution is 0 ppi or outside 1 to 100,000 ppi now
takes its size from its JFIF density instead of one point per pixel.

Tests place an 11 x 17 in image (330 x 510 px at 30 ppi) with a click,
check that it comes in at 792 x 1224 pt and keeps that size through a
save and reopen, and that an image with no stored resolution comes in
at 72 ppi.
2026-11-11 18:20:51 -08:00
aiongg 0f1f51cbd4 Fix failing CI check
- crates/images/src/resolution.rs
2026-11-11 18:03:40 -08:00
aiongg 581af01d88 Apply review fixes
- crates/images/src/resolution.rs
2026-11-11 18:03:40 -08:00
aiongg 058815cd80 Honor embedded raster resolution when placing graphics (#1991)
A 600px photo saved at 600dpi places 1in wide, as in InDesign, instead
of one pixel per point. Reads JFIF/EXIF (JPEG), pHYs (PNG), EXIF (WebP),
pixels-per-meter (BMP) and TIFF resolution tags; insane metadata falls
back to 72ppi.
2026-11-11 18:03:40 -08:00
zwork eb0dbcbb14 Merge remote-tracking branch 'upstream/main' into work-1030 2026-11-04 17:36:38 +03:00
Dylan M. Taylorandaiongg 9437553fd4 Images: one budget for the nested SVG data images of a parse (#2254)
* images: one nested-SVG byte budget per parse

* Apply review fixes

- crates/images/src/lib.rs

---------

Co-authored-by: aiongg <67543387+aiongg@users.noreply.github.com>
2026-11-03 21:29:36 -05:00
NetterSilverandClaude Opus 5.5 41a64bc10f Match placed SVG font-family against legacy family and full names
Fixes #2085

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 15:35:41 +00:00
VoiceLessQ be81d5db0e Images: check the RGBA budget before GIF tone and CMYK TIFF decodes (#1586)
tone() decoded a GIF to RGBA and decode_cmyk_tiff() called read_image()
without the header check decode_rgba() runs. Both now call
too_large_to_decode() first. The decoders' own limits (image 512 MiB,
tiff 256 MiB) already refused these files; the guard refuses them from
the header instead.
2026-10-30 00:40:00 -02:00
VoiceLessQ d5f07d30eb PDF: check the RGBA budget before recompressing an image (#1586)
With compressImages on, PDF export re-encodes rasters as JPEG in
recompress, which decoded with the image crate directly. A gray PNG
that decode_rgba refuses still decoded there, was copied and encoded
as JPEG, and only then dropped: krilla refuses a JPEG wider or taller
than 16,384 px, and every raster past the budget is. Exporting the
23,000 px PNG that way took 4.2 s and 1 GB more memory, for a PDF
without the image.

recompress now asks too_large_to_decode first, the check decode_rgba
uses, so the export skips the image with the same warning at once.
2026-10-28 23:28:11 -02:00
VoiceLessQ 5eddc821ec Images: refuse a raster that would decode past 1 GiB of RGBA (fixes #1586)
decode_rgba relied on the image crate's 512 MiB limit, which bounds
only the decoder's own output. A gray or 1-bit image just under it
expanded four times to RGBA, and render made a premultiplied copy on
top: a 288 KB PNG of 23,000 x 23,000 pixels froze the first draw for
9 s and took the app to 4.5 GB. The size is now read from the header
and anything past 256 Mpx is refused before decoding. It draws as an
empty frame, and PDF export skips it with a warning.

A 300 ppi scan of an A0 sheet (about 139 Mpx) still opens.
2026-10-28 22:50:39 -02:00
aiongg 98fb372245 refactor(images): move the tests module of lib.rs to tests.rs 2026-10-26 18:18:14 +00:00
aiongg 7c02423416 refactor(images): move the tests module of psd.rs to psd/tests.rs 2026-10-26 18:18:13 +00:00
skylar taylor-barrick bd4b9dd1d2 egui-037: reconcile shared window integration with main 2026-10-25 18:34:10 +01:00
skylartaylor a2db858e7d egui037: Port DesignCraft to egui 0.37
Pin the final egui, winit and shared UI revisions and reconcile current main.
Preserve document-epoch input and screenshot boundaries, host action ordering,
and Windows path regression coverage. Add click/End batch characterization.

Validation: all nine Linux CI stages pass (3230 tests, zero failures); Windows
CI and bounded native editing workflows pass on the same production source.
2026-10-25 00:52:21 +02:00
Dylan M. TaylorandClaude Sonnet 5.5 cb763c2583 refactor: split complex functions in psd, table, parabox, index, trace, pdf export, render (Sonar S3776) (#1724)
Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-24 04:51:26 -04:00
Dylan M. TaylorandClaude Sonnet 5.5 8299d26400 chore: replace trivial closures with method paths (Sonar S1612) (#1714)
Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-24 04:30:43 -04:00
Dylan M. TaylorandClaude Sonnet 5.5 bfd95b258b chore: drop redundant 'static lifetimes in statics and consts (Sonar S8863) (#1713)
Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-24 04:30:39 -04:00
aiongg 3ee11391ae CI: one integration-test binary per crate 2026-10-23 01:17:48 +00:00