Skip to content

Keep the cover image's Opaque choice through the Edit tab and the thumbnail (BL-16819) - #8339

Merged
andrew-polk merged 1 commit into
Version6.5from
BL-16819-cover-opaque-edit-tab
Sep 10, 2026
Merged

Keep the cover image's Opaque choice through the Edit tab and the thumbnail (BL-16819)#8339
andrew-polk merged 1 commit into
Version6.5from
BL-16819-cover-opaque-edit-tab

Conversation

@JohnThomson

@JohnThomson JohnThomson commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Problem

Setting the front cover image's Transparency to Opaque (or Transparent) still did not stick after the first fix (#8331). The choice survived quitting and reopening Bloom and switching between books in the Collections tab, but the moment the book was opened in the Edit tab the cover image was back on Auto, and the next save wrote that loss into the book. The book's thumbnail in the collection also ignored the choice: a line-art cover marked Opaque was still drawn with its white background made transparent.

Cause

Every time the Edit tab is entered, Bloom re-applies the book's content-language choice, which pushes BookData's member data set back onto the pages. That data set is a snapshot taken when the book was loaded; when a page is saved, its entry for the cover image is recreated with the new value but without the saved attribute list. The class-restoring code added in #8331 read a missing attribute list as "no classes" and removed bloom-opaque from the image.

The collection thumbnail is composed straight from the cover image file, and that code always ran the line-art transparency check without looking at the image's classes.

What the PR does

  • When the cover image is refilled and the data set carries no attribute information for it, the image's classes are left alone, the same way attribute merging already treats a missing list. The choice now survives the Edit tab.
  • The book thumbnail honors the same three-way decision the browser uses: Opaque never gets a transparent background, Transparent always does, Auto only when the picture looks like line art. A JPEG cover now gets the same treatment as a PNG (the copy is re-saved as PNG, since only a PNG can carry transparency), and the transparent copy is written to a uniquely named temp file so thumbnails made at the same time cannot collide, a failure in that step is logged and the thumbnail is made without transparency, and the old thumbnail-only helper that skipped JPEGs is removed.
  • Tests: the data-set round trip after a save (fails without the fix), a BringBookUpToDate round trip including the page as prepared for editing, and a pixel-level check of the thumbnail for each of the three choices on PNG and JPEG covers (the Opaque cases fail without the fix).

Ref: https://issues.bloomlibrary.org/youtrack/issue/BL-16819

🤖 Generated with Claude Code


Devin review


This change is Reviewable

Comment thread src/BloomExe/BookThumbNailer.cs Outdated
Comment thread src/BloomExe/BookThumbNailer.cs Outdated
@JohnThomson

Copy link
Copy Markdown
Contributor Author

[Claude Fable 5.1] Consulted Devin on 2026-09-10 up to commit a938879.

Three rounds. Devin raised two bugs, both fixed and both marked resolved by its final pass: an Auto JPEG cover still skipped transparency in the collection thumbnail (#8339 (comment)), and the thumbnail's transparency temp file was named after the cover image so concurrent thumbnails could collide (#8339 (comment)). No Investigate or Informational flags in any round. The pr-automation check passed on every commit.

…mbnail (BL-16819)

https://issues.bloomlibrary.org/youtrack/issue/BL-16819

The first fix (#8331) restores the bloom-opaque / bloom-transparent classes on the
cover image from the data-div whenever the xmatter is regenerated. That survived
reopening the book and switching books, but entering the Edit tab still reset the
image to Auto, and the next save wrote the loss into the book file. The book's
thumbnail in the collection also ignored the choice.

Entering the Edit tab calls Book.SetMultilingualContentLanguages, which pushes the
member _dataset back onto the pages with UpdateDomFromDataset(). That data set is
the snapshot taken when the BookData was built; when a page is saved,
UpdateSingleTextVariableInDataDiv recreates its entry for the cover image with the
new value but no attribute list. RestoreImgClassesFromDataDiv read the missing list
as an empty class list and removed the class.

- RestoreImgClassesFromDataDiv leaves the image alone when there is no attribute
  list, matching MergeAttrsIntoElement, which already treats null as "no
  information".
- BookThumbNailer.CreateThumbnailOfCoverImage decides transparency with
  HtmlDom.GetImageTransparencyMode, so the collection thumbnail honors Opaque and
  Transparent instead of always running the line-art check. Auto and Transparent
  both work for a JPEG cover: ImageUtils.MakeTransparentBackground re-saves a
  non-PNG source as PNG (only a PNG can carry the alpha channel), and
  MakeTransparentBackgroundIfNeeded reuses it after the line-art check, which
  accepts JPEGs just as the editor's display path does. The transparent copy is
  written to a randomly named .png temp file so thumbnails made at the same time
  cannot collide, and a failure in that step is logged and the thumbnail is made
  without transparency. RuntimeImageProcessor.MakePngBackgroundTransparentIfDesirable
  has no remaining callers and is removed.

Tests: BookDataTests cover UpdateDomFromDataset() straight after construction and
after a save that set the choice (the latter fails without the fix, with an empty
class attribute). BookTests cover the BringBookUpToDate round trip including the
page as prepared for editing. BookThumbnailerTests check a pixel of the thumbnail
for each of the three choices on PNG and JPEG covers; the Opaque cases fail without
the fix.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@JohnThomson
JohnThomson force-pushed the BL-16819-cover-opaque-edit-tab branch from a938879 to 9a7b1ce Compare September 10, 2026 15:46
@JohnThomson
JohnThomson marked this pull request as ready for review September 10, 2026 15:46

@andrew-polk andrew-polk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andrew-polk reviewed 7 files and all commit messages, and resolved 2 discussions.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on JohnThomson).

@andrew-polk
andrew-polk merged commit ba54e90 into Version6.5 Sep 10, 2026
1 of 2 checks passed
@andrew-polk
andrew-polk deleted the BL-16819-cover-opaque-edit-tab branch September 10, 2026 18:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants