I've been working on a theoretically simple web service to convert PSD or AI files to jpeg, png or some web-compatible format.

I was able to successfully use ImageMagic's convert -flatten sample.ai sample-ai.jpg command, but consistently getting "invalid header" for various attempts using PhotoShop PSDs. I'm assuming ImageMagick prefers it's own or GIMP-saved PSD files, though perhaps I'm missing something there.

Also tried installing NConvert, but had problems with glibc version on client's CentOS 5.8, which I'm not permitted to change.

In any case, GIMP seems to have good PSD support. More than enough to flatten an image and save it. They've also recently updated their PSD parser. I've seen a similar question but

  1. that's on windows,
  2. they didn't really answer anything for GIMP,
  3. neither convert nor mogrify works for me

mogrify: Improper image header 'Test1.psd'.

So, does anyone know how to write a conversion script in Gimp via command line? I'm looking at this article trying to figure out the commands, but I think my trouble is I don't know ScriptFu worth anything.

It would also be tremendously helpful if I can echo back the dimensions of the original PSD, but I can get these from the resulting file fairly easily with a second step.

  • 2
    Interesting that you say that the Gimp has great support for PSD. I have had a lot of problems loading any PSD files with the Gimp, at least under Linux (I don't really use MS-Windows). Now on the other hand I have more luck with convert to convert PSD files, something like this: convert sample.psd[0] sample.jpg. The [0] index is to get the resulting image (all the layers merged on in image.) Jul 8, 2014 at 20:17
  • 1
    The [0] index is to get the resulting image (all the layers merged on in image.) ....... GREAT! Thanks!!
    – FireFoxII
    Dec 3, 2018 at 19:52

1 Answer 1


I have just created a Node module that deals with PSD files from the CLI. You may use it with as many files as you want with just one command.

As far as my tests went, GIMP is not really a solution and has a poor understanding of modern PSD files, and NodeJS happen to have a great new package that deals with the Photoshop format.

Instructions from the GitHub repo:

Install it:

npm install -g psd-cli

Convert myfile.psd to a new myfile.png :

psd myfile.psd

I hope you find this useful! The package is pretty new and other cool features will be added soon. Any feature requests and help with improving the code is appreciated :)

  • ooh fancy, thanks for the update. indeed the gimp situation was "mildly workable" but far from optimal plus the license with psd.js is nicer. Nov 29, 2015 at 9:05
  • Currently it does nothing, but convert works.
    – peterh
    Jul 3, 2018 at 10:50
  • Looks like this project is not maintained anymore. Mar 17, 2020 at 5:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.