Page 1 of 1

photoshop tiff files - counting/exporting layers to jpg

Posted: 2009-03-09T10:48:23-07:00
by russellbarnhart
hi. ive been struggling this all day, so i figured i'd ask. all the following is taking place via the command line.

here is the output of 'convert -version'
Version: ImageMagick 6.4.9-10 2009-03-09 Q16 OpenMP http://www.imagemagick.org
im using version 3.8.2 of libtif

the image im testing with is here:
http://itsalmostreal.com/gnu/imagemagick/test.tif

here is a screenshot of the file open in photoshop, showing the layers:
http://itsalmostreal.com/gnu/imagemagick/ps_grab.png

here is a screengrab of the settings used when i save the file (though i have tried every other combination and had the same results):
http://itsalmostreal.com/gnu/imagemagic ... ttings.png

here are the commands and results that im running
identify command: identify -format "%[scenes]" test.tif
result:
identify: test.tif: unknown field with tag 37724 (0x935c) encountered. `TIFFReadDirectory' @ tiff.c/TIFFWarnings/526.
identify: test.tif: unknown field with tag 40961 (0xa001) encountered. `TIFFReadCustomDirectory' @ tiff.c/TIFFWarnings/526.
identify: test.tif: unknown field with tag 37724 (0x935c) encountered. `TIFFReadDirectory' @ tiff.c/TIFFWarnings/526.
0

i understand that the 3 errors are most-likely just proprietary tag read errors, and actually have no effect on the outcome. its the 0 that bothers me. the file definitely has 3 layers, so im not sure why its telling me 0.

convert command: convert test.tif[2] layer_2.jpg
result: yields the same tag read errors, and creates a file with all 3 layers merged.

can anyone provide me with any insight? my main goal is to be able to take a multilayer tiff file, count the number of layers, and then output a thumbnail of each layer.

is this going to be possible? i feel like i must be making a silly mistake. thanks for any and all help. its greatly appreciated.

Re: photoshop tiff files - counting/exporting layers to jpg

Posted: 2009-03-09T10:52:42-07:00
by fmw42
Your original file is inaccessible for our testing. It gives a FORBIDDEN error. Check the permissions.

Re: photoshop tiff files - counting/exporting layers to jpg

Posted: 2009-03-09T10:56:59-07:00
by russellbarnhart
sorry about that. i changed the permissions and the file is accessible now. thanks.

Re: photoshop tiff files - counting/exporting layers to jpg

Posted: 2009-03-10T16:56:03-07:00
by russellbarnhart
anyone have any ideas regarding this?

Re: photoshop tiff files - counting/exporting layers to jpg

Posted: 2009-03-10T17:06:45-07:00
by magick
You are getting the scene number instead of the number of scenes. This bug is fixed in the latest release of ImageMagick, available sometime tomorrow). Thanks for the problem report.

Re: photoshop tiff files - counting/exporting layers to jpg

Posted: 2009-03-18T05:54:11-07:00
by russellbarnhart
ive just installed from source the latest version (6.5.0-1) and i still have the same issue.

does imagemagick recognize the layers in tif files created by photoshop?

see page 11 of http://partners.adobe.com/public/develo ... toshop.pdf

Re: photoshop tiff files - counting/exporting layers to jpg

Posted: 2009-03-18T10:43:46-07:00
by fmw42
Testing a simple case:

create 3 frame gif
convert rose: rose: rose rose3.gif

get info in various ways:

identify rose3.gif
rose3.gif[0] GIF 70x46 70x46+0+0 8-bit PseudoClass 256c 10.6kb
rose3.gif[1] GIF 70x46 70x46+0+0 8-bit PseudoClass 256c 10.6kb
rose3.gif[2] GIF 70x46 70x46+0+0 8-bit PseudoClass 256c 10.6kb

identify -format "%[scenes]" rose3.gif
333

identify -format "%[scenes]\n" rose3.gif
3
3
3

identify -format "%[scene]\n" rose3.gif
0
1
2

So strangely, the second to last method, tells you for each frame that there are 3 frames in the image.

However, the last one, tells you the number of each frame. So you can get the last value and add one to it to compute the total frames.

I downloaded your test.tif file and it has only one frame when I open it in Mac Preview. When I try to do

identify test.tif

it chokes my system.

Re: photoshop tiff files - counting/exporting layers to jpg

Posted: 2015-05-07T09:33:38-07:00
by visitor x
To extract all layers to jpgs, you can do something like:

Code: Select all

for i in $(identify -format "%[scene] " <filename>.tiff); do convert <filename>.tiff[$i] <extracted-filename>-$i.jpg; done 
(ImageMagick 6.8.9-9 Q16 i686 2015-01-06)

I've changed "%[scene]\n" for "%[scene] ", so this is equivalent to do

Code: Select all

for i in 0 1 2 4 5 6 7 etc; do ... done
More loops examples: http://www.cyberciti.biz/faq/bash-for-loop/

Hope it helps!
Andrrr