problem with transparency in composite command
problem with transparency in composite command
Hi,
I use a composite command with displacement map: composite map.png 1.png +matte -displace 0x30 2.png
1.png has transparent areas, but in 2.png all areas, that should be transparent, becomes black. How can I solve this problem?
I use a composite command with displacement map: composite map.png 1.png +matte -displace 0x30 2.png
1.png has transparent areas, but in 2.png all areas, that should be transparent, becomes black. How can I solve this problem?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: problem with transparency in composite command
I am not sure about transparency handling in -displace as that may not work or be very tricky due to the values in the transparency channel, but you can try adding -channel rgba before -matte NOT +matte. Note +matte turns off the alpha/transparency channel. If that does not work, hopefully Anthony can clarify. So write back and let us know if it works and so that he will see your reply.
Also be sure that map.png is single channel, so replace map.png with \( map.png -channel g \)
composite \(map.png -channel g \) \( 1.png -channel rgba -matte \) -displace 0x30 2.png
If this does not work, you may be able to handle it using the slower -fx. See viewtopic.php?f=1&t=12015
Also be sure that map.png is single channel, so replace map.png with \( map.png -channel g \)
composite \(map.png -channel g \) \( 1.png -channel rgba -matte \) -displace 0x30 2.png
If this does not work, you may be able to handle it using the slower -fx. See viewtopic.php?f=1&t=12015
Re: problem with transparency in composite command
Thanks a lot, but in this way it also does not work properly. With composite command I have such problem as htvu in that topic - image id not distorted, only shifted by Y on 30px.
And when I use -fx, distortion strongly differs from what is carried out by 'composite':
1.png
map.png
composite map.png 1.png -displace 0x30 2.png
composite map.png -channel g 1.png -channel rgba -matte -displace 0x30 2.png
convert 1.png map.png -channel RGBA -fx \"p{i,v.g*h}\" 2.png
And when I use -fx, distortion strongly differs from what is carried out by 'composite':
1.png
map.png
composite map.png 1.png -displace 0x30 2.png
composite map.png -channel g 1.png -channel rgba -matte -displace 0x30 2.png
convert 1.png map.png -channel RGBA -fx \"p{i,v.g*h}\" 2.png
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: problem with transparency in composite command
You may need to use the parentheses as I originally specified to ensure that each image uses the channel(s) required. If this does not work, then possibly -displace cannot handle transparency. But I will defer to Anthony on that.composite map.png -channel g 1.png -channel rgba -matte -displace 0x30 2.png
composite \( map.png -channel g \) \( 1.png -channel rgba -matte \) -displace 0x30 2.png
see
http://www.imagemagick.org/Usage/basics/#parenthesis
If you are on Windows, then see also
http://www.imagemagick.org/Usage/api/#windows
as Windows uses different conventions and the parentheses don't need the \ escape
This was meant only as an example of one particular distortion and shows how to handle the transparency. You need to build your own -fx expression to do the distortion as you need it. But you see it does work with transparency.convert 1.png map.png -channel RGBA -fx \"p{i,v.g*h}\" 2.png
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: problem with transparency in composite command
The -fx version you are using is doing an absolute distortion. -displace is doing a relative distortion. The results is naturally quite different. You were just lucky they weren't far more different than that you actually achieved.ghost wrote:Thanks a lot, but in this way it also does not work properly. With composite command I have such problem as htvu in that topic - image id not distorted, only shifted by Y on 30px.
And when I use -fx, distortion strongly differs from what is carried out by 'composite':
See http://www.imagemagick.org/Usage/distorts/#lut
for a general introduction to the two different methods.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: problem with transparency in composite command
I use it, under Windows, but brackets doesn't do any effect in this expression.fmw42 wrote:You may need to use the parentheses as I originally specified to ensure that each image uses the channel(s) required. If this does not work, then possibly -displace cannot handle transparency. But I will defer to Anthony on that.
Thank you for your help, but I have already found a Barrel distortion, that gives an effect very similar to my needs
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: problem with transparency in composite command
IM as of 6.4.2-4 already has a barrel distortion. see http://www.imagemagick.org/Usage/distorts/#barrelghost wrote:[
Thank you for your help, but I have already found a Barrel distortion, that gives an effect very similar to my needs
Also my texteffect script does the same, using an barrel inverse polynomial (but not yet converted to the new IM barrelinverse). see http://www.fmwconcepts.com/imagemagick/index.html
Re: problem with transparency in composite command
Yes, I also meant this, and use nowfmw42 wrote:IM as of 6.4.2-4 already has a barrel distortion. see http://www.imagemagick.org/Usage/distorts/#barrel
Thanks, I downloaded Texteffect but in my Windows under Cygwin it doesn't workAlso my texteffect script does the same, using an barrel inverse polynomial (but not yet converted to the new IM barrelinverse). see http://www.fmwconcepts.com/imagemagick/index.html
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: problem with transparency in composite command
Can you tell me where and or how it is failing? Does your Cygwin include the bc calculator?Also my texteffect script does the same, using an barrel inverse polynomial (but not yet converted to the new IM barrelinverse). see http://www.fmwconcepts.com/imagemagick/index.html
Thanks, I downloaded Texteffect but in my Windows under Cygwin it doesn't work
What was your command line for using my texteffect?
It might be an IM version issue? But I would need to know what you were doing to check that.
Re: problem with transparency in composite command
Code: Select all
$ texteffect -t "SOME CONVEX TEXT" -s outline -e convex -d 0.35 -f Arial -p 48 -c skyblue -b white -o black -l 1 -u lightpink test.png
/usr/bin/texteffect: line 825: [: : integer expression expected
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: problem with transparency in composite command
Hello Ghost,
Thanks for the reply and notification. However, this line simply refers to a test of the IM version. But it requires the use of SED. Does your Cygwin include SED?
Try this:
im_version=`convert -list configure | \
sed '/^LIB_VERSION_NUMBER /!d; s//,/; s/,/,0/g; s/,0*\([0-9][0-9]\)/\1/g'`
echo "im_version=$im_version"
It should give something like:
im_version=06040308
Let me know what you get from this test. I suspect you do not have SED and so am getting an empty string for the result. Therefore the test of your version against the threshold version for using -distort vs -fx is giving an error.
Fred
ghost wrote:I use 6.4.3. bc installed.Code: Select all
$ texteffect -t "SOME CONVEX TEXT" -s outline -e convex -d 0.35 -f Arial -p 48 -c skyblue -b white -o black -l 1 -u lightpink test.png /usr/bin/texteffect: line 825: [: : integer expression expected
Thanks for the reply and notification. However, this line simply refers to a test of the IM version. But it requires the use of SED. Does your Cygwin include SED?
Try this:
im_version=`convert -list configure | \
sed '/^LIB_VERSION_NUMBER /!d; s//,/; s/,/,0/g; s/,0*\([0-9][0-9]\)/\1/g'`
echo "im_version=$im_version"
It should give something like:
im_version=06040308
Let me know what you get from this test. I suspect you do not have SED and so am getting an empty string for the result. Therefore the test of your version against the threshold version for using -distort vs -fx is giving an error.
Fred
Re: problem with transparency in composite command
Hm, it gives an empty string, but I have SED 4.1.5-2 in my Cygwin :/
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: problem with transparency in composite command
Very strange. Can you try other SED commands? Perhaps part of this SED command is not valid for your version of Cygwin SED?ghost wrote:Hm, it gives an empty string, but I have SED 4.1.5-2 in my Cygwin :/
Try removing the \ and make it one long line?
im_version=`convert -list configure | sed '/^LIB_VERSION_NUMBER /!d; s//,/; s/,/,0/g; s/,0*\([0-9][0-9]\)/\1/g'`
Also try the following, which replaces SED with GREP, etc. I can change the script to substitute this, if it works for you.
im_version="0$(convert -list configure | grep 'LIB_VERSION_NUMBER' | cut -d\ -f2 | tr ',' '0')"
echo "$im_version"
or
im_version="0`convert -list configure | grep 'LIB_VERSION_NUMBER' | cut -d\ -f2 | tr ',' '0'`"
echo "$im_version"
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: problem with transparency in composite command
Just a word of caution. I do not recommend that 'grep' solution as it assumes that each of the version/patch numbers will be a single digit. That has not and probably will NOT always be the case, though it usually is.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: problem with transparency in composite command
anthony wrote:Just a word of caution. I do not recommend that 'grep' solution as it assumes that each of the version/patch numbers will be a single digit. That has not and probably will NOT always be the case, though it usually is.
Good point. I had not thought of that, but have seen some minor version numbers above 9.