PNG (Portable Network Graphics) is a popular file format known for its lossless compression and ability to handle transparent backgrounds. However, PNG files can be relatively large, which can be problematic when uploading images to websites, sending them via email, or storing many files on your device. Compressing PNG files can help you reduce their size while retaining their quality, and if you’re using a Mac, there are various ways to do it.
In this article, we’ll cover two different methods to compress PNG images on a Mac:
- Using a graphical user interface (GUI) tool.
- Using the Terminal (command-line) with free utilities.
Before we dive into the details, check out our XConvert’s own PNG compressor to compress your PNG files online.
Method 1: Compressing PNG Images Using Preview (GUI Method)
The Preview app on macOS is a built-in tool that can handle basic image editing tasks, including compression. Here’s how you can use it to reduce the file size of a PNG image.
Step-by-Step Instructions:
- Open the PNG File in Preview:
- Locate the PNG image you want to compress.
- Right-click on the file and select Open With > Preview.
- Alternatively, you can double-click the image, as Preview is often the default image viewer on macOS.
- Adjust the Image Size:
- In Preview, go to the Tools menu on the top bar and select Adjust Size.
- A dialog box will appear, allowing you to resize the image.
- You can reduce the resolution or dimensions of the image to compress it. For example, reducing the width and height will lower the file size.
- Make sure the Scale proportionally option is checked to maintain the aspect ratio.
- Click OK to apply the new size.
- Export the Image:
- After adjusting the size, go to File > Export.
- In the export dialog, choose PNG as the format.
- Drag the Quality slider to adjust the image compression level. Lowering the quality will reduce the file size but may affect the image’s appearance.
- Select a location to save the compressed image, then click Save.
Pros and Cons:
- Pros:
- Easy to use and no need for additional software.
- Free and built-in on macOS.
- Cons:
- Limited control over advanced compression settings.
- May not achieve maximum compression for very large PNG files.
Method 2: Compressing PNG Files Using Terminal (Command-Line Method)
For those comfortable with the command line or looking for more advanced compression, macOS Terminal can be a powerful way to compress PNG files. One of the most efficient tools to achieve this is ImageOptim, which can be installed on macOS. However, we’ll use a command-line tool called pngquant
, a popular and highly effective PNG compressor.
Step-by-Step Instructions for Terminal Method:
Step 1: Install Homebrew (if not already installed)
First, you’ll need Homebrew, a package manager for macOS, to install pngquant
. If you don’t have Homebrew, install it by running the following command in Terminal:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Step 2: Install pngquant
Once Homebrew is installed, you can easily install pngquant
by typing:
brew install pngquant
This will install pngquant
, a popular tool specifically for compressing PNG files.
Step 3: Compress a PNG File Using pngquant
Now that you have pngquant
installed, you can compress PNG files using Terminal. Here’s the basic command to compress a PNG file:
pngquant --quality=65-80 --ext .png --force your-image.png
--quality=65-80
: Specifies the range of quality. A higher number gives better quality but a larger file. A lower number reduces quality and file size.--ext .png
: Keeps the original file extension.--force
: Forces overwriting of the original file.your-image.png
: Replace this with the actual path to your PNG file.
For example, if you have a PNG file named image.png
on your desktop, the command would look like this:
pngquant --quality=65-80 --ext .png --force ~/Desktop/image.png
Step 4: Verify the Compressed Image
After running the command, your original image will be replaced with the compressed version. If you want to keep the original, use a different file name by adding a suffix using the --ext
option:
pngquant --quality=65-80 --ext -compressed.png --force ~/Desktop/image.png
This will create a new file named image-compressed.png
on your desktop, preserving the original image.
Pros and Cons:
- Pros:
- Achieves high levels of compression while preserving good quality.
- More customizable and powerful for advanced users.
- Cons:
- Requires using the command line, which might not be beginner-friendly.
- Must install additional software (pngquant via Homebrew).
Comparison of Both Methods
Feature | Preview (GUI Method) | Terminal (pngquant) |
---|---|---|
Ease of Use | Beginner-friendly, no installation required | Requires Terminal knowledge and installation of pngquant |
Compression Quality | Basic image compression by resizing and lowering quality | Advanced compression with higher optimization for PNG |
Control over Compression | Limited to resolution and quality adjustments | Full control over compression quality, advanced settings |
Speed | Fast and simple | Requires additional steps but efficient for bulk compression |
Preserving Image Quality | Decent, but quality can degrade significantly with higher compression | Balances file size reduction and quality better |
Conclusion
Compressing PNG images on a Mac can be done with ease using different methods depending on your preferences and technical expertise. For casual users, the Preview app provides a simple and effective way to reduce image size by resizing and adjusting quality. However, if you need more control over the compression process or are working with many PNG files, the Terminal method using pngquant
is a powerful option.
Whether you prefer a graphical tool or command-line approach, both methods can help you achieve smaller PNG files that are optimized for web use, email, or storage without sacrificing much quality.
Happy compressing!
Featured photo by Alexander Dummer on Unsplash