Made changes based on ZXY101 code review
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import { showSnackbar } from '$lib/util';
|
import { showSnackbar } from '$lib/util';
|
||||||
import { writable } from 'svelte/store';
|
import { writable } from 'svelte/store';
|
||||||
import { blobToBase64, imageResize } from '.';
|
import { blobToBase64, imageResize } from '.';
|
||||||
|
import { Settings } from '$lib/settings';
|
||||||
|
|
||||||
type CropperModal = {
|
type CropperModal = {
|
||||||
open: boolean;
|
open: boolean;
|
||||||
@@ -34,7 +35,7 @@ function getRadianAngle(degreeValue: number) {
|
|||||||
|
|
||||||
export type Pixels = { width: number; height: number; x: number; y: 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 image = await createImage(imageSrc);
|
||||||
const canvas = new OffscreenCanvas(image.width, image.height);
|
const canvas = new OffscreenCanvas(image.width, image.height);
|
||||||
const ctx = canvas.getContext('2d');
|
const ctx = canvas.getContext('2d');
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { settings } from "$lib/settings";
|
import { Settings, settings } from "$lib/settings";
|
||||||
import { showSnackbar } from "$lib/util"
|
import { showSnackbar } from "$lib/util"
|
||||||
import { get } from "svelte/store";
|
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 image = await createImageBitmap(source);
|
||||||
const canvas = new OffscreenCanvas(image.width, image.height);
|
const canvas = new OffscreenCanvas(image.width, image.height);
|
||||||
const context = canvas.getContext("2d");
|
const context = canvas.getContext("2d");
|
||||||
|
|||||||
@@ -124,6 +124,9 @@
|
|||||||
type="number"
|
type="number"
|
||||||
bind:value={qualityField}
|
bind:value={qualityField}
|
||||||
on:change={() => updateAnkiSetting('qualityField', qualityField)}
|
on:change={() => updateAnkiSetting('qualityField', qualityField)}
|
||||||
|
min={0}
|
||||||
|
max={1}
|
||||||
|
step="0.1"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -101,9 +101,9 @@ const defaultSettings: Settings = {
|
|||||||
overwriteImage: true,
|
overwriteImage: true,
|
||||||
pictureField: 'Picture',
|
pictureField: 'Picture',
|
||||||
sentenceField: 'Sentence',
|
sentenceField: 'Sentence',
|
||||||
heightField: 200,
|
heightField: 0,
|
||||||
widthField: 200,
|
widthField: 0,
|
||||||
qualityField: 0.5,
|
qualityField: 1,
|
||||||
triggerMethod: 'both'
|
triggerMethod: 'both'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user