Made changes based on ZXY101 code review

This commit is contained in:
decodatain
2025-06-22 20:16:15 -06:00
parent 2fb5d4ae0a
commit 2493555faf
4 changed files with 10 additions and 6 deletions

View File

@@ -1,6 +1,7 @@
import { showSnackbar } from '$lib/util';
import { writable } from 'svelte/store';
import { blobToBase64, imageResize } from '.';
import { Settings } from '$lib/settings';
type CropperModal = {
open: boolean;
@@ -34,7 +35,7 @@ function getRadianAngle(degreeValue: number) {
export type Pixels = { width: number; height: number; x: number; y: number }
export async function getCroppedImg(imageSrc: string, pixelCrop: Pixels, settings: any, rotation = 0 ) {
export async function getCroppedImg(imageSrc: string, pixelCrop: Pixels, settings: Settings, rotation = 0 ) {
const image = await createImage(imageSrc);
const canvas = new OffscreenCanvas(image.width, image.height);
const ctx = canvas.getContext('2d');

View File

@@ -1,4 +1,4 @@
import { settings } from "$lib/settings";
import { Settings, settings } from "$lib/settings";
import { showSnackbar } from "$lib/util"
import { get } from "svelte/store";
@@ -50,7 +50,7 @@ export async function blobToBase64(blob: Blob) {
});
}
export async function imageToWebp(source: File, settings: any) {
export async function imageToWebp(source: File, settings: Settings) {
const image = await createImageBitmap(source);
const canvas = new OffscreenCanvas(image.width, image.height);
const context = canvas.getContext("2d");

View File

@@ -124,6 +124,9 @@
type="number"
bind:value={qualityField}
on:change={() => updateAnkiSetting('qualityField', qualityField)}
min={0}
max={1}
step="0.1"
/>
</div>
</div>

View File

@@ -101,9 +101,9 @@ const defaultSettings: Settings = {
overwriteImage: true,
pictureField: 'Picture',
sentenceField: 'Sentence',
heightField: 200,
widthField: 200,
qualityField: 0.5,
heightField: 0,
widthField: 0,
qualityField: 1,
triggerMethod: 'both'
}
};