Skip to content

How to convert SVG to PNG on a Mac

Slides, documents, app stores and a lot of upload forms want PNG, not SVG. macOS can make one from Terminal with Quick Look, the same thing that previews files in Finder. convt converts one SVG or a whole folder of them at the size you pick, keeps transparency, and does it on your Mac without uploading anything.

Updated

The short version

Built in: qlmanage -t -s 1000 -o . logo.svg in Terminal. At a set size, or a whole folder: convt icons --to png -r -o png --dpi 192.

Convert SVG to PNG with Quick Look in Terminal

From the qlmanage manual page (type man qlmanage in Terminal). We haven't run it on a Mac ourselves.

macOS ships qlmanage, a Terminal tool for Quick Look, the preview you get when you press Space on a file in Finder. Its -t option saves a thumbnail as a PNG file. Open Terminal, go to the folder with the SVG and run:

qlmanage -t -s 1000 -o . logo.svg

-s 1000 asks for a 1000-pixel thumbnail and -o . saves it in the current folder. The file is named logo.svg.png, so rename it if the extra .svg gets in the way.

It works for a quick copy, but it's a thumbnail tool: the manual describes it as the "Quick Look Server debug and management tool". It makes one thumbnail per file you name, and the manual lists no option for the background or for subfolders. For those, use convt.

Convert an SVG to PNG with convt

Run with the released convt 0.5.0 command-line tool on Linux, on SVGs we made. convt renders SVG with resvg, the same engine in the Mac and Windows installs.

convt is a desktop app for Mac and Windows that converts files on your computer, with a command-line tool in the same install. Local conversions never upload your files.

Install it from the download page or GitHub releases. Homebrew also puts the convt command in Terminal:

brew tap opencoredev/convt https://github.com/opencoredev/convtbrew install --cask convt

In Terminal, go to the folder with the SVG and run this. If you installed from the disk image, type /Applications/convt.app/Contents/MacOS/convt instead of convt.

convt logo.svg --to png
Output
logo.svg -> ./logo.png

The PNG is written next to the SVG, which stays as it was. The same command makes a JPG, WebP or another image format: --to jpg or --to webp. Run convt targets logo.svg to list them all.

Pick the size of the PNG

An SVG is drawn from shapes, so it can become a PNG of any size without going blurry. convt starts from the width and height written in the SVG, counted at 96 pixels per inch, the way a browser shows it. Two options change that:

--dpi 192
Twice the size the SVG sets, which is the @2x copy for Retina screens. 288 is three times. Our 120 × 80 logo came out at 375 × 250 with --dpi 300. convt accepts 18 to 1200.
--max-size 512
Caps the longest edge at 512 pixels and keeps the shape. It only makes the PNG smaller, never bigger.

Together they give a set size: raise the resolution, then cap it. A 24 × 24 icon came out at exactly 256 × 256 with this command:

convt icon.svg --to png --dpi 1200 --max-size 256

1200 is the most convt takes, which is 12.5 times the SVG's own size. A 24-pixel icon can reach 300 pixels that way, so for a bigger PNG from a small icon, set a larger width and height in the SVG file first. With a capped size the edge can land a pixel over: our logo capped at 1000 came out 1001 × 667.

Keep it transparent, or fill the background

By default the PNG keeps the SVG's transparent areas, which is what you want for a logo on a colored slide. To fill them, add --background with white, black or a color code:

convt logo.svg --to png --background whiteconvt logo.svg --to png --background "#ff8800"convt logo.svg --to jpg --dpi 300

JPG has no transparency, so a JPG gets a white background unless you pick another color.

Convert a folder of SVGs to PNG

Give convt a folder instead of a file. -r includes subfolders and -o png writes the PNGs into a new folder with the same subfolders, so an icon set keeps its layout. Here every icon comes out at twice its size:

convt icons --to png -r -o png --dpi 192
Output
icons/sub/c.SVG -> png/sub/c.png
icons/a.svg -> png/a.png
icons/sub/b.svg -> png/sub/b.png
3 converted, 0 failed

The 24 × 24 icons came out at 48 × 48. A folder input converts every file convt can turn into PNG, so photos in the folder get converted too. To shrink a set to one size, use --max-size instead.

What came out of our test

Size
Without options, the PNG has the width and height the SVG sets: our 120 × 80 logo became a 120 × 80 PNG.
Transparency
Kept. Areas the SVG doesn't paint stay transparent in the PNG.
Subfolders
With -r and -o, icons/sub/b.svg became png/sub/b.png.
Capital letters
A file named c.SVG converted like the others.
Existing PNGs
A PNG already in the folder was skipped, not converted again.
Name clashes
Running the same command twice wrote logo (1).png next to logo.png. It doesn't overwrite the first one.

Questions

Why is the text missing from my PNG?
An SVG that names a font draws its text with that font from your computer. If the font isn't installed, the text can drop out: in our Linux test, a line of text in a font the computer didn't have was missing from the PNG, and the same line in an installed font came out. Install the font, or turn the text into outlines in the app that made the SVG.
Does this work on Windows?
Yes, with the same options. The Windows installer doesn't add convt to your PATH, so in PowerShell type its full path: & "$env:LOCALAPPDATA\Programs\convt\convt.exe" icons --to png -r -o png --dpi 192.
Can convt turn a PNG into an SVG?
No. Tracing a picture into shapes is a different job, and convt 0.5.0 doesn't offer it. It doesn't make a PDF from an SVG either. For photos, see WebP to PNG or JPG.
Does convt upload my files?
Not for local conversions. The app and the command-line tool convert on your computer. The app uploads a file only if you pick Cloud for a job, which is part of Desktop + Cloud. For scripts and the other commands, see the command-line page and the formats page.

Send feedback

A bug, a format you need, anything. It goes straight to the convt team.