Why does gm always export all layers of the input image?

0

Given the following command line:

'/usr/bin/gm' convert 'directory/filename.psd[0]' filename.jpg

I will always receive all layers from the .psd as output:

$ ls something*
something.jpg.0  something.jpg.1  something.jpg.2

The documentation clearly states:

Use a square-bracket syntax to indicate which frame or frames you want. For example,

gm convert "Image.gif[0]" first.gif
Will extract the first image (scene 0) from a GIF animation. Be sure to surround the file specification with quotation marks, to prevent the shell from interpreting the square brackets.

I tried messing around with it in many ways, but I always end up with the same result.

Version information:

GraphicsMagick 1.3.12 2010-03-08 Q8 http://www.GraphicsMagick.org/
Copyright (C) 2002-2010 GraphicsMagick Group.
Additional copyrights and licenses apply to this software.
See http://www.GraphicsMagick.org/www/Copyright.html for details.

Feature Support:
  Thread Safe              no
  Large Files (> 32 bit)   yes
  Large Memory (> 32 bit)  no
  BZIP                     yes
  DPS                      no
  FlashPix                 no
  FreeType                 yes
  Ghostscript (Library)    no
  JBIG                     no
  JPEG-2000                no
  JPEG                     yes
  Little CMS               yes
  Loadable Modules         yes
  OpenMP                   no
  PNG                      yes
  TIFF                     yes
  TRIO                     no
  UMEM                     no
  WMF                      yes
  X11                      no
  XML                      yes
  ZLIB                     yes

Host type: i686-pc-linux-gnu

Configured using the command:
  ./configure  '--prefix=/usr' '--build=i686-pc-linux-gnu' '--host=i686-pc-linux-gnu' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--datadir=/usr/share'                                                                  '--sysconfdir=/etc' '--localstatedir=/var/lib' '--docdir=/usr/share/doc/graphicsmagick-1.3.12' '--htmldir=/usr/share/doc/graphicsmagick-1.3.12/html' '--enable-shar                                                                 ed' '--enable-largefile' '--without-included-ltdl' '--without-frozenpaths' '--without-gslib' '--with-quantum-depth=8' '--with-fontpath=/usr/share/fonts' '--with-gs                                                                 -font-dir=/usr/share/fonts/default/ghostscript' '--with-windows-font-dir=/usr/share/fonts/corefonts' '--with-perl-options=INSTALLDIRS=vendor' '--disable-ccmalloc'                                                                  '--disable-prof' '--disable-gcov' '--disable-magick-compat' '--disable-openmp' '--with-bzlib' '--with-magick-plus-plus' '--without-fpx' '--without-jbig' '--with-jp                                                                 eg' '--without-jp2' '--with-lcms' '--with-modules' '--with-perl' '--with-png' '--with-xml' '--without-threads' '--with-tiff' '--with-ttf' '--with-wmf' '--without-x                                                                 ' '--with-zlib' 'build_alias=i686-pc-linux-gnu'

Final Build Parameters:
  CC       = i686-pc-linux-gnu-gcc -std=gnu99
  CFLAGS   = -O2 -march=i686 -fomit-frame-pointer -Wall
  CPPFLAGS = -I/usr/include/freetype2 -I/usr/include/libxml2
  CXX      = i686-pc-linux-gnu-g++
  CXXFLAGS = -O2 -march=i686 -fomit-frame-pointer
  LDFLAGS  = -Wl,-O1 -Wl,--as-needed -L/usr/lib -L/usr/lib
  LIBS     = -llcms -lfreetype -lbz2 -lz -lm

Der Hochstapler

Posted 2012-03-08T22:48:50.423

Reputation: 77 228

Answers

1

It sounds like you need to flatten the PSD to a single layer. I would try adding the -flatten flag to your line. This may convert all of the layers to one JPG instead of multiple files.

Also, it looks like by adding the [0] you're telling it to loop through the layers as it would the sequence of images in a gif file.

kobaltz

Posted 2012-03-08T22:48:50.423

Reputation: 14 361

While that might work (and I will be thankful if it does), why doesn't my approach work? It seems like I use it exactly as described in the documentation. – Der Hochstapler – 2012-03-08T23:08:46.110

Because by adding the [0], it looks like a "command" to loop through the possible images/layers in the specified file to export several files based on that information. That may be very useful to some, but counterproductive to others. – kobaltz – 2012-03-08T23:11:02.767

The main problem, I believe is that your documentation is to split an Animated GIF image into several files. Almost like taking a movie and making several images from each frame of the movie. – kobaltz – 2012-03-08T23:11:50.600

What kind of makes me doubt this, is the fact if I use ImageMagicks convert for the same purpose, it outputs a single file when using [0] and multiple files when not providing [0]. – Der Hochstapler – 2012-03-08T23:15:20.377