Difference between composite and convert -composite BUG??

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
jansuhr
Posts: 43
Joined: 2016-01-28T01:35:38-07:00
Authentication code: 1151

Difference between composite and convert -composite BUG??

Post by jansuhr »

When using the command composite to save a transparent Photoshop file I get a different result than with convert -composite.

With composite I get the proper result of a PSD file with a transparent background.
The command is:

Code: Select all

composite input.jpg transparent_file.tif mask.jpg output.psd
Only drawback with the above is that the clipping path in the input file is discarded and so is the embedded ICC-Profile and both are needed in the final output file.

So trying with:

Code: Select all

convert -composite input.jpg transparent_file.tif mask.jpg output.psd
This doesn't give me a transparent background but the ICC-profile and clipping path are there.

Isn't these two commands supposed to have the same behavior??

Is this a bug??


Thanks

Jan
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Difference between composite and convert -composite BUG??

Post by snibgo »

jansuhr wrote:Isn't these two commands supposed to have the same behavior??
No. For one thing, the input files (so-called "source" and "destination") are given in the opposite order. So if you want the same effect, you should swap the files.

You should also put operations (eg "-composite") after the inputs, not before. Thus:

Code: Select all

convert transparent_file.tif input.jpg mask.jpg -composite output.psd
snibgo's IM pages: im.snibgo.com
jansuhr
Posts: 43
Joined: 2016-01-28T01:35:38-07:00
Authentication code: 1151

Re: Difference between composite and convert -composite BUG??

Post by jansuhr »

Thanks for the clarification, my mistake.

How ever doing it like you suggest discards the ICC-profile and the Clipping path, shouldn't they stay?
Another thing is that it shows that the resolution is only 1 px per inch.

Jan
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Difference between composite and convert -composite BUG??

Post by snibgo »

Which file contains the profile? If transparent_file.tif then, yes, it should stay. I don't know what happens to clip paths, but I think that is the same. What resolution does that file have?

Generally, output metadata comes from the first input file. You can invert the order with a suitable "-compose", of course.
snibgo's IM pages: im.snibgo.com
jansuhr
Posts: 43
Joined: 2016-01-28T01:35:38-07:00
Authentication code: 1151

Re: Difference between composite and convert -composite BUG??

Post by jansuhr »

Well if it the transparent file that controls this then it explains it. It is created on the fly with ImageMagick to get the same size as the original file. It doesn't contain any ICC-profile or paths and I guess that also explains the resolution.

Is there a way to copy the path from the input file and then paste it in to the output file? The ICC-profile can easily be assigned afterwards but the path has to be in the final output file!

Thanks

Jan
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Difference between composite and convert -composite BUG??

Post by snibgo »

You can invert the order with a suitable "-compose":

Code: Select all

convert mask.jpg transparent_file.tif input.jpg -compose DstOver -composite output.psd
snibgo's IM pages: im.snibgo.com
jansuhr
Posts: 43
Joined: 2016-01-28T01:35:38-07:00
Authentication code: 1151

Re: Difference between composite and convert -composite BUG??

Post by jansuhr »

That only gave me the mask in the output.

The solution you suggested in the my other post is working and could may be improved a little.

Jan
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Difference between composite and convert -composite BUG??

Post by snibgo »

Yes, sorry, you want transparent, than input, then mask.
snibgo's IM pages: im.snibgo.com
Post Reply