feat: add additional cover art actions and settings (#1938)

* feat: add cover image auto cropping when oversized

* feat: add smart cropping to ignore sections of constant colours in cover images

* fix: description implied cbx files would be excluded from cover regeneration when they are not

* feat: add options to bulk edit cover images in the library view

* fix: resolve issues with batching requests and data validation for cover images
This commit is contained in:
CounterClops
2025-12-19 11:20:50 -07:00
committed by GitHub
parent 4e6842c189
commit 54108754f9
26 changed files with 745 additions and 37 deletions
@@ -257,6 +257,7 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
() => this.fetchMetadata(),
() => this.bulkEditMetadata(),
() => this.multiBookEditMetadata(),
() => this.regenerateCoversForSelected(),
);
this.tieredMenuItems = this.bookMenuService.getTieredMenuItems(this.selectedBooks);
@@ -668,6 +669,38 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
this.dialogHelperService.openMultibookMetadataEditorDialog(this.selectedBooks);
}
regenerateCoversForSelected(): void {
if (!this.selectedBooks || this.selectedBooks.size === 0) return;
const count = this.selectedBooks.size;
this.confirmationService.confirm({
message: `Are you sure you want to regenerate covers for ${count} book(s)?`,
header: 'Confirm Cover Regeneration',
icon: 'pi pi-image',
acceptLabel: 'Yes',
rejectLabel: 'No',
accept: () => {
this.bookService.regenerateCoversForBooks(Array.from(this.selectedBooks)).subscribe({
next: () => {
this.messageService.add({
severity: 'success',
summary: 'Cover Regeneration Started',
detail: `Regenerating covers for ${count} book(s). Refresh the page when complete.`,
life: 3000
});
},
error: () => {
this.messageService.add({
severity: 'error',
summary: 'Failed',
detail: 'Could not start cover regeneration.',
life: 3000
});
}
});
}
});
}
moveFiles() {
this.dialogHelperService.openFileMoverDialog(this.selectedBooks);
}
@@ -22,7 +22,8 @@ export class BookMenuService {
autoFetchMetadata: () => void,
fetchMetadata: () => void,
bulkEditMetadata: () => void,
multiBookEditMetadata: () => void): MenuItem[] {
multiBookEditMetadata: () => void,
regenerateCovers: () => void): MenuItem[] {
return [
{
label: 'Auto Fetch Metadata',
@@ -43,6 +44,11 @@ export class BookMenuService {
label: 'Multi-Book Metadata Editor',
icon: 'pi pi-clone',
command: multiBookEditMetadata
},
{
label: 'Regenerate Covers',
icon: 'pi pi-image',
command: regenerateCovers
}
];
}
@@ -432,6 +432,17 @@ export class BookService {
return this.http.post<void>(`${this.url}/${bookId}/regenerate-cover`, {});
}
regenerateCoversForBooks(bookIds: number[]): Observable<void> {
return this.http.post<void>(`${this.url}/bulk-regenerate-covers`, { bookIds });
}
bulkUploadCover(bookIds: number[], file: File): Observable<void> {
const formData = new FormData();
formData.append('file', file);
formData.append('bookIds', bookIds.join(','));
return this.http.post<void>(`${this.url}/bulk-upload-cover`, formData);
}
/*------------------ All the metadata related calls go here ------------------*/