Skip to content
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

Ability to create new image with specific channels #1585

Open
toptensoftware opened this issue Mar 14, 2024 · 8 comments
Open

Ability to create new image with specific channels #1585

toptensoftware opened this issue Mar 14, 2024 · 8 comments

Comments

@toptensoftware
Copy link

Is your feature request related to a problem? Please describe

Need a way to create a .tiff image with channels RGB + meta0 (not alpha)

Describe the solution you'd like

A way to create a new image with a specified size and channel set.

Describe alternatives you've considered

Can't find an API method to do so, so haven't really tried anything else.

Additional context

It seems the only way to create a new image of specified size is with public MagickImage(IMagickColor<QuantumType> color, int width, int height) which allows some selection of channels depending on the color object passed (3 vs 4 channel) but if there's a way to create other channel formats I can't figure it out.

(Ideally what I'd like is a way to create a new image of specified size with exact same settings as another image instance. I asked about this in github discussion question (#1584), but didn't get an answer. At the time I worked around it with different color objects + calling .Grayscale() to get a single channel file. But now I need RGB+meta0).

@dlemstra
Copy link
Owner

dlemstra commented Apr 9, 2024

Can you prove a bit more detail on what kind of issue you are trying to solve? Because when I read #1584 it looks like you want to clone part of the image? You can use image.Clone(x, y, width, height) for that?

@toptensoftware
Copy link
Author

Hi @dlemstra,

Thanks for that... yes Clone(geo) will probably cover it for me for the moment.

Just for background though... I'm mostly working with large archive .tif files of photographic negative scans. These have RGB or grayscale channels + a meta0 channel used for the infrared channel from the scanner. There are a couple of scenarios where I'd like to explicitly create a .tif file with that additional IR channel added and or removed and I couldn't find how to do this with the API. eg: If I need to create a greyscale image with IR channel how would I do that? Not super important and if/when I get to needing that I can just create some template .tif files and clone from there I guess.

Brad

@dlemstra
Copy link
Owner

Not sure how this should be added to the api. Hoping someone will come and suggest how we should add this to the api. Then I can try to figure out how this can be done with the ImageMagick api.

@toptensoftware
Copy link
Author

How about:

public MagickImage(PixelChannel[] channels, int width, int height)

@dlemstra
Copy link
Owner

That would work for the creation but not the removal of a channel. And that also would not copy the settings of another image. And that would also not adress your removal of channels request.

@toptensoftware
Copy link
Author

Hrm, not sure then. Perhaps:

public void AddChannel(PixelChannel channel);
public void RemoveChannel(PixelChannel channel);

@dlemstra
Copy link
Owner

There is an api in ImageMagick that can be used to set the number of meta channels. The rest of the channels have a lot of logic depending on the type/colorspace of the image. I can add a method somewhere that allows you to change the number of meta channels. Would that work for you?

@toptensoftware
Copy link
Author

Yes, that would probably cover it - I only ever deal with one meta channel and I just need to be able to add it/remove it.

@dlemstra dlemstra added this to the 13.9.0 milestone May 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants