-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extracting additional channels #5979
Comments
What application are the first two screenshots from? |
@radarhere |
If we were to add this functionality, is your image one that we are able to include in our test suite, and distribute under the Pillow license? |
from PIL import Image
with Image.open("Alpha Masks Sample with 2 Alphas.tif") as im:
print("rawmode", im.tile[0][-1][0])
print("mode", im.mode) gives
Pillow detects the raw mode as RGBXX and the mode as RGBX. Pillow is trying to convert the image to a more common format by restricting the number of channels, in opposition to what you're requesting. |
If you've already installed psdtags, then I expect you've also installed the dependency tifffile. In that case, here is a way to solve your problem. import tifffile
from PIL import Image
folder = "<path_to_file>"
file = "Alpha Masks Sample with 2 Alphas.tif"
source_file = folder + "/" + file
img = tifffile.imread(source_file)
for channel_counter in range(img.shape[2]):
im = Image.fromarray(img[:, :, channel_counter])
im.save(folder + "/export_channel"+str(channel_counter+1)+".png", optimize=True) |
@radarhere |
Thanks very much for asking! Ok, for the first time, I've setup a Sponsor button on my profile, so if you'd like to throw some spare change at me, your kindness can express itself there - https:/sponsors/radarhere?frequency=one-time |
What did you do?
Tried to export two alpha channels:
What did you expect to happen?
To be able to get preview of both alpha channels as a png files.
What actually happened?
I've got preview of only one alpha channel:
What are your OS, Python and Pillow versions?
Archive with example and source code:
pillow_alpha_channels.zip
The text was updated successfully, but these errors were encountered: