#185 gm always converts all layers of input image


I'm trying to convert the first layer of a given .psd file using:
'/usr/bin/gm' convert 'directory/filename.psd[0]' filename.jpg
But it will always write out ALL layers of the given file, resulting in .0, .1 and .2 files.

Our hosting provider only gives us 1.3.12, so if this was already fixed, please let me know in what version so I can advise them to upgrade. Thanks


  • Oliver Salzburg

    Oliver Salzburg - 2012-03-08
    • labels: --> Command Line Handling
  • Bob Friesenhahn

    Bob Friesenhahn - 2012-03-09

    The layers of a PSD are intended to be composited to produce a human-usable image. The use of layers is an artifact of Photoshop preserving the flexibility to add or remove parts of the image content. As such there is only one "image" represented by a PSD even though GM returns a list of layers (which need to be flattened for viewing with -flatten). Regardless, GraphicsMagick could be modified to do what you want.

    A workaround which might not seem very nice (but does work) is to do something like:

    gm convert 4layers.psd tiff:- | gm convert '-[0]' frame1.tiff

    GraphicsMagick's PSD support is not very good. ImageMagick's support is better but very slow. The best support I have seen in the open source world is provided by The GIMP.

  • Oliver Salzburg

    Oliver Salzburg - 2012-03-09

    Thanks for that information.
    I'm just looking into an issue in a graphics layer of a much larger application. In that layer GraphicsMagick and ImageMagick are supposed to work interchangeably.
    That's where the [0] notation comes from.
    When issuing the same command using ImageMagicks convert, the result is as expected, a single file. That's why I assumed, the same would be true for ImageMagick.

  • Bob Friesenhahn

    Bob Friesenhahn - 2012-03-09

    I understand the expectation. ImageMagick does not precisely return the PSD layers as the exist in the file. When foo.psd[0] is requested, it returns a fully-rendered ("flattened") representation of the PSD. GraphicsMagick does not do that.

    After 9-1/2 years of being independently developed, one should expect some feature disparity between the two packages.

  • Oliver Salzburg

    Oliver Salzburg - 2012-03-09
    • status: open --> closed
  • Oliver Salzburg

    Oliver Salzburg - 2012-03-09

    Ah, interesting. Thanks for that information.
    I went ahead and just pushed the -flatten option to the layer now. But at least now I know why it's the correct solution :)
    Thanks again.


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks