Creating TIF with layers

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
sandraR
Posts: 19
Joined: 2019-01-22T02:37:30-07:00
Authentication code: 1152

Creating TIF with layers

Post 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).
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Creating TIF with layers

Post 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
snibgo's IM pages: im.snibgo.com
sandraR
Posts: 19
Joined: 2019-01-22T02:37:30-07:00
Authentication code: 1152

Re: Creating TIF with layers

Post 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.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Creating TIF with layers

Post 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.
snibgo's IM pages: im.snibgo.com
sandraR
Posts: 19
Joined: 2019-01-22T02:37:30-07:00
Authentication code: 1152

Re: Creating TIF with layers

Post 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.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Creating TIF with layers

Post 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.
snibgo's IM pages: im.snibgo.com
sandraR
Posts: 19
Joined: 2019-01-22T02:37:30-07:00
Authentication code: 1152

Re: Creating TIF with layers

Post 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... :)
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Creating TIF with layers

Post by fmw42 »

As far as I know, Imagemagick cannot create TIFF layers, only multiple pages.
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Creating TIF with layers

Post 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.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
sandraR
Posts: 19
Joined: 2019-01-22T02:37:30-07:00
Authentication code: 1152

Re: Creating TIF with layers

Post 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.
sandraR
Posts: 19
Joined: 2019-01-22T02:37:30-07:00
Authentication code: 1152

Re: Creating TIF with layers

Post 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.
Post Reply