Unrestricted Open-source alternative to AI video platforms — Free AI image & video generation studio with 600+ models (Flux, Midjourney, Kling, Sora, Veo). No content filters. Self-hosted, MIT licensed.
JavaScript ai-art-generatorai-image-generationai-video-generationfal-ai-alternativegenerative-aiimage-to-videoinvideo-alternativekling-ailipsynclitellm-alternativemidjourney-alternativemuapiopen-sourceopenrouter-alternativeseedance2sora-alternativetext-to-imagetext-to-videouncensoredwan-video
fix(studio): preserve image download format
antilya8ab1afb63df1
diff --git a/packages/studio/src/components/ImageStudio.jsx b/packages/studio/src/components/ImageStudio.jsxindex 9ac70e8f..7e667a22 100644--- a/packages/studio/src/components/ImageStudio.jsx+++ b/packages/studio/src/components/ImageStudio.jsx@@ -4,6 +4,7 @@ import { useState, useEffect, useRef, useCallback } from "react";import toast, { Toaster } from "react-hot-toast";import { generateImage, generateI2I, uploadFile } from "../muapi.js";import { formatErrorMessage } from "../utils/formatError.js";+import { downloadImage } from "../utils/downloadImage.js";import { scopedPersistKey, migrateLegacyPersistKey } from "../persistKey.js";import DrawModal from "./DrawModal.jsx";import MobileGenerationActions, {@@ -42,25 +43,6 @@ import {promptMediaButtonClassName,} from "./prompt/PromptComposer.jsx";-// ─── helpers ────────────────────────────────────────────────────────────────--async function downloadImage(url, filename) {- try {- const response = await fetch(url);- const blob = await response.blob();- const blobUrl = URL.createObjectURL(blob);- const a = document.createElement("a");- a.href = blobUrl;- a.download = filename;- document.body.appendChild(a);- a.click();- document.body.removeChild(a);- URL.revokeObjectURL(blobUrl);- } catch {- window.open(url, "_blank");- }-}-// ─── UploadButton (inline picker) ───────────────────────────────────────────function UploadButton({ apiKey, maxImages, onSelect, onClear, initialUrls = [], label = null, persistedHistory = null, onHistoryChange = null }) {diff --git a/packages/studio/src/utils/downloadImage.js b/packages/studio/src/utils/downloadImage.jsnew file mode 100644index 00000000..c85b5984--- /dev/null+++ b/packages/studio/src/utils/downloadImage.js@@ -0,0 +1,31 @@+const IMAGE_EXTENSION_BY_MIME_TYPE = {+ "image/jpeg": "jpg",+ "image/png": "png",+ "image/webp": "webp",+};++export function getImageDownloadFilename(filename, mimeType) {+ const extension = IMAGE_EXTENSION_BY_MIME_TYPE[mimeType];+ if (!extension) return filename;++ const extensionIndex = filename.lastIndexOf(".");+ const basename = extensionIndex > 0 ? filename.slice(0, extensionIndex) : filename;+ return `${basename}.${extension}`;+}++export async function downloadImage(url, filename) {+ try {+ const response = await fetch(url);+ const blob = await response.blob();+ const blobUrl = URL.createObjectURL(blob);+ const anchor = document.createElement("a");+ anchor.href = blobUrl;+ anchor.download = getImageDownloadFilename(filename, blob.type);+ document.body.appendChild(anchor);+ anchor.click();+ document.body.removeChild(anchor);+ URL.revokeObjectURL(blobUrl);+ } catch {+ window.open(url, "_blank");+ }+}diff --git a/src/components/ImageStudio.js b/src/components/ImageStudio.jsindex 4d73a813..d0e8d0e1 100644--- a/src/components/ImageStudio.js+++ b/src/components/ImageStudio.js@@ -11,6 +11,7 @@ import { AuthModal } from './AuthModal.js';import { t } from '../lib/i18n.js';import { createUploadPicker } from './UploadPicker.js';import { savePendingJob, removePendingJob, getPendingJobs } from '../lib/pendingJobs.js';+import { downloadImage } from '../../packages/studio/src/utils/downloadImage.js';function createInlineInstructions(type) {const el = document.createElement('div');@@ -1047,25 +1048,6 @@ export function ImageStudio() {});};- // --- Helper: Download image ---- const downloadImage = async (url, filename) => {- try {- const response = await fetch(url);- const blob = await response.blob();- const blobUrl = URL.createObjectURL(blob);- const a = document.createElement('a');- a.href = blobUrl;- a.download = filename;- document.body.appendChild(a);- a.click();- document.body.removeChild(a);- URL.revokeObjectURL(blobUrl);- } catch (err) {- // Fallback: open in new tab- window.open(url, '_blank');- }- };-// --- Load history from localStorage ---try {const saved = JSON.parse(localStorage.getItem('muapi_history') || '[]');