feat: image cropping / resizing T0
This commit is contained in:
1 parent
cb05b38f36
commit
e15f444603
18 files changed
+1869
-46
No files matched your search
@@ -42,3 +42,19 @@ export function rejectionTitle(filename: string) {
|
||||
export function sizeRejectionText(filename: string, bytes: number) {
|
||||
return `${filename} is ${formatMegabytes(bytes)} MB. Images can be up to 10 MB.`
|
||||
}
|
||||
|
||||
export function formatWholeKB(bytes: number): string {
|
||||
const kb = bytes / 1024
|
||||
const rounded = Math.round(kb * 10) / 10
|
||||
if (rounded === 0) {
|
||||
return '0.0'
|
||||
}
|
||||
return Number.isInteger(rounded) ? String(rounded) : rounded.toFixed(1)
|
||||
}
|
||||
|
||||
export function formatUploadProgress(loadedBytes: number, totalBytes: number): string {
|
||||
if (totalBytes < 1024 * 1024) {
|
||||
return `Uploading ${formatWholeKB(loadedBytes)} of ${formatWholeKB(totalBytes)} KB`
|
||||
}
|
||||
return `Uploading ${formatMegabytes(loadedBytes)} of ${formatMegabytes(totalBytes)} MB`
|
||||
}
|
||||
Reference in new issue
Block a user