Converter Studio
Auto-convert product images to WebP or AVIF
Converter Studio for Medusa
Smaller, faster product images for your Medusa v2 store. This plugin converts product images to WebP, AVIF or JPG with the Converter Studio API. It runs on its own when you add images to a product, and you can also start it from the admin.
- Automatic. When a product is created or updated, its JPG, PNG, HEIC, TIFF and BMP images are converted in the background. The converted file takes the original's place in the product's gallery, thumbnail and variant thumbnails.
- HEIC from phones just works. Browsers other than Safari cannot show HEIC photos. The plugin turns them into WebP or JPG.
- Large photos are made smaller. Photos whose longer side is over 2560 pixels (phone and camera photos, often 5–10 MB) are scaled down to 2560 px, which still fills a sharp product page and its zoom. Change it with Copy to clipboard
maxSize, or turn it off. - Originals are kept. The original file stays in your storage, and its URL is saved in the image's metadata (Copy to clipboard
converter_studio_original_url). You can put the originals back with one click. - Safe for credits. Each image goes ahead only up to Copy to clipboard
maxCredits(default 1). If a converted JPG or PNG comes out larger than the original, the original stays. Before converting the whole catalog, the admin shows how many images would be converted and what that can cost, and lets you try 10 images first. When the account runs out of credits, the plugin stops, keeps the originals and tells you in the admin. - Admin. A product page widget shows each image's state and has Convert images and Restore originals buttons. A settings page (Settings → Converter Studio) shows your plan and remaining credits, can convert a sample or the whole catalog, and lists the latest conversions.
- Works with any file provider. Local, S3, MinIO, R2 and others: the plugin saves converted files through Medusa's File Module, so your storage setup stays the same.
- Privacy. EXIF details (camera, date, GPS location) are removed by default.
Requirements
- Medusa v2.11.2 or later (tested with 2.22.7 and 2.23.0)
- Node.js 20 or later
- A Converter Studio account and an API key. Create a key on your account page. A free account is enough to start.
Install
1npm install medusa-plugin-converter-studio
Add the plugin to Copy to clipboardmedusa-config.ts:
123456789101112module.exports = defineConfig({// ...plugins: [{resolve: 'medusa-plugin-converter-studio',options: {apiKey: process.env.CONVERTER_STUDIO_API_KEY,format: 'webp', // or "avif", or "jpg"},},],});
Put the key in your environment (for example Copy to clipboard.env), not in the code:
1CONVERTER_STUDIO_API_KEY=cvs_live_...
Then create the plugin's table, and restart Medusa:
1npx medusa db:migrate
New product images are now converted automatically. To convert the images you already have, open Settings → Converter Studio: it shows how many images would be converted. Click Try 10 images to see the savings first, then Convert all. Or use Convert images on a product's page.
Options
All options are optional.
Option Default What it does Copy to clipboardapiKey Copy to clipboardCONVERTER_STUDIO_API_KEY Your Converter Studio API key. Without one, the plugin does nothing and logs a warning. Copy to clipboardformat Copy to clipboard"webp" What images become: Copy to clipboard"webp", Copy to clipboard"avif" or Copy to clipboard"jpg". Copy to clipboardsources depends on Copy to clipboardformat Formats to convert. WebP: Copy to clipboardjpg, Copy to clipboardpng, Copy to clipboardheic, Copy to clipboardtiff, Copy to clipboardbmp. AVIF: the same plus Copy to clipboardwebp. JPG: Copy to clipboardheic, Copy to clipboardtiff, Copy to clipboardbmp (only formats browsers cannot show). Copy to clipboardgif can be added, but animation is not kept. Copy to clipboardquality Copy to clipboard"balanced" Copy to clipboard"high", Copy to clipboard"balanced" or Copy to clipboard"small". Copy to clipboardmaxSize Copy to clipboard2560 Shrinks images whose longer side is larger: Copy to clipboard2560, Copy to clipboard1920, Copy to clipboard1280 or Copy to clipboard800 pixels. Images are never made larger. Copy to clipboardnull (or Copy to clipboard0) keeps every image at its size. Copy to clipboardkeepMetadata Copy to clipboardfalse Keeps EXIF details (camera, date). The GPS location is still removed. Copy to clipboardmaxCredits Copy to clipboard1 The most credits one image may cost. A more expensive conversion is skipped and the original kept. Copy to clipboardautoConvert Copy to clipboardtrue Converts images when products are created or updated. Set to Copy to clipboardfalse to convert only from the admin. Copy to clipboardonlyIfSmaller Copy to clipboardtrue Keeps a JPG or PNG original when the converted file would be larger. HEIC, TIFF and BMP are always converted. Copy to clipboardconcurrency Copy to clipboard2 Images converted at the same time (1–5). Copy to clipboardtimeoutSeconds Copy to clipboard180 The longest one conversion may take. Copy to clipboardconversionOptions Copy to clipboard{} Further Converter Studio options, passed on unchanged (for example Copy to clipboard{ "maxKb": 300 } or Copy to clipboard{ "lossless": true }). A size set here (Copy to clipboardwidth, Copy to clipboardlongSide, Copy to clipboardscale, Copy to clipboardresizeWidth, Copy to clipboardresizeHeight) replaces the default Copy to clipboardmaxSize. Copy to clipboardapiUrl Copy to clipboardhttps://converter.studio/api The API's address. Change it only for testing.
Credits and pricing
Conversions use your Converter Studio account's credits, the same credits as on the website. Most images cost 1 credit. Free accounts get 25 credits a day, and paid plans include more credits each month. See converter.studio/pricing.
When the credits run out:
- the image that could not be converted, and the ones after it, keep their originals;
- the admin widget and the settings page say so, with a link to get more credits;
- automatic conversions pause for 30 minutes, then try again on the next product change. Click Convert images (or Convert all) once you have credits again.
A failed conversion costs nothing. Images already in the target format are never sent, so they cost nothing either. Converting an image whose result turns out larger (and is therefore not used) still costs its credit: the plugin cannot know beforehand whether a JPG or PNG will come out smaller. That happens mostly with small JPGs that are already well compressed; photos larger than Copy to clipboardmaxSize nearly always come out much smaller, because they are also scaled down.
Before converting the whole catalog, Settings → Converter Studio shows:
- how many images Convert all would send, in how many products, and the most it can cost (one credit an image);
- how many images it leaves alone for free (already in the target format, a format you did not choose, or an original kept after an earlier try);
- whether the account has fewer credits than that.
Try 10 images converts the first 10 of those images and reports how many were converted, how many kept their original, the credits spent (and how many of them on kept originals) and the space saved. Convert all then goes on with the rest: images converted or kept before are not sent again.
How it works
- A product is created or updated. A subscriber (Copy to clipboard
product.created, Copy to clipboardproduct.updated) starts the Copy to clipboardconverter-studio-convert-product-imagesworkflow in the background. The product itself is saved right away, with the originals. The plugin's own updates (a converted or restored image put in place) do not start it again, so converting one image or a sample converts only those. - The workflow locks the product, so only one run works on it at a time. It then picks the images that need converting.
- Each image is downloaded from its URL and sent to Converter Studio (Copy to clipboard
POST /v1/uploads, Copy to clipboardPOST /v1/conversions). When the result is ready, it is downloaded and saved with your File Module provider. - The workflow reads the product again and swaps the URLs of images that have not changed in the meantime, using Medusa's Copy to clipboard
updateProductsWorkflow. Image ids stay the same, so variant images are kept. - Every attempt is recorded in the Copy to clipboard
converter_studio_image_conversiontable, which the admin reads.
A few seconds pass between saving a product and its converted images appearing. Storefronts showing the product in that time get the original.
The workflows are exported for your own code:
123456import {convertProductImagesWorkflow,restoreProductImagesWorkflow,} from 'medusa-plugin-converter-studio/workflows';await convertProductImagesWorkflow(container).run({ input: { product_id, trigger: 'manual' } });
Admin API routes
All routes require an admin login.
Route Purpose Copy to clipboardGET /admin/converter-studio Options in effect (without the key), plan and credits Copy to clipboardGET /admin/converter-studio/products/:id Each image's state Copy to clipboardPOST /admin/converter-studio/products/:id/convert Convert the product's images (Copy to clipboard{ image_ids? }), in the background Copy to clipboardPOST /admin/converter-studio/products/:id/restore Put the originals back (Copy to clipboard{ image_ids? }) Copy to clipboardGET /admin/converter-studio/conversions Latest conversions (Copy to clipboardlimit, Copy to clipboardoffset, Copy to clipboardstatus) Copy to clipboardGET/Copy to clipboardPOST /admin/converter-studio/bulk Convert every product's images (Copy to clipboard{ action: "start" | "cancel", limit? }; Copy to clipboardlimit: try only that many images, 1–1000) Copy to clipboardGET /admin/converter-studio/bulk/estimate What converting every product's images would send and can cost, before anything is spent
Good to know
- Product feeds. Some marketplaces and ad catalogs accept only JPG or PNG. If you send product feeds, use Copy to clipboard
format: "jpg", or read the original from the image's Copy to clipboardconverter_studio_original_urlmetadata. - Demo data. With the plugin active, seeding demo products converts their images too, which uses credits. Set Copy to clipboard
autoConvert: falsewhile seeding if you don't want that. - Changing Copy to clipboard
formatlater (for example from WebP to AVIF) converts the images again from their originals, not from the earlier result. - Restored images are left alone by automatic conversions. Convert images converts them again.
- Several servers. Converting is safe across servers and workers (a lock per product). The progress of Convert all is kept by the server that runs it.
- Storage. Converted files are stored next to the originals. Restoring deletes the converted file.
Privacy
Product images are sent to Converter Studio to be converted, and that is their only use. Uploads are deleted after conversion, and results after 6 hours. See the privacy policy and terms. Mention Converter Studio in your store's privacy policy as a service that processes product images.
Support
Write to support@converter.studio, or report a problem at github.com/tariksucu/medusa-plugin-converter-studio/issues. API documentation: converter.studio/developers.
Development and releases
1234npm cinpm run typechecknpm test # unit tests, no networknpm run build # .medusa/server
Copy to clipboardnpm run test:integration runs the conversion code against a Converter Studio API: set Copy to clipboardCONVERTER_STUDIO_TEST_API_URL (for example Copy to clipboardhttps://converter.studio/api) and Copy to clipboardCONVERTER_STUDIO_TEST_API_KEY_FILE (a file holding an API key). It spends a few credits.
Releases are published to npm by this repository's GitHub Actions workflow (Copy to clipboard.github/workflows/publish.yml) when a version tag is pushed, with an npm provenance statement: the package page on npm shows the commit and the workflow each version was built from.
License
MIT
