combining two images
combining two images
Hello!
I've got two images one is a TIFF and the other is an PNG and they have same dimensions.
Only the PNG image has transparency information.
Does anyone know how to apply the transparency information to tiff, preserving other settings (colorspace and so on)
I tried with combine and the transparency chanel but I didn't find any solution.
thanks in advance!
The two pics:
http://www.werk3at.net/rol/Winter2.tif
http://www.werk3at.net/rol/Winter2.png
greets richard
I've got two images one is a TIFF and the other is an PNG and they have same dimensions.
Only the PNG image has transparency information.
Does anyone know how to apply the transparency information to tiff, preserving other settings (colorspace and so on)
I tried with combine and the transparency chanel but I didn't find any solution.
thanks in advance!
The two pics:
http://www.werk3at.net/rol/Winter2.tif
http://www.werk3at.net/rol/Winter2.png
greets richard
Re: combining two images
Hello Richard
I have just had a go at your problem but my server does not seem to understand tif !
Anyway on downloading untitled.png my PC kept renaming it to a .bmp could there be a problem with this file ?
I change the black on the untitled file to transparent and saved it as a png then tried a couple of things and I have the transparency on the png but no sign of the tif.
I then tried using a jpg for the background image then added the png file and it seemed to work Ok.
I would try a different png and see what happens.
I have just had a go at your problem but my server does not seem to understand tif !
Anyway on downloading untitled.png my PC kept renaming it to a .bmp could there be a problem with this file ?
I change the black on the untitled file to transparent and saved it as a png then tried a couple of things and I have the transparency on the png but no sign of the tif.
I then tried using a jpg for the background image then added the png file and it seemed to work Ok.
I would try a different png and see what happens.
Re: combining two images
I think a bug has been uncovered here. In the course of figuring out the command to do what you describe, I found this:
This produces a transparent image, as expected:
But if we use Winter2.tif as the source image, the output is not transparent.
Therefore this fails:
But this works:
ImageMagick 6.3.2 01/20/07 Q16 in Debian.
This produces a transparent image, as expected:
Code: Select all
convert Winter2.png -fill none -draw "color 0,0 reset" test.png
Code: Select all
convert Winter2.tif -fill none -draw "color 0,0 reset" test.png
Code: Select all
convert Winter2.tif -fill none -draw "color 0,0 reset" Winter2.tif \( Winter2.png -channel matte -negate -separate \) -composite test.png
Code: Select all
convert Winter2.png -fill none -draw "color 0,0 reset" Winter2.tif \( Winter2.png -channel matte -negate -separate \) -composite test.png
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: combining two images
After reading in the TIF try adding the -matte operator. This ensures the image has a matte/transparency or alpha channel added, before you attempt to add transparent color to the image.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: combining two images
Thanks, Anthony.
This works:
This works:
Code: Select all
convert Winter2.tif -matte -fill none -draw "color 0,0 reset" Winter2.tif \( Winter2.png -channel matte -negate -separate \) -composite test.png
Re: combining two images
Thank you for for the replies. The commands mentioned work perfectly for PNG-results. but i ned the TIFF, because only the TIFF-images has right colorspace information and so on (PNG only supports RGB).
If i just change the extension to .tiff the background is black and there's no transparency.
greets richard
If i just change the extension to .tiff the background is black and there's no transparency.
greets richard
Re: combining two images
cs_rol wrote: Thank you for for the replies. The commands mentioned work perfectly for PNG-results. but i ned the TIFF, because only the TIFF-images has right colorspace information and so on (PNG only supports RGB).
If i just change the extension to .tiff the background is black and there's no transparency.
This works for me:
Code: Select all
convert Winter2.tif -matte -fill none -draw "color 0,0 reset" Winter2.tif \( Winter2.png -channel matte -negate -separate \) -composite test.tiff
Re: combining two images
i resolved this by changing the tiff-coder by adding an asociated alpha channel in order to make the file be displayed correct in photoshop
tiff.c@~line1734
Now I have the task to implement this command with MagickWand or MagickCore. Can anyone tell me the lines of code to implement this features? I tried several times but i didn't come to an appropriate result.
thanks in advance and greez
richard
tiff.c@~line1734
Code: Select all
sample_info[0]=EXTRASAMPLE_ASSOCALPHA;// remove: EXTRASAMPLE_UNASSALPHA
thanks in advance and greez
richard
-
- Posts: 1015
- Joined: 2005-03-21T21:16:57-07:00
Re: combining two images
If I understand your request correctly, you want to copy the alpha channel from the png to the tif, in which case this command should do it:
I can't test it with a TIF as output but it does work when output to a PNG.
If that's what you need then this C function does the same thing:
Pete
Code: Select all
convert Winter2.tif -matte Winter2.png -compose Dst_In -composite winter2_out.png
If that's what you need then this C function does the same thing:
Code: Select all
#include <windows.h>
#include <wand/magick_wand.h>
void test_wand(void)
{
MagickWand *m_wand = NULL;
MagickWand *a_wand = NULL;
MagickWandGenesis();
/* Read the TIF and add an alpha layer */
m_wand = NewMagickWand();
MagickReadImage(m_wand,"Winter2.tif");
MagickSetImageMatte(m_wand,MagickTrue);
/* Read the PNG which has the alpha layer */
a_wand = NewMagickWand();
MagickReadImage(a_wand,"Winter2.png");
/* Copy the alpha layer from PNG to TIF */
MagickCompositeImage(m_wand,a_wand,DstInCompositeOp,0,0);
/* Write it out */
MagickWriteImage(m_wand,"winter2_cmd.png");
/* Clean up */
if(m_wand)m_wand = DestroyMagickWand(m_wand);
if(a_wand)a_wand = DestroyMagickWand(a_wand);
MagickWandTerminus();
}