There are many ways you can work with a PSD file without the need of purchasing or installing Photoshop. This includes editing PSD files online, using free Photoshop alternatives such as GIMP or extracting images from PSD layers using free command line utilities that we will show you in this post. The command line conversion of PSD file to PNG and JPG image can also be useful when you want to batch convert PSD files i.e. export images in bulk.
We will show you two different command line utilities that are capable of converting PSD files to PNG/JPG from the terminal. Both of them are free and available on all platforms including Windows, Mac OS and Linux. Let us see them in action and learn how to export PSD images.
PSD to PNG/JPG using ImageMagick CLI
ImageMagick includes a number of command-line utilities for manipulating images and it can be downloaded and installed on almost all platforms. Head over to their download page and find the download file that is suitable for your operating system and install ImageMagick using it.
Once installed, ImageMagick would add its tool into the PATH of your command line and you will be able to run ‘magick’ command in your terminal. You can read about the different command line options that ImageMagick provides. Below, we are presenting the commands that will export images from PSD files.
Convert single PSD to PNG or JPG
If your file name is psd-file.psd then you need to specify the name along with a  as shown below to export the PSD into image. If you don’t add  to the file name, all the objects and layers will get exported. To specify the output format, simply use the right extension in the output file name as shown below
$ magick 'psd-file.psd' png-file.png $ magick 'psd-file.psd' jpg-file.jpg
Batch convert PSD to PNG or JPG
To batch convert a set of PSD files, you can use an ‘*’ to match all the PSD files in the current directory. Additionally, specify ‘%03d’ to the output file name to generate out files in numbered fashion such as out-file-001.png, out-file-002.png, out-file-003.png and so on.
$ magick '*.psd' out-file-%03d.png
PSD to PNG using psd-cli
The second command line utility is based on Node.js and requires you to have it installed on your system as a pre-requisite. Once you have Node.js installed, you can install psd-cli using the following command.
$ npm install -g psd-cli
Now, you will be able run the ‘psd’ command in your terminal and convert PSD files into PNG as shown below:
$ psd path/to/psd_file.psd -c
This will export and create a psd-file.png in the same directory as the PSD file. This utility is based on PSD.js, which is a Photoshop PSD file parser for NodeJS and browsers. You can use PSD.js to create advance scripts to manipulate and convert PSD files as you desire.
We showed you two different command line utilities for converting PSD files into PNG and JPG images. Out of these two ImageMagick is quite powerful and is capable of doing a large variety of image manipulations including resizing, watermarking, combining etc. of images.
We have covered more command line utilities that can help you with day to day tasks:
- Test Internet Speed from Command Line
- Check Bitcoin Price from Command Line
- How to Use WHOIS Command in Windows 10