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
@@ -34,7 +34,76 @@
</div>
<p class="setting-description">
<i class="pi pi-info-circle"></i>
Regenerates cover images for all EPUB and PDF books (excluding locked ones) from the embedded covers in the file.
Regenerates cover images for all books from the embedded covers in the file.
</p>
</div>
</div>
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">Vertical Cover Cropping</label>
<p-toggleswitch
[(ngModel)]="coverCroppingSettings.verticalCroppingEnabled"
(onChange)="onCoverCroppingChange()">
</p-toggleswitch>
</div>
<p class="setting-description">
<i class="pi pi-info-circle"></i>
Automatically crop extremely tall images (like web comics) from the top to create usable cover thumbnails.
</p>
</div>
</div>
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">Horizontal Cover Cropping</label>
<p-toggleswitch
[(ngModel)]="coverCroppingSettings.horizontalCroppingEnabled"
(onChange)="onCoverCroppingChange()">
</p-toggleswitch>
</div>
<p class="setting-description">
<i class="pi pi-info-circle"></i>
Automatically crop extremely wide images from the left to create usable cover thumbnails.
</p>
</div>
</div>
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">Aspect Ratio Threshold: {{ coverCroppingSettings.aspectRatioThreshold }}</label>
<div class="slider-container">
<p-slider
[(ngModel)]="coverCroppingSettings.aspectRatioThreshold"
[min]="1.5"
[max]="3"
[step]="0.1"
(onSlideEnd)="onCoverCroppingChange()">
</p-slider>
</div>
</div>
<p class="setting-description">
<i class="pi pi-info-circle"></i>
Images with aspect ratios exceeding this threshold will be cropped. A value of 2.5 means images more than 2.5x taller (or wider) than normal will be cropped.
</p>
</div>
</div>
<div class="setting-item">
<div class="setting-info">
<div class="setting-label-row">
<label class="setting-label">Smart Cropping</label>
<p-toggleswitch
[(ngModel)]="coverCroppingSettings.smartCroppingEnabled"
(onChange)="onCoverCroppingChange()">
</p-toggleswitch>
</div>
<p class="setting-description">
<i class="pi pi-info-circle"></i>
Skip uniform colour regions when determining where to crop. Focuses the cover image on the most relevant content.
</p>
</div>
</div>
@@ -215,3 +215,14 @@
margin-top: 0.5rem;
}
}
.slider-container {
flex: 1;
min-width: 200px;
max-width: 300px;
@media (max-width: 768px) {
min-width: 180px;
max-width: 250px;
}
}
@@ -7,9 +7,10 @@ import {MessageService} from 'primeng/api';
import {AppSettingsService} from '../../../shared/service/app-settings.service';
import {BookService} from '../../book/service/book.service';
import {AppSettingKey, AppSettings} from '../../../shared/model/app-settings.model';
import {AppSettingKey, AppSettings, CoverCroppingSettings} from '../../../shared/model/app-settings.model';
import {filter, take} from 'rxjs/operators';
import {InputText} from 'primeng/inputtext';
import {Slider} from 'primeng/slider';
@Component({
selector: 'app-global-preferences',
@@ -18,7 +19,8 @@ import {InputText} from 'primeng/inputtext';
Button,
ToggleSwitch,
FormsModule,
InputText
InputText,
Slider
],
templateUrl: './global-preferences.component.html',
styleUrl: './global-preferences.component.scss'
@@ -30,6 +32,13 @@ export class GlobalPreferencesComponent implements OnInit {
similarBookRecommendation: false,
};
coverCroppingSettings: CoverCroppingSettings = {
verticalCroppingEnabled: false,
horizontalCroppingEnabled: false,
aspectRatioThreshold: 2.5,
smartCroppingEnabled: false
};
private appSettingsService = inject(AppSettingsService);
private bookService = inject(BookService);
private messageService = inject(MessageService);
@@ -49,6 +58,9 @@ export class GlobalPreferencesComponent implements OnInit {
if (settings?.maxFileUploadSizeInMb) {
this.maxFileUploadSizeInMb = settings.maxFileUploadSizeInMb;
}
if (settings?.coverCroppingSettings) {
this.coverCroppingSettings = {...settings.coverCroppingSettings};
}
this.toggles.autoBookSearch = settings.autoBookSearch ?? false;
this.toggles.similarBookRecommendation = settings.similarBookRecommendation ?? false;
});
@@ -68,6 +80,10 @@ export class GlobalPreferencesComponent implements OnInit {
}
}
onCoverCroppingChange(): void {
this.saveSetting(AppSettingKey.COVER_CROPPING_SETTINGS, this.coverCroppingSettings);
}
saveCacheSize(): void {
if (!this.cbxCacheValue || this.cbxCacheValue <= 0) {
this.showMessage('error', 'Invalid Input', 'Please enter a valid cache size in MB.');