converter-studio / craft-converter-studio
Converts iPhone photos (HEIC), camera RAW photos, videos, office documents and audio into JPG, MP4, PDF and MP3 as they are uploaded, through converter.studio.
Package info
github.com/tariksucu/craft-converter-studio
Type:craft-plugin
pkg:composer/converter-studio/craft-converter-studio
Requires
- php: >=8.2
- craftcms/cms: ^5.0.0
Requires (Dev)
- craftcms/ecs: dev-main
- craftcms/phpstan: dev-main
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^10.5
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Converts the files that browsers and Craft cannot use well into ones they can, as they are uploaded:
- iPhone photos (HEIC, HEIF) and camera RAW photos (CR2, NEF, ARW, DNG) become JPG. Only Safari shows HEIC, and many servers cannot make thumbnails or transforms of it. Craft does not accept RAW files at all.
- Videos (MOV, AVI, MKV, WMV, FLV, 3GP) become MP4 (H.264), which plays in every browser.
- Office documents (DOC, DOCX, ODT, RTF, PPT, PPTX, ODP, XLS, XLSX, ODS) become PDF.
- Audio (WAV, AIFF, FLAC, WMA, and optionally M4A, OGG, Opus, AAC) becomes MP3.
The work is done by converter.studio through its REST API, with the credits of your converter.studio account. Nothing has to be installed on your server: no ImageMagick with HEIC support, no FFmpeg, no LibreOffice.
Requirements
- Craft CMS 5.0 or later, PHP 8.2 or later.
- A converter.studio account and API key. Free accounts get credits every day; most photos and documents cost 1 credit; audio and video are priced by their length, and video also by its frame size. See pricing.
- Craft's queue running (it runs by itself on control panel requests, or with
php craft queue/listen), for conversions after uploading and by hand.
Installation
From the Plugin Store: search for “Converter Studio” in your control panel and press “Install”.
With Composer:
composer require converter-studio/craft-converter-studio php craft plugin/install converter-studio
Setup
-
Create an API key on your converter.studio account page.
-
Put it in your
.envfile:CONVERTER_STUDIO_API_KEY=cvs_live_…
-
In Settings → Plugins → Converter Studio, the API key field already says
$CONVERTER_STUDIO_API_KEY; the page shows your plan and credits once the key works. You can type the key itself instead, but it then ends up in the project config (config/project/*.yaml) and in your repository. -
Give the user groups whose uploads should be converted the permission “Have uploads converted by Converter Studio” (admins have it). Give “Convert existing assets with Converter Studio” to those who may convert existing files.
Every setting can also be set in config/converter-studio.php, which wins over the control panel:
<?php return [ 'apiKey' => '$CONVERTER_STUDIO_API_KEY', // Credits one file may cost without asking. 'maxCredits' => 20, 'rules' => [ 'video' => ['mode' => 'background', 'height' => '720'], 'office' => ['mode' => 'manual'], ], ];
How it works
Each kind of file has a rule with a mode:
| Rule | Default | What happens |
|---|---|---|
| HEIC → JPG, RAW → JPG | While uploading | The upload waits (a few seconds) and the asset is a JPG from the start. |
| Video → MP4 | After uploading, in the queue | The file is stored as it came, then a queue job converts it in place. |
| Office → PDF, Audio → MP3 | Only by hand | Nothing happens on upload; convert existing files with the asset action or the console command. |
- In place means the asset keeps its id, title, alt text, field values and relations, so every entry that uses it shows the new file. With Keep originals on (the default), the original is kept as an asset of its own in the same folder, titled “… (original)”.
- Existing files are never converted by themselves. Select them on the Assets page and choose Convert with Converter Studio from the actions menu, or run the console command below.
- Only uploads by people with the permission are converted, and never uploads made by console commands or queue jobs (imports, migrations), so installing the plugin never spends credits on a whole library.
- Assets fields: a file is not converted when an Assets field it is uploaded to, or used in, does not accept the result's kind of file (a PDF in a field that only takes Word documents).
- RAW files: Craft does not accept CR2, NEF, ARW or DNG uploads. While the RAW rule converts while
uploading, the plugin lets them in only to convert them: one that cannot be converted is refused, so a RAW
file is never stored. For other rules, add the extensions you want to
extraAllowedFileExtensionsinconfig/general.php(Craft already takes HEIC, MOV, AVI, WMV, FLV, WebM, the Office formats but ODP, WAV, AIFF, M4A, OGG and WMA).
Credits and errors
- A conversion that would cost more than Credits a file may cost without asking (20 by default) is not charged: it waits for approval in Utilities → Converter Studio (an upload is then stored as it came).
- When the account is out of credits, or the key does not work, conversions pause (until the credits renew, or for an hour) and go on by themselves; Resume now in the utility starts them at once.
- If converting while uploading fails, the original is stored and the conversion goes on in the queue when it can. A RAW upload is refused instead, with the reason.
- Large files are sent in 16 MB parts; a queue job works for up to four minutes and hands over to the next one, so long videos never need a long request. A lost answer never makes a file be paid for twice.
Utilities → Converter Studio
The account's plan and credits, every conversion with its status and cost, and buttons to approve, retry or cancel. The utility's badge counts conversions that wait for approval.
Console commands
php craft converter-studio/status # the key's state, credits, conversions by status php craft converter-studio/convert --volume=uploads --rule=heic --dry-run # what would be converted php craft converter-studio/convert --volume=uploads --rule=heic --limit=50 # queue them php craft converter-studio/convert --asset-id=12,13 --now # convert in this process, without the queue
Limits
- Craft's own upload limit (
maxUploadFileSize, 16 MB by default) and PHP's (upload_max_filesize,post_max_size) apply before the plugin sees a file; raise them for videos and RAW photos. - converter.studio's plan limits apply (file size, video length); the error says which.
- Converted files are not transformed further: Craft's image transforms still make your WebP/AVIF sizes from the JPG.
Privacy
The plugin sends the files it converts, with their names and sizes, to converter.studio, and nothing else about your site. converter.studio deletes each upload once it is converted and each result after six hours. No request is made until an API key is set. Mention converter.studio in your site's privacy policy if people upload personal files. See converter.studio's privacy policy and terms.
Support
Questions and bugs: GitHub issues or support@converter.studio.