feat: write meta channels in PSD files #8393
Replies: 17 comments 23 replies
-
|
Your request is not clear. Do you want IM to write an image that contains meta channels to a PSD file? Or something else? From the code in coders/psd.c, IM can read meta channels from PSD files, but can't write meta channels to PSD files. To do this, I suppose WritePSDChannels() would need to be modified, stepping through the meta channels. I don't know how difficult that would be. |
Beta Was this translation helpful? Give feedback.
-
|
Naively I just added the code below just after line 3306 of the psd code and of course it didn't work. But I think I'm on the right track... Maybe just something wrong with the rows calculations etc, I really didn't think much about it. ssize_t
number_meta_channels;
QuantumInfo
*quantum_info;
ssize_t
i;
number_meta_channels=(ssize_t) channels-psd_info->min_channels;
if ((image->alpha_trait & BlendPixelTrait) != 0)
number_meta_channels--;
quantum_info=AcquireQuantumInfo(image_info,layer);
for (i=0; i < number_meta_channels; i++)
{
(void) SetQuantumMetaChannel(image,quantum_info,i);
length=WritePSDChannel(psd_info,image_info,image,layer,
MultispectralQuantum,compact_pixels,rows_offset,separate,compression,
exception);
if (separate != MagickFalse)
size_offset+=WritePSDSize(psd_info,image,length,size_offset)+2;
else
{
rows_offset+=(MagickOffsetType) offset_length;
total_length+=length;
break;
}
total_length+=length;
}
(void) SetQuantumMetaChannel(image,quantum_info,-1); |
Beta Was this translation helpful? Give feedback.
-
|
I was looking at commits in the TIFF coder file and... wow, the full support for meta channels in TIFF is only 4 weeks old!! I also decided that this is a bit beyond my knowledge so I hope someone else will take this task 🙏 |
Beta Was this translation helpful? Give feedback.
-
|
Can I have the confirmation that this is possible with PSD files from one of the developers? Like, the only thing that prevents ImageMagick support this feature is just the time to implement it and that an implementation of this feature would be very similar with how the write to metachannels were implemented for TIFF files? |
Beta Was this translation helpful? Give feedback.
-
|
The answer now is maybe? I haven't made time to investigate this yet. The PSD format is complicated and I don't have Photoshop to test changes I would make. We do support reading meta channels so I suspect we could also write them in the same way. |
Beta Was this translation helpful? Give feedback.
-
I don't think there is a simple answer. I suggest you find or make a TIFF file with named channels. Using tiffinfo and exiftool, identify which tags store that metadata. If the tags are public (eg InkSet, NumberofInks, InkNames) then they should be documented in the TIFF 6.0 specification. If they are private Photoshop tags (eg AlphaChannelsNames), they may be documented in https://exiftool.org/TagNames/Photoshop.html . With luck, you then know which tags you need to add to TIFF files, so you can modify your copy of ImageMagick. |
Beta Was this translation helpful? Give feedback.
-
|
@arturo32: Attached is x.zip which contains x.tiff, which is has an image with 4 meta channels, each with a name (I hope). I don't have Photoshop, and can't test this. Please read this with Photoshop, and see if it can read the names. |
Beta Was this translation helpful? Give feedback.
-
|
If someone wanted to implement this in Imagemagick, one could consider adding defines for tiff and psd for the meta channel names when using -channel-fx. |
Beta Was this translation helpful? Give feedback.
-
|
Okay, good. I have recorded the names in the
The 8BIM profile is a sequence of (binary, not text) bytes that start with the magic characters "8BIM". The following C program Compile the program, then run it like this, directing stdout to any file: To test this, I make an image with 4 meta channels, and assign the names from the profile: " |
Beta Was this translation helpful? Give feedback.
-
|
My mistake. The magick command I showed, and the output x.tiff, creates only 3 meta channels. |
Beta Was this translation helpful? Give feedback.
-
|
I wrote:
However, we can simply concatenate the Make an Concatenate the two profiles (Windows command): The equivalent bash command is: Apply this concatenated profile: What happens if p1.bin already contains a IM doesn't contain code to parse an 8BIM profile. But it could append This would all be simpler if exiftool could add or update |
Beta Was this translation helpful? Give feedback.
-
|
As a test of my previous post, here is p4.zip which contains p4.tiff, which has RGB channels and one meta channel, and a large 8BIM profile. That profile contains a Those See the lines that begin " My hope is that Photoshop will overwrite the first |
Beta Was this translation helpful? Give feedback.
-
|
Oh, that's a shame. Photoshop is ignoring the second |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
|
For me PS only shows one extra channel for flower_before.tiff
|
Beta Was this translation helpful? Give feedback.
-
|
We can extract the 5 channels from flower_before.tiff and view them like this: I resize and write to JPG to reduce network bandwidth. I notice that in fmw42's screenshot, the alpha channel is shown as a chequerboard background, though it isn't listed as a channel. I don't know why it isn't listed. |
Beta Was this translation helpful? Give feedback.
-
|
Note that Photoshop has two kinds of alpha channels: background and extra channels. I suppose it depends upon what kind of alpha channel the OP created in his before image. |
Beta Was this translation helpful? Give feedback.





Uh oh!
There was an error while loading. Please reload this page.
-
ImageMagick version
7.1.2-3
Operating system, version and so on
Linux
Description
There are several issues and discussions about problems when converting files to and from PSD: they are about "alpha" channels being lost or ignored. These "alpha" channels are, most of the time, meta channels that the PSD format support, but IM seems unable to read and work with them.
I have seen some discussions about "multispectral images" and the support for PSD files (which would imply support for meta channels as well) is always cited together with TIFF files, but this seems not to be the case. I can create meta channels for TIFF files without a problem with IM, but not for PSD files.
My use case is that I want to create and save a meta channel called "white" for a DTG printer in a PSD file. This channel is also called a "spot channel". I accept that IM can't change the name for meta channels but if it could at least support their existence for PSD files that would be nice.
Where would someone go (as in edit some code file) to make this feature possible? How difficult it may be to implement it?
Related discussions and issues:
Beta Was this translation helpful? Give feedback.
All reactions