composite fails on /dev/fd/nn
composite fails on /dev/fd/nn
The composite command used to accept input from pipes. In a recent release, it stopped doing so, probably due to seeking on an input file.
To reproduce, on a LInux system under bash (or probably zsh, though I haven't tested that):
composite png:<(convert -size 200 label:abcdefg png:-) -watermark 15 some-image.jpg > /dev/null
where "some-image.jpg" is a JPEG image.
This command used to work fine, but under ImageMagick 7.0.7-8 Q16 x86_64 20171015 it fails as follows:
composite: insufficient image data in file `/dev/fd/63' @ error/png.c/ReadPNGImage/4220.
composite: `some-image.jpg' @ error/composite.c/CompositeImageCommand/1613.
It's possible to work around the problem by using a temporary file, but it's a pain--and avoiding temp files is the whole point of pipes.
To reproduce, on a LInux system under bash (or probably zsh, though I haven't tested that):
composite png:<(convert -size 200 label:abcdefg png:-) -watermark 15 some-image.jpg > /dev/null
where "some-image.jpg" is a JPEG image.
This command used to work fine, but under ImageMagick 7.0.7-8 Q16 x86_64 20171015 it fails as follows:
composite: insufficient image data in file `/dev/fd/63' @ error/png.c/ReadPNGImage/4220.
composite: `some-image.jpg' @ error/composite.c/CompositeImageCommand/1613.
It's possible to work around the problem by using a temporary file, but it's a pain--and avoiding temp files is the whole point of pipes.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: composite fails on /dev/fd/nn
You are on IM 7. Things have changed a bit since IM 6. Use magick in place of convert. Also put magick before composite, identify, montage, mogrify, etc.
I would really suggest you get out of the habit of using the limited composite and start using magick ... -compose -composite in its place. It is much more flexible and allows you to avoid the redirect from a second convert by using parenthesis processing.
try
if on Windows, remove the \ escapes.
See http://www.imagemagick.org/Usage/compose/#watermark
and
http://imagemagick.org/script/porting.php#cli
I would really suggest you get out of the habit of using the limited composite and start using magick ... -compose -composite in its place. It is much more flexible and allows you to avoid the redirect from a second convert by using parenthesis processing.
try
Code: Select all
magick some-image.jpg \( -size 200 label:abcdefg \) -define compose:args=15 -composite result.png
See http://www.imagemagick.org/Usage/compose/#watermark
and
http://imagemagick.org/script/porting.php#cli
Re: composite fails on /dev/fd/nn
Thanks for the pointer and the workaround.
However, let's be clear that it's still a bug. Backwards compatibility has been broken, and existing software that depends on the old feature is failing, so the bug still needs to be fixed.
However, let's be clear that it's still a bug. Backwards compatibility has been broken, and existing software that depends on the old feature is failing, so the bug still needs to be fixed.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: composite fails on /dev/fd/nn
If you use IM 7, then things have changed. You cannot use old convert syntax. Try
If you want to use the old convert and composite syntax, then you will have to back down to IM 6.
Code: Select all
magick composite png:<(magick -size 200 label:abcdefg png:-) -watermark 15 some-image.jpg > /dev/null
Re: composite fails on /dev/fd/nn
Can post a command that we can copy / paste under Bash that works. Your current command fails to grok under Bash. If we can reproduce the problem, we will attempt to patch it.
Re: composite fails on /dev/fd/nn
How does it fail on bash?
I just copied and pasted from my Web browser into bash, and it worked (or rather failed) just fine (mallet:501> is the prompt):
mallet:501> composite png:<(convert -size 200 label:abcdefg png:-) -watermark 15 some-image.jpg > /dev/null
composite: insufficient image data in file `/dev/fd/63' @ error/png.c/ReadPNGImage/4220.
composite: `some-image.jpg' @ error/composite.c/CompositeImageCommand/1613.
I didn't even need to replace some-image.jpg with the name of a real image.
I just copied and pasted from my Web browser into bash, and it worked (or rather failed) just fine (mallet:501> is the prompt):
mallet:501> composite png:<(convert -size 200 label:abcdefg png:-) -watermark 15 some-image.jpg > /dev/null
composite: insufficient image data in file `/dev/fd/63' @ error/png.c/ReadPNGImage/4220.
composite: `some-image.jpg' @ error/composite.c/CompositeImageCommand/1613.
I didn't even need to replace some-image.jpg with the name of a real image.
Last edited by gkuenning on 2017-10-23T11:53:54-07:00, edited 1 time in total.
Re: composite fails on /dev/fd/nn
fwm42, I think you misunderstand the entire concept of backwards compatibility. So here's a quick primer: if a command is used by 1000 sites, and it takes each site 30 minutes to adapt to a change that breaks existing code, then 500 hours of people time have been wasted. If maintaining compatibility would have taken 10 hours, then it's a 50-to-1 loss in productivity.fmw42 wrote: ↑2017-10-19T15:22:39-07:00 If you use IM 7, then things have changed. You cannot use old convert syntax. Try
If you want to use the old convert and composite syntax, then you will have to back down to IM 6.Code: Select all
magick composite png:<(magick -size 200 label:abcdefg png:-) -watermark 15 some-image.jpg > /dev/null
I'm pretty sure ImageMagick is used by a lot more than 1000 people.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: composite fails on /dev/fd/nn
ImageMagick 7 is different from ImageMagick 6. There are things that will not be backward compatible. I think you can install the legacy components and still use the old code.
But I will leave this between you and the ImageMagick developers to discuss.
But I will leave this between you and the ImageMagick developers to discuss.
Re: composite fails on /dev/fd/nn
Fwm42, maybe someday when you've experienced the other side for yourself you'll have a clearer perspective.
But FWIW your suggestion fails in exactly the same way--which is hardly surprising, since composite and convert are just symlinks to magick.
But FWIW your suggestion fails in exactly the same way--which is hardly surprising, since composite and convert are just symlinks to magick.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: composite fails on /dev/fd/nn
composite is not just a symlink. You have to preface it with magick in IM 7, since magick is the only thing really new and composite is still the old one. So you have to call it from magick. The convert command can still be used if you have a symlink between convert to magick in IM 7. Or you can just install the legacy IM 6. But I am not an expert on symlinks and other stuff like this. But see http://imagemagick.org/script/porting.php#cli.
In fact, I have over 300 scripts that I have had to deal with to be sure that they run properly under IM 7 as well as IM 6 (see my link at the bottom of this message box). So I have had to put in version tests and do different things where needed. So I am familiar with the importance of backward compatibility. I have been working with the IM developers to make this as transparent as possible. But there are things in IM 7 that are different. I have had to change a number of things in my scripts to be compatible with both versions. One of them is not using composite. However, I still have to make use of identify. In my scripts I have to put in version tests so that in IM 6 it is identify, but in IM 7 it is magick identify. This is true for montage and mogrify as well. All my scripts still keep convert syntax, since it is just a symlink to magick.
I sympathize with you. But I have completely gotten away from the use of composite, since convert ... -composite is so much more flexible. What you have with the redirect from one convert to a composite can be done in one convert command and thus no need to redirect that part.
But I do understand your situation.
Perhaps the IM developers can help you further. I am not a software engineer. I only do bash scripting with ImageMagick.
In fact, I have over 300 scripts that I have had to deal with to be sure that they run properly under IM 7 as well as IM 6 (see my link at the bottom of this message box). So I have had to put in version tests and do different things where needed. So I am familiar with the importance of backward compatibility. I have been working with the IM developers to make this as transparent as possible. But there are things in IM 7 that are different. I have had to change a number of things in my scripts to be compatible with both versions. One of them is not using composite. However, I still have to make use of identify. In my scripts I have to put in version tests so that in IM 6 it is identify, but in IM 7 it is magick identify. This is true for montage and mogrify as well. All my scripts still keep convert syntax, since it is just a symlink to magick.
I sympathize with you. But I have completely gotten away from the use of composite, since convert ... -composite is so much more flexible. What you have with the redirect from one convert to a composite can be done in one convert command and thus no need to redirect that part.
But I do understand your situation.
Perhaps the IM developers can help you further. I am not a software engineer. I only do bash scripting with ImageMagick.