Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.
TypeScript cross-platformelectronffmpegopen-sourceproduct-demorustscreen-capturescreen-recorderscreen-recordingscreen-studioscreencastspeech-to-texttypescriptvideo-editingvideo-editorwaylandwgpuwhisper
Allow PNG custom background uploads
Sunwood-ai-labs613ed008fc68
diff --git a/src/components/video-editor/SettingsPanel.tsx b/src/components/video-editor/SettingsPanel.tsxindex 82e106c5c..5ac597969 100644--- a/src/components/video-editor/SettingsPanel.tsx+++ b/src/components/video-editor/SettingsPanel.tsx@@ -43,6 +43,7 @@ import { getTestId } from "@/utils/getTestId";import ColorPicker from "../ui/color-picker";import { AnnotationSettingsPanel } from "./AnnotationSettingsPanel";import { BlurSettingsPanel } from "./BlurSettingsPanel";+import { BACKGROUND_IMAGE_ACCEPT, isSupportedBackgroundImageType } from "./backgroundImageUpload";import { CropControl } from "./CropControl";import { KeyboardShortcutsHelp } from "./KeyboardShortcutsHelp";import type {@@ -459,9 +460,7 @@ export function SettingsPanel({const file = files[0];- // Validate file type - only allow JPG/JPEG- const validTypes = ["image/jpeg", "image/jpg"];- if (!validTypes.includes(file.type)) {+ if (!isSupportedBackgroundImageType(file.type, file.name)) {toast.error(t("imageUpload.invalidFileType"), {description: t("imageUpload.jpgOnly"),});@@ -1041,7 +1040,7 @@ export function SettingsPanel({type="file"ref={fileInputRef}onChange={handleImageUpload}- accept=".jpg,.jpeg,image/jpeg"+ accept={BACKGROUND_IMAGE_ACCEPT}className="hidden"/><Buttondiff --git a/src/components/video-editor/backgroundImageUpload.test.ts b/src/components/video-editor/backgroundImageUpload.test.tsnew file mode 100644index 000000000..d83ca3a03--- /dev/null+++ b/src/components/video-editor/backgroundImageUpload.test.ts@@ -0,0 +1,20 @@+import { describe, expect, it } from "vitest";+import { isSupportedBackgroundImageType } from "./backgroundImageUpload";++describe("background image upload validation", () => {+ it("accepts PNG images for custom backgrounds", () => {+ expect(isSupportedBackgroundImageType("image/png", "生成画像1.png")).toBe(true);+ });++ it("accepts PNG images by extension when the browser does not provide a MIME type", () => {+ expect(isSupportedBackgroundImageType("", "生成画像1.png")).toBe(true);+ });++ it("keeps rejecting non-image uploads", () => {+ expect(isSupportedBackgroundImageType("text/plain", "notes.txt")).toBe(false);+ });++ it("does not allow extension fallback for explicit unsupported MIME types", () => {+ expect(isSupportedBackgroundImageType("text/plain", "notes.png")).toBe(false);+ });+});diff --git a/src/components/video-editor/backgroundImageUpload.ts b/src/components/video-editor/backgroundImageUpload.tsnew file mode 100644index 000000000..ebc256a2b--- /dev/null+++ b/src/components/video-editor/backgroundImageUpload.ts@@ -0,0 +1,20 @@+const SUPPORTED_BACKGROUND_IMAGE_TYPES = new Set(["image/jpeg", "image/jpg", "image/png"]);+const SUPPORTED_BACKGROUND_IMAGE_EXTENSIONS = new Set([".jpg", ".jpeg", ".png"]);++export const BACKGROUND_IMAGE_ACCEPT = ".jpg,.jpeg,.png,image/jpeg,image/png";++export function isSupportedBackgroundImageType(type: string, fileName: string): boolean {+ const normalizedType = type.trim().toLowerCase();+ if (SUPPORTED_BACKGROUND_IMAGE_TYPES.has(normalizedType)) {+ return true;+ }++ if (normalizedType) {+ return false;+ }++ const lowerName = fileName.trim().toLowerCase();+ return [...SUPPORTED_BACKGROUND_IMAGE_EXTENSIONS].some((extension) =>+ lowerName.endsWith(extension),+ );+}diff --git a/src/i18n/locales/en/settings.json b/src/i18n/locales/en/settings.jsonindex 9b85c2bf5..ff2147220 100644--- a/src/i18n/locales/en/settings.json+++ b/src/i18n/locales/en/settings.json@@ -93,7 +93,7 @@},"imageUpload": {"invalidFileType": "Invalid file type",- "jpgOnly": "Please upload a JPG or JPEG image file.",+ "jpgOnly": "Please upload a JPG, JPEG, or PNG image file.","uploadSuccess": "Custom image uploaded successfully!","failedToUpload": "Failed to upload image","errorReading": "There was an error reading the file."diff --git a/src/i18n/locales/es/settings.json b/src/i18n/locales/es/settings.jsonindex 423b158ee..8dee9c2ba 100644--- a/src/i18n/locales/es/settings.json+++ b/src/i18n/locales/es/settings.json@@ -93,7 +93,7 @@},"imageUpload": {"invalidFileType": "Tipo de archivo no válido",- "jpgOnly": "Por favor sube un archivo de imagen JPG o JPEG.",+ "jpgOnly": "Por favor sube un archivo de imagen JPG, JPEG o PNG.","uploadSuccess": "¡Imagen personalizada subida exitosamente!","failedToUpload": "Error al subir la imagen","errorReading": "Hubo un error al leer el archivo."diff --git a/src/i18n/locales/fr/settings.json b/src/i18n/locales/fr/settings.jsonindex 66df1ba98..56f2642af 100644--- a/src/i18n/locales/fr/settings.json+++ b/src/i18n/locales/fr/settings.json@@ -100,7 +100,7 @@},"imageUpload": {"invalidFileType": "Type de fichier invalide",- "jpgOnly": "Veuillez téléverser un fichier image JPG ou JPEG.",+ "jpgOnly": "Veuillez téléverser un fichier image JPG, JPEG ou PNG.","uploadSuccess": "Image personnalisée téléversée avec succès !","failedToUpload": "Échec du téléversement de l'image","errorReading": "Une erreur s'est produite lors de la lecture du fichier."diff --git a/src/i18n/locales/ja-JP/settings.json b/src/i18n/locales/ja-JP/settings.jsonindex 129217c50..cde1f1db5 100644--- a/src/i18n/locales/ja-JP/settings.json+++ b/src/i18n/locales/ja-JP/settings.json@@ -100,7 +100,7 @@},"imageUpload": {"invalidFileType": "無効なファイル形式",- "jpgOnly": "JPG または JPEG 画像ファイルをアップロードしてください。",+ "jpgOnly": "JPG、JPEG、または PNG 画像ファイルをアップロードしてください。","uploadSuccess": "カスタム画像が正常にアップロードされました!","failedToUpload": "画像のアップロードに失敗しました","errorReading": "ファイルの読み取り中にエラーが発生しました。"diff --git a/src/i18n/locales/ko-KR/settings.json b/src/i18n/locales/ko-KR/settings.jsonindex 08fdb3c56..c7df60d6e 100644--- a/src/i18n/locales/ko-KR/settings.json+++ b/src/i18n/locales/ko-KR/settings.json@@ -93,7 +93,7 @@},"imageUpload": {"invalidFileType": "지원하지 않는 파일 형식입니다",- "jpgOnly": "JPG 또는 JPEG 이미지 파일을 업로드해 주세요.",+ "jpgOnly": "JPG, JPEG 또는 PNG 이미지 파일을 업로드해 주세요.","uploadSuccess": "커스텀 이미지가 성공적으로 업로드되었습니다!","failedToUpload": "이미지 업로드에 실패했습니다","errorReading": "파일을 읽는 중 오류가 발생했습니다."diff --git a/src/i18n/locales/tr/settings.json b/src/i18n/locales/tr/settings.jsonindex 143c467cd..039158297 100644--- a/src/i18n/locales/tr/settings.json+++ b/src/i18n/locales/tr/settings.json@@ -93,7 +93,7 @@},"imageUpload": {"invalidFileType": "Geçersiz dosya türü",- "jpgOnly": "Lütfen bir JPG veya JPEG görüntü dosyası yükleyin.",+ "jpgOnly": "Lütfen JPG, JPEG veya PNG görüntü dosyası yükleyin.","uploadSuccess": "Özel görüntü başarıyla yüklendi!","failedToUpload": "Görüntü yüklenemedi","errorReading": "Dosya okunurken bir hata oluştu."diff --git a/src/i18n/locales/zh-CN/settings.json b/src/i18n/locales/zh-CN/settings.jsonindex 708ae5eaa..d2a10c158 100644--- a/src/i18n/locales/zh-CN/settings.json+++ b/src/i18n/locales/zh-CN/settings.json@@ -93,7 +93,7 @@},"imageUpload": {"invalidFileType": "无效的文件类型",- "jpgOnly": "请上传 JPG 或 JPEG 格式的图片文件。",+ "jpgOnly": "请上传 JPG、JPEG 或 PNG 格式的图片文件。","uploadSuccess": "自定义图片上传成功!","failedToUpload": "上传图片失败","errorReading": "读取文件时出错。"diff --git a/src/i18n/locales/zh-TW/settings.json b/src/i18n/locales/zh-TW/settings.jsonindex c93e8d5d7..6f2fb08cd 100644--- a/src/i18n/locales/zh-TW/settings.json+++ b/src/i18n/locales/zh-TW/settings.json@@ -100,7 +100,7 @@},"imageUpload": {"invalidFileType": "無效的檔案類型",- "jpgOnly": "請上傳 JPG 或 JPEG 格式的圖片檔案。",+ "jpgOnly": "請上傳 JPG、JPEG 或 PNG 格式的圖片檔案。","uploadSuccess": "自訂圖片上傳成功!","failedToUpload": "上傳圖片失敗","errorReading": "讀取檔案時出錯。"