Page 1 of 1
TIFF copy alpha channel from one image to another
Posted: 2016-02-13T15:18:10-07:00
by Misko78
Hello everyone and sorry for asking maybe a stupid question.
I'm using a Vuescan program to scan my negatives, and negfix8 script to remove orange mask. Vuescan saves infrared scan of a negative for purposes of dust and scratch removal. It does that by saving IR scan as an alpha channel. RAW scan that Vuescan makes is in fact RGB 16bit TIFF image plus 16bit grayscale image as a alpha channel.
By using negfix8 script you lose alpha channel in new TIFF file. Is there any way to copy alpha channel from initial TIFF scan file to new TIFF.
Re: TIFF copy alpha channel from one image to another
Posted: 2016-02-13T16:22:08-07:00
by fmw42
What version of Imagemagick are you using and what platform? Always provide that when asking questions, since syntax may differ
Can you post your input TIFF file that has the alpha channel or the RGB image and a separate alpha channel image to some place such as dropbox.com and put the URL here. I am not really sure I understand where you have the alpha channel that you want to put in another image.
If you have a tiff with RGB and alpha as input, then in unix syntax
Code: Select all
convert new.tif \( input.tif -channel a -separate +channel \) -alpha off -compose copy_opacity -composite new.tif
for windows
Code: Select all
convert new.tif ( input.tif -channel a -separate +channel ) -alpha off -compose copy_opacity -composite new.tif
Re: TIFF copy alpha channel from one image to another
Posted: 2016-02-13T16:44:54-07:00
by Misko78
Thank you for a superfast response
I use ImageMagick 6.9.2-3 Q16 x64
This is a link to my dropbox folder with two files (i've lowered resolution to 600dpi because originals are over 100MB):
https://www.dropbox.com/sh/v0u2w9pnmgvr ... HGg1a?dl=0
P_scan0006.tif - file created with negfix8 script (
https://sites.google.com/site/negfix/) without alpha channel
scan0006.tif - RAW scan from Vuescan program.
I need to transfer alpha channel from scan0006.tif to P_scan0006.tif.
Re: TIFF copy alpha channel from one image to another
Posted: 2016-02-13T19:06:53-07:00
by fmw42
You have not answered my question. What platform are you on? Syntax differs.
The other image from the google site has many different sizes. But what relevance does it have to the other two files?
Did you try my commands above for your platform?
EDIT:
This works for me (unix syntax)
Code: Select all
convert -quiet P_scan0006.tif \( scan0006.tif -channel a -separate +channel \) -alpha off -compose copy_opacity -composite P_scan0006_alpha.tif
Re: TIFF copy alpha channel from one image to another
Posted: 2016-02-13T19:08:18-07:00
by snibgo
For dust and scratches, which are very small things, you might provide cropped versions of the large files rather than resized. The crops can be very small, provided they are representative.
Re: TIFF copy alpha channel from one image to another
Posted: 2016-02-13T19:14:05-07:00
by fmw42
see my EDIT above
Re: TIFF copy alpha channel from one image to another
Posted: 2016-02-14T02:09:14-07:00
by Misko78
ahh, I use Windows 7, was tired last night and misunderstood you. I posted google link as a reference to a script used, don't mind images there.
When i use command above i get this:
and i need it like this:
Re: TIFF copy alpha channel from one image to another
Posted: 2016-02-14T02:23:33-07:00
by fmw42
If you are on windows, then try
Code: Select all
convert -quiet P_scan0006.tif ( scan0006.tif -channel a -separate +channel ) -alpha off -compose copy_opacity -composite P_scan0006_alpha.tif
When I process your images, the result looks fine (no dither pattern).
http://www.fmwconcepts.com/misc_tests/a ... _alpha.tif
If this is not what you want, then it is something other than a simple transfer of alpha channels. So please explain further or provide and example of two input images and the resulting output image.
What is your version of Imagemagick and your version of libtiff
Re: TIFF copy alpha channel from one image to another
Posted: 2016-02-14T02:47:36-07:00
by Misko78
I've updated Imagemagick to 6.9.3-4 Q16 x64 and my libtiff is 3.8.2 (gnuwin32
http://gnuwin32.sourceforge.net/packages/tiff.htm)
When i open your file in Photoshop i don't see separate alpha channel only dithered image, when i open it in any pic viewer i see image normally.
Yes i need simple transfer of alpha channel from one image to another and to maintain it as a separate alpha channel.
Re: TIFF copy alpha channel from one image to another
Posted: 2016-02-14T11:46:55-07:00
by fmw42
You need to specify the type of alpha you want in your command line. Try this (windows syntax)
Code: Select all
convert -quiet P_scan0006.tif ( scan0006.tif -channel a -separate +channel ) -alpha off -compose copy_opacity -composite -define tiff:alpha=unassociated P_scan0006_alpha_u.tif
Re: TIFF copy alpha channel from one image to another
Posted: 2016-02-14T12:06:44-07:00
by Misko78
Still no luck, maybe it has something to do because when you do the command it makes layer 0 instead of background layer.
Re: TIFF copy alpha channel from one image to another
Posted: 2016-02-14T13:17:29-07:00
by fmw42
Can you send an example TIFF of the format you want it to have. We need to understand better what you want. The file I generated above had one layer and 4 channels (RGB and separate alpha). When I open it in PS (CS), it has one layer (background) and 4 channels red, green, blue, alpha 1. What is wrong with that?
If the above does not work, try
Code: Select all
convert -quiet P_scan0006.tif ( scan0006.tif -channel a -separate +channel ) -alpha off -compose copy_opacity -composite -define tiff:alpha=unspecified P_scan0006_alpha_us.tif
or
Code: Select all
convert -quiet P_scan0006.tif ( scan0006.tif -channel a -separate +channel ) -alpha off -compose copy_opacity -composite -define tiff:alpha=associated P_scan0006_alpha_a.tif
But I think those will produce the same result as before with the dither-like pattern.
Re: TIFF copy alpha channel from one image to another
Posted: 2016-02-14T13:28:39-07:00
by Misko78
fmw42 wrote:Can you send an example TIFF of the format you want it to have. We need to understand better what you want. The file I generated above had one layer and 4 channels (RGB and separate alpha). When I open it in PS (CS), it has one layer (background) and 4 channels red, green, blue, alpha 1. What is wrong with that?
That is exactly what i need. But when i used that command again i got dithered image.
It finally worked for me with this command:
Code: Select all
convert -quiet P_scan0006.tif ( scan0006.tif -channel a -separate +channel ) -alpha off -compose copy_opacity -composite -define tiff:alpha=unspecified P_scan0006_alpha_us.tif
Thank you so much.
For you time, knowledge and patience!!!
Re: TIFF copy alpha channel from one image to another
Posted: 2016-02-14T13:49:12-07:00
by fmw42
I think somewhere along the way, Adobe changed the meaning of unassociated and unspecified. I get different results than you.