Page 1 of 1
How to specify a complete path with layer extraction?
Posted: 2019-01-21T12:10:44-07:00
by Fredrik M
Hi.
Quite new to using ImageMagick from the command line and i have tried for hours but can't get it right.
This works:
convert /path/to/my/file.tif /path/to/my/file.jpg
If i am located in the directory where my file is located this also works:
convert file.tif[2] extractedLayer.jpg
Yes i want to get the second layer only from my tif file.
But i can't figure out how i get this to work:
convert /path/to/my/file.tif[2] /path/to/my/file.jpg
In addition to the above i have tried
convert "/path/to/my/file.tif[2]" /path/to/my/file.jpg and
convert '/path/to/my/file.tif[2]' /path/to/my/file.jpg and a bunch of other ways but i only get this error message.
convert: unable to open image `/path/to/my/file.tif': No such file or directory @ error/blob.c/OpenBlob/2761.
convert: no images defined `/path/to/my/file.jpg' @ error/convert.c/ConvertImageCommand/3258.
So i assume there is something wrong with how i enter the search path for the file when trying to extract one layer only.
Any suggestions?
Re: How to specify a complete path with layer extraction?
Posted: 2019-01-21T12:55:12-07:00
by snibgo
What version of IM, on what platform?
Re: How to specify a complete path with layer extraction?
Posted: 2019-01-21T13:31:35-07:00
by Fredrik M
ImageMagick 6.9.9-40 on Mac OS X 10.14.2
Re: How to specify a complete path with layer extraction?
Posted: 2019-01-21T13:47:24-07:00
by fmw42
Your syntax looks fine. Perhaps if you show your actual paths we can suggest solutions. Does the output directory already exist? Imagemagick will not create a new directory. It has to exist already. Does the output filename or path include spaces? If so, enclose the output file and its path in double quotes.
Code: Select all
convert "/path/to/my/file.tif[2]" "/path/to/my/file.jpg "
If you are trying to use relative paths, then do not include the initial /. The initial / will think it is an absolute path from your root directory.
Re: How to specify a complete path with layer extraction?
Posted: 2019-01-21T13:56:02-07:00
by Fredrik M
This works, i get some warning messages but an image is created.
Fredriks-MBP:fredrik fredrik$ convert '/Users/fredrik/Desktop/Quicksilver.tif' Quick.png
convert: Incompatible type for "RichTIFFIPTC"; tag ignored. `TIFFFetchNormalTag' @ warning/tiff.c/TIFFWarnings/912.
convert: improper image header `/Users/fredrik/Desktop/Quicksilver.tif' @ error/psd.c/ReadPSDLayersInternal/1675.
This however does not work.
Fredriks-MBP:fredrik fredrik$ convert '/Users/fredrik/Desktop/Quicksilver.tif[2]' Quick.png
convert: Incompatible type for "RichTIFFIPTC"; tag ignored. `TIFFFetchNormalTag' @ warning/tiff.c/TIFFWarnings/912.
convert: improper image header `/Users/fredrik/Desktop/Quicksilver.tif' @ error/psd.c/ReadPSDLayersInternal/1675.
convert: no images defined `Quick.png' @ error/convert.c/ConvertImageCommand/3258.
I get the same error message when using a complete path "/Volumes/Macintosh SSD/Users/fredrik/Desktop/Quicksilver.tif[2]"
Re: How to specify a complete path with layer extraction?
Posted: 2019-01-21T14:06:34-07:00
by fmw42
I would suggest double quotes. But I think single quotes should still work. Post your TIFf file to some free hosting service that will not change it s format. The post a link to your TIFF file here some we can test.
The messages you got "Incompatible type for "RichTIFFIPTC"; tag ignored" were warnings not errors. They just say that there are special TIFF tags that IM does not understand. You can avoid this warnings by adding -quiet after convert. Improper header seems to imply there is some corruption or malformed header information in the file, which may be why IM cannot read the second layer.
Does your tiff file contain actual layers or just pages?
Re: How to specify a complete path with layer extraction?
Posted: 2019-01-21T14:13:47-07:00
by fmw42
P.S. Imagemagick layer indices start with 0. [0] is the first layer. [1] is the second layer. [2] is the third layer. Do you have only 2 layers in your image. If so, then there is no layer [2].
Re: How to specify a complete path with layer extraction?
Posted: 2019-01-21T14:16:47-07:00
by Fredrik M
My image contains two photoshop layers, i only get the no images defined when using /Users/fre... in the path, if i go to the Desktop folder and type the command without search path, like this convert Quicksilver.tif[2] Quick.png it works just fine.
Re: How to specify a complete path with layer extraction?
Posted: 2019-01-21T14:18:21-07:00
by Fredrik M
fmw42 wrote: ↑2019-01-21T14:13:47-07:00
P.S. Imagemagick layer indices start with 0. [0] is the first layer. [1] is the second layer. [2] is the third layer. Do you have only 2 layers in your image. If so, then there is no layer [2].
Not as i have learned, [0] is not pointed to a specific photoshop layer, it is the complete image with all layers. [1] is the first layer [2] the second and so on.
Re: How to specify a complete path with layer extraction?
Posted: 2019-01-21T16:16:11-07:00
by fmw42
TIFF does not have a flattened layer. So the first layer of a tiff is the actual layer. PSD files do have a flattened first layer, which would be Imagemagick index [0] and the first simple layer would be [1]. But for TIFF, the first layer is [0].
So since you only have two layers, the first layer would be [0] and the second layer would be [1] in a TIFF file.
Re: How to specify a complete path with layer extraction?
Posted: 2019-01-22T10:54:04-07:00
by Fredrik M
fmw42 wrote: ↑2019-01-21T16:16:11-07:00
TIFF does not have a flattened layer. So the first layer of a tiff is the actual layer. PSD files do have a flattened first layer, which would be Imagemagick index [0] and the first simple layer would be [1]. But for TIFF, the first layer is [0].
So since you only have two layers, the first layer would be [0] and the second layer would be [1] in a TIFF file.
Well if i do a identify on the image i get this.
Quicksilver.tif[0] TIFF 3507x2480 3507x2480+0+0 8-bit sRGB 26.2328MiB 0.020u 0:00.009
Quicksilver.tif[1] TIFF 3507x2480 3507x2480+0+0 8-bit sRGB 0.000u 0:00.000
Quicksilver.tif[2] TIFF 3507x2480 3507x2480+0+0 8-bit sRGB 0.000u 0:00.000
And if i enter convert Quicksilver.tif[2] Quick.png i do get an image from the correct layer of the original image.
My issue is not the layers it is that the above stops working as soon as i try to enter the complete search path which i will need to do when i use it in a script later on.
Re: How to specify a complete path with layer extraction?
Posted: 2019-01-22T13:28:37-07:00
by fmw42
You said earlier that you only had 2 layers. Now you are showing 3 layers. So [2] should be valid. With regard to your file paths, to check, try
Does that show the list you expect? If not, then your path is incorrect.
Re: How to specify a complete path with layer extraction?
Posted: 2019-01-22T13:53:38-07:00
by Fredrik M
fmw42 wrote: ↑2019-01-22T13:28:37-07:00
You said earlier that you only had 2 layers. Now you are showing 3 layers. So [2] should be valid. With regard to your file paths, to check, try
Does that show the list you expect? If not, then your path is incorrect.
The image does only contains two layers.
You can download it here if you don't believe me.
http://malvefors.se/forumimages/ImageMa ... silver.tif
It is just a test image, two layers, top one transparent with a logo, bottom one a solid color and yes the search path to the image is correct. It works just fine if i do this.
Fredriks-MBP:Desktop fredrik$ cd /Users/fredrik/Desktop/
Fredriks-MBP:Desktop fredrik$ convert Quicksilver.tif[2] Quick.png
convert: Incompatible type for "RichTIFFIPTC"; tag ignored. `TIFFFetchNormalTag' @ warning/tiff.c/TIFFWarnings/912.
Fredriks-MBP:Desktop fredrik$
But it does not work if i do this.
Fredriks-MBP:Desktop fredrik$ cd /
Fredriks-MBP:/ fredrik$ convert "/Users/fredrik/Desktop/Quicksilver.tif[2]" "/Users/fredrik/Desktop/Quick2.png"
convert: Incompatible type for "RichTIFFIPTC"; tag ignored. `TIFFFetchNormalTag' @ warning/tiff.c/TIFFWarnings/912.
convert: improper image header `/Users/fredrik/Desktop/Quicksilver.tif' @ error/psd.c/ReadPSDLayersInternal/1675.
convert: no images defined `/Users/fredrik/Desktop/Quick2.png' @ error/convert.c/ConvertImageCommand/3258.
Fredriks-MBP:/ fredrik$
Re: How to specify a complete path with layer extraction?
Posted: 2019-01-22T14:27:39-07:00
by fmw42
Your file in Photoshop has two layers, but Imagemagick does see a flattened layer [0], contrary to my previous comment and belief.
Quicksilver.tif[0] TIFF 3507x2480 3507x2480+0+0 8-bit sRGB 26.2328MiB 0.000u 0:00.009
Quicksilver.tif[1] TIFF 3507x2480 3507x2480+0+0 8-bit sRGB 26.2328MiB 0.000u 0:00.000
Quicksilver.tif[2] TIFF 3507x2480 3507x2480+0+0 8-bit sRGB 26.2328MiB 0.000u 0:00.000
You can see that by
Code: Select all
convert -quiet Quicksilver.tif Quicksilver.png
This works for me (although the background color is a bit more blue)
Code: Select all
convert /Users/fred/desktop/test/Quicksilver.tif[2] /Users/fred/desktop/test/Quicksilver2.jpg
I cannot explain why you get all 3 layers, but cannot get the layer [0]. Your version of Imagemagick is a bit old. You might try to upgrade to the current version (now at 6.9.10.24).