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
@@ -312,6 +312,49 @@
</div>
</div>
<!-- Cover Image Upload Section -->
<div class="flex flex-col gap-2 border border-gray-700 rounded-md p-4 bg-gray-900">
<label class="flex items-center gap-2 text-base font-semibold">
<i class="pi pi-image"></i>
Cover Image
</label>
<p class="text-sm text-gray-400">
Upload an image to set as the cover for all selected books.
</p>
<div class="flex items-center gap-4 mt-2">
@if (selectedCoverFile) {
<div class="flex items-center gap-2 text-sm text-gray-300">
<i class="pi pi-file-image"></i>
<span>{{ selectedCoverFile.name }}</span>
<p-button
icon="pi pi-times"
[text]="true"
size="small"
severity="danger"
(onClick)="clearCoverFile()"
pTooltip="Remove file"
tooltipPosition="top">
</p-button>
</div>
} @else {
<input
type="file"
#coverFileInput
accept="image/jpeg,image/png,image/webp"
(change)="onCoverFileSelect($event)"
class="hidden">
<p-button
icon="pi pi-upload"
label="Select Image"
[outlined]="true"
size="small"
severity="info"
(onClick)="coverFileInput.click()">
</p-button>
}
</div>
</div>
<div class="flex justify-end mt-4">
<p-button type="submit" label="Apply to Selected" [disabled]="loading"/>
</div>
@@ -41,6 +41,7 @@ export class BulkMetadataUpdateComponent implements OnInit {
mergeMoods = true;
mergeTags = true;
loading = false;
selectedCoverFile: File | null = null;
clearFields = {
authors: false,
@@ -257,13 +258,37 @@ export class BulkMetadataUpdateComponent implements OnInit {
this.loading = true;
this.bookService.updateBooksMetadata(payload).subscribe({
next: () => {
this.loading = false;
this.messageService.add({
severity: 'success',
summary: 'Metadata Updated',
detail: 'Books updated successfully'
});
this.ref.close(true);
if (this.selectedCoverFile) {
this.bookService.bulkUploadCover(this.bookIds, this.selectedCoverFile).subscribe({
next: () => {
this.loading = false;
this.messageService.add({
severity: 'success',
summary: 'Metadata & Cover Updated',
detail: 'Books updated and cover upload started. Refresh the page when complete.'
});
this.ref.close(true);
},
error: err => {
console.error('Bulk cover upload failed:', err);
this.loading = false;
this.messageService.add({
severity: 'warn',
summary: 'Partial Success',
detail: 'Metadata updated but cover upload failed'
});
this.ref.close(true);
}
});
} else {
this.loading = false;
this.messageService.add({
severity: 'success',
summary: 'Metadata Updated',
detail: 'Books updated successfully'
});
this.ref.close(true);
}
},
error: err => {
console.error('Bulk metadata update failed:', err);
@@ -276,4 +301,15 @@ export class BulkMetadataUpdateComponent implements OnInit {
}
});
}
onCoverFileSelect(event: Event): void {
const input = event.target as HTMLInputElement;
if (input.files && input.files.length > 0) {
this.selectedCoverFile = input.files[0];
}
}
clearCoverFile(): void {
this.selectedCoverFile = null;
}
}