RSS/Atom feed Twitter
Site is read-only, email is disabled

Copy the alpha channel from an image to another

This discussion is connected to the gimp-user-list.gnome.org mailing list which is provided by the GIMP developers and not related to gimpusers.com.

This is a read-only list on gimpusers.com so this discussion thread is read-only, too.

5 of 7 messages available
Toggle history

Please log in to manage your subscriptions.

Copy the alpha channel from an image to another Germain Le Chapelain 13 Feb 03:10
  Copy the alpha channel from an image to another Claus Cyrny 13 Feb 05:44
Copy the alpha channel from an image to another Germain Le Chapelain 13 Feb 08:52
mailman.0.1171332036.24831.... 07 Oct 20:18
mailman.36468.1171353048.16... 07 Oct 20:18
  Copy the alpha channel from an image to another Michael J. Hammel 13 Feb 16:39
   Copy the alpha channel from an image to another Akkana Peck 13 Feb 18:38
Germain Le Chapelain
2007-02-13 03:10:02 UTC (over 17 years ago)

Copy the alpha channel from an image to another

Hi,

I feel like my question might be very stupid :

I would like to know who to copy the alpha channel of an image to another image.
I am working with texture file so basically that layer is a data as the color channel, not something I am using to modifie my files.

I have been trying to make a batch script to convert tgas to DX texture, and I realized I had no idea how to do that when I tried doing it by hand.

I have been looking for hours in the docs and on internet but really all I find is the way to convert that channel to a selection, whereas I do want to select it and copy it in an other image.

In script fu, going 'gimp-layer-add-alpha' then 'gimp-selection-all', 'gimp-edit-copy' and 'gimp-edit-paste' leaves it white.

Thanks for your help. Germain

Claus Cyrny
2007-02-13 05:44:51 UTC (over 17 years ago)

Copy the alpha channel from an image to another

Hi,

Germain Le Chapelain wrote:

Hi,

I feel like my question might be very stupid :

I would like to know who to copy the alpha channel of an image to another image.

Simpy select the alpha channel with 'select all' ([CTRL]+A) and copy it into the clipboard. Then go to the second image where you want to insert the alpha channel, select the image ([CTRL]+A again), and copy this selection into an alpha channel ('Select > Save to Channel'). Then just select this new alpha channel in the 'Layers/Channels' menu and paste the alpha channel ([CTRL]+A, [CTRL]+H) from the clipboard into it. That's all.

HTH,

Claus

Germain Le Chapelain
2007-02-13 08:52:09 UTC (over 17 years ago)

Copy the alpha channel from an image to another

From: Claus Cyrny [mailto:claus.cyrny@web.de] Sent: Mon 2/12/2007 11:44 PM
To: Germain Le Chapelain
Cc: gimp-user@lists.XCF.Berkeley.EDU Subject: Re: [Gimp-user] Copy the alpha channel from an image to another

Hi,

Germain Le Chapelain wrote:

Hi,

I feel like my question might be very stupid :

I would like to know who to copy the alpha channel of an image to another image.

Simpy select the alpha channel with 'select all' ([CTRL]+A) and copy it into the clipboard. Then go to the second image where you want to insert the alpha channel, select the image ([CTRL]+A again), and copy this selection into an alpha channel ('Select > Save to Channel'). Then just select this new alpha channel in the 'Layers/Channels' menu and paste the alpha channel ([CTRL]+A, [CTRL]+H) from the clipboard into it. That's all.

Thanks for the explanation.

I might have some serious psychotechnic problems but I am not able to reproduce the scenario you describe.

However, I have finally been able to do what I wanted from the begining : copy paste the all 4 channels from an existing image to a new image.

To do so :

o when creating a new image, choose

`advanced options > Fill with : Transparency' this is what tells gimp that there will be an alpha channel.

o then you can go select-all => paste in your new image.

But creating a new image, RGB, filled with white, and then adding an alpha channel doesn't allow to copy all four channel at once, and leave the alpha channel at 255.

Similarly, the equivalent script

(drawableDst (car (gimp-layer-new imageDst newWidth newHeight RGBA-IMAGE "dest" 100 NORMAL-MODE)))) (gimp-drawable-fill drawableDst TRANSPARENT-FILL) (gimp-edit-copy (car (gimp-image-get-active-drawable image)))

Does copy the four channels at once, whereas going

(drawableDst (car (gimp-layer-new imageDst newWidth newHeight RGBA-IMAGE "dest" 100 NORMAL-MODE)))) (gimp-drawable-fill drawableDst TRANSPARENT-FILL) (gimp-edit-copy (car (gimp-image-get-active-drawable image)))

Leave also the alpha channel to 255.

I don't understand that behavior. : /

Thank you again for your help, I ll get back to that email if I need to transfert the alpha channel independently !

Germain

Michael J. Hammel
2007-02-13 16:39:28 UTC (over 17 years ago)

Copy the alpha channel from an image to another

On Mon, 2007-02-12 at 23:50 -0800, "Germain Le Chapelain"

I would like to know who to copy the alpha channel of an image to another image.

1. Merge visible layers of the source image. 2. Copy visible layer of source image 3. Create new image for destination (as in File->New). 4. Add a layer to destination image
5. Delete background layer in destination image 6. Add black layer mask to only layer left in destination image. 7. Make black layer mask active drawable. 8. Paste into destination image.
9. Anchor to active drawable (re: mask). 10. Apply layer mask.

Now the destination image (at least in that one layer) has the same alpha as your source image.

Steps 4-5 could be:

4. Add alpha channel to background layer 5. (delete this step)

Should also work in both 2.2 and 2.4.

I tried this with a simple white image (single layer) using a gradient in a layer mask to create the source image. I then applied the layer mask in the source image to put the alpha into the layer itself. When this layer was copied to the black layer mask of the destination, the visual appearance was correct. When I saved both files (after applying the mask in the destination) they have the same file size (as expected) but they are not binary identical when saved as either XCF, TIFF or PNG. Not sure why (maybe some metadata differences?). I did notice that the pasted copy had a selection outline that was not the full size of the source image (both images where the same size). So even though I did a Select->All, Edit->Copy (I also tried Edit->Copy Visible), it appears to only have picked up to a certain transparency level in the copy. Or maybe it's just that the marching ants only recognize up to a certain level when pasted.

Maybe one of the developers has some insight as to why the source and destination wouldn't be identical in this case.

Akkana Peck
2007-02-13 18:38:56 UTC (over 17 years ago)

Copy the alpha channel from an image to another

Michael J. Hammel writes:

On Mon, 2007-02-12 at 23:50 -0800, "Germain Le Chapelain"

I would like to know who to copy the alpha channel of an image to another image.

1. Merge visible layers of the source image. 2. Copy visible layer of source image 3. Create new image for destination (as in File->New). 4. Add a layer to destination image
5. Delete background layer in destination image 6. Add black layer mask to only layer left in destination image. 7. Make black layer mask active drawable. 8. Paste into destination image.
9. Anchor to active drawable (re: mask). 10. Apply layer mask.

That doesn't quite work for me, because the contents of the source image get applied to the layer mask too (where the source image was blue but opaque, the destination won't be fully opaque).

But you can fix that by adding two steps: between steps 1 and 2, turn on Keep Transparency (checkbox in the Layers dialog, called Lock in 2.3) for the source image, then fill the source image with white. Then copy, and what you paste later into the dest image's layer mask will reflect only the alpha channel of the original.

(Don't get too put off by the number of steps. I skipped steps 4 and 5, but I was only using single layer images; maybe they're important for the general case. And I skipped step 7 because it happens automatically from step 6.)

This doesn't actually give you an image with an alpha channel, as the OP asked; it gives you a layer with a layer mask that mimics the original image's alpha channel. But "Merge visible layers" will turn that layer mask into an alpha channel if you care about the difference.