Page 1 of 1

Creating TIF with layers

Posted: 2019-02-05T04:52:33-07:00
by sandraR
Hi. I am new to IM.
I want to create and add a second layer to a TIF file.

My original file is TIF with only one layer with transparacy (it is a picture of a chair on transparent background).

I want to add an additional layer to that file, and a fill it with a color (rgb=152,152,152), and then place this new layer under the existing one.
I do not want to merge them, I just want to get a new TIF-file with 2 layers instead.

Any one know how to do this?

I thought that maybe I could clone the layer and fill it with a color then change the layer order.
But I can't get it to work...

Code: Select all

magick mylayeredfile.tif ( -clone 0 -background "rgb(152,152,152)" -flatten) -alpha set -reverse newlayeredfile.tif
Any ideas?

I found this tread online about how to merge diffrent files to a layered PSD:
https://stackoverflow.com/questions/187 ... agick?lq=1

But since I just need a layer in a color, maybe I could do this directly in IM and not use diffrent files that combines?
Allthou I need it so still be a TIF (with layers).

Re: Creating TIF with layers

Posted: 2019-02-05T05:05:18-07:00
by snibgo
What version of IM? On what platform?

How about:

Code: Select all

magick in.tif ( +clone -fill "rgb(152,152,152)" -colorize 100 ) -reverse out.tif

Re: Creating TIF with layers

Posted: 2019-02-05T05:16:53-07:00
by sandraR
Hi snibgo.
I am using the version 7.0.8-24 on CentOS6.9

I tried your code, but it did not give me the result I want.
There is still just one layer in the file and now it merged the picture of the chair with the color, so it is just a flatt colored chair with transparacy. :P

I am looking for a way to preserve my original layer and just add a new layer with color.
So in the end the TIF contains 2 layers.

Re: Creating TIF with layers

Posted: 2019-02-05T05:26:19-07:00
by snibgo
I don't know what you mean by "layers". What software are you using to examine tif files? IM deals in images, not layers. My command will create out.tif with two images.

Re: Creating TIF with layers

Posted: 2019-02-05T05:41:48-07:00
by sandraR
By Layers I mean as in layers you see in Photoshop.

I want the output to be just 1 image - that contains 2 photoshop layers as a TIF file.
Image

To day my original file just contains 1 layer, and I want to add another layer in a color and place that layer underneath the existing.
Like you see in my screenshot here.

Re: Creating TIF with layers

Posted: 2019-02-05T06:05:01-07:00
by snibgo
sandraR wrote:I want the output to be just 1 image - that contains 2 photoshop layers as a TIF file.
I don't use Photoshop, but I don't think IM can do that.

Re: Creating TIF with layers

Posted: 2019-02-05T06:56:25-07:00
by sandraR
Both PSD and TIF can contain photoshop layers.
But I am unsure if I can in a TIF create more than one layer using IM...?

I found this ticket on the IM forum, where they create a PSD file with layers.
But to create the layers they use diffrent files, and combine them to a PSD file.
https://www.imagemagick.org/discourse-s ... =1&t=19775

So it should be possible, I think, for TIF aswell...
I guess I have to keep trying, or perhaps try another approach where I use 2 files to combine as them in a new file as layers.

Not giving up just yet... :)

Re: Creating TIF with layers

Posted: 2019-02-05T14:30:02-07:00
by fmw42
As far as I know, Imagemagick cannot create TIFF layers, only multiple pages.

Re: Creating TIF with layers

Posted: 2019-02-05T23:43:23-07:00
by dlemstra
There is an experimental flag `-define tiff:write-layers=yes`that can be used to create photoshop layers inside a tiff file. But there were still some issues when openening these files in Photoshop.

Re: Creating TIF with layers

Posted: 2019-02-06T01:53:16-07:00
by sandraR
fmw42 wrote: 2019-02-05T14:30:02-07:00 As far as I know, Imagemagick cannot create TIFF layers, only multiple pages.
yeah, I have yet to make a successful conversion for TIF with layers....

I have manage to create a layered file in .PSD - but I had to combine 2 files to create the 2 layers and make an output in PSD.

Code: Select all

magick \( -page +0+0 -label "Product" chair.tif -background none -flatten \) \( -page +0+0 -label "Grey" background.tif -background none -flatten \) \( -clone 0--1 -background none -flatten \) -alpha On -reverse mylayeredfile.psd
The size(MB) is really big thou in the created PSD.

If I try to change this to TIF as the output, it won't keep the layers intact in the file when opening the file in photoshop.

Re: Creating TIF with layers

Posted: 2019-02-06T02:12:24-07:00
by sandraR
dlemstra wrote: 2019-02-05T23:43:23-07:00 There is an experimental flag `-define tiff:write-layers=yes`that can be used to create photoshop layers inside a tiff file. But there were still some issues when openening these files in Photoshop.
hmm... interesting. I will try it.