Make png image semi transparent

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?".
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Make png image semi transparent

Post by fmw42 »

Artman wrote:with this example also i have a problem under windows

Code: Select all

.\bin\magick -size 320x100 xc:lightblue -font georgia -pointsize 72 ^
            -draw "fill black text 27,67 "Led Zeppelin" ^
                              text 25,68 "Led Zeppelin" ^
                              text 23,67 "Led Zeppelin" ^
                              text 22,65 "Led Zeppelin" ^
                              text 23,63 "Led Zeppelin" ^
                              text 25,62 "Led Zeppelin" ^
                              text 27,63 "Led Zeppelin" ^
                              text 28,65 "Led Zeppelin" ^
                   fill white text 25,65 "Led Zeppelin" " ^
			7.png
what wrong?
Use single quotes around your Led Zeppelin, not double quotes. Your double quotes for your text conflict with the double quotes around the draw command.

Use double quotes for the -draw "..." and single quotes for the actual text. I do not think you can do it the other way around.


So try:

Code: Select all

.\bin\magick -size 320x100 xc:lightblue -font georgia -pointsize 72 ^
            -draw "fill black text 27,67 'Led Zeppelin' ^
                              text 25,68 'Led Zeppelin' ^
                              text 23,67 'Led Zeppelin' ^
                              text 22,65 'Led Zeppelin' ^
                              text 23,63 'Led Zeppelin' ^
                              text 25,62 'Led Zeppelin' ^
                              text 27,63 'Led Zeppelin' ^
                              text 28,65 'Led Zeppelin' ^
                   fill white text 25,65 'Led Zeppelin' " ^
         7.png


This works fine for me in unix syntax:

Code: Select all

magick -size 320x100 xc:lightblue -font georgia -pointsize 72 \
-draw "fill black text 27,67 'Led Zeppelin' \
text 25,68 'Led Zeppelin' \
text 23,67 'Led Zeppelin' \
text 22,65 'Led Zeppelin' \
text 23,63 'Led Zeppelin' \
text 25,62 'Led Zeppelin' \
text 27,63 'Led Zeppelin' \
text 28,65 'Led Zeppelin' \
fill white text 25,65 'Led Zeppelin'" \
7.png
Except 320 is too short and so the text is cut off.

See examples at http://www.imagemagick.org/Usage/text/#draw
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: Make png image semi transparent

Post by glennrp »

Artman wrote:with this example also i have a problem under windows

Code: Select all

.\bin\magick -size 320x100 xc:lightblue -font georgia -pointsize 72 ^
            -draw "fill black text 27,67 "Led Zeppelin" ^
                              text 25,68 "Led Zeppelin" ^
                              text 23,67 "Led Zeppelin" ^
                              text 22,65 "Led Zeppelin" ^
                              text 23,63 "Led Zeppelin" ^
                              text 25,62 "Led Zeppelin" ^
                              text 27,63 "Led Zeppelin" ^
                              text 28,65 "Led Zeppelin" ^
                   fill white text 25,65 "Led Zeppelin" " ^
			7.png
what wrong?
You have quotes inside quotes. Either "escape" the inner quotes or use single quotes around the
entire draw option. The problem you are having is with Windows syntax, so I can't
help you with the details.
Artman
Posts: 13
Joined: 2016-12-14T04:44:21-07:00
Authentication code: 1151

Re: Make png image semi transparent

Post by Artman »

thanks guys for your replays. its work for me under windows but only as single line.
its question about that much easier work with formatted text.

Code: Select all

.\bin\magick -size 320x100 xc:lightblue -font georgia -pointsize 72 ^
            -draw "fill black text 27,67 'Led Zeppelin' text 25,68 'Led Zeppelin' text 23,67 'Led Zeppelin' text 22,65 'Led Zeppelin' text 23,63 'Led Zeppelin' text 25,62 'Led Zeppelin' text 27,63 'Led Zeppelin' text 28,65 'Led Zeppelin' fill white text 25,65 'Led Zeppelin' " ^
			LZ.png
thanks again.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Make png image semi transparent

Post by fmw42 »

Does this work?

Code: Select all

.\bin\magick -size 320x100 xc:lightblue -font georgia -pointsize 72 ^
-draw "fill black text 27,67 'Led Zeppelin' ^
text 25,68 'Led Zeppelin' ^
text 23,67 'Led Zeppelin' ^
text 22,65 'Led Zeppelin' ^
text 23,63 'Led Zeppelin' ^
text 25,62 'Led Zeppelin' ^
text 27,63 'Led Zeppelin' ^
text 28,65 'Led Zeppelin' ^
fill white text 25,65 'Led Zeppelin' " ^
7.png
It is possible that copy and paste changes the spaces and line endings. Be sure you have no space after ^

It is also possible that using leading tabs in place of spaces is causing your issue.
Artman
Posts: 13
Joined: 2016-12-14T04:44:21-07:00
Authentication code: 1151

Re: Make png image semi transparent

Post by Artman »

fmw42 wrote:Does this work?

Code: Select all

.\bin\magick -size 320x100 xc:lightblue -font georgia -pointsize 72 ^
-draw "fill black text 27,67 'Led Zeppelin' ^
text 25,68 'Led Zeppelin' ^
text 23,67 'Led Zeppelin' ^
text 22,65 'Led Zeppelin' ^
text 23,63 'Led Zeppelin' ^
text 25,62 'Led Zeppelin' ^
text 27,63 'Led Zeppelin' ^
text 28,65 'Led Zeppelin' ^
fill white text 25,65 'Led Zeppelin' " ^
7.png
It is possible that copy and paste changes the spaces and line endings. Be sure you have no space after ^

It is also possible that using leading tabs in place of spaces is causing your issue.
its not work coz cli under windows have many specific rules.
but i consulted with one top pro in windows and him give me good solution:

Code: Select all

.\bin\magick -size 470x100 xc:lightblue ^
			-font georgia -pointsize 72 ^
			-fill black ^
			-draw "text 27,67 'Led Zeppelin'" ^
			-draw "text 25,68 'Led Zeppelin'" ^
			-draw "text 23,67 'Led Zeppelin'" ^
			-draw "text 22,65 'Led Zeppelin'" ^
			-draw "text 23,63 'Led Zeppelin'" ^
			-draw "text 25,62 'Led Zeppelin'" ^
			-draw "text 27,63 'Led Zeppelin'" ^
			-draw "text 28,65 'Led Zeppelin'" ^
			-fill white ^
			-draw "text 25,65 'Led Zeppelin'" ^
         LZ3.png

as you can see this code proper formated and easy to read and understand
and this code work like charm under windows.
all about put couple more draw to avoid escape characters that windows cli not so like.
i believe its best solution. thanks again for your time.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Make png image semi transparent

Post by snibgo »

The problem was that the command had a "quoted string" split between lines, with a caret ^ at the line ends. That works in bash but not Windows.
snibgo's IM pages: im.snibgo.com
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Make png image semi transparent

Post by anthony »

General... Masks as colored Shapes..
http://www.imagemagick.org/Usage/masking/#shapes

But in your case just using +level-colors Gold would convert teh black shape to a Gold Shape
http://www.imagemagick.org/Usage/color_ ... vel-colors

Or a more complex and older technique -fill Gold -colorize 100%
http://www.imagemagick.org/Usage/color_mods/#colorize

Strangely colorize is preserving the alpha chanel of the image. My Examples indicate that it should also tint the fully transparent areas!
Is this a bug?
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Make png image semi transparent

Post by fmw42 »

Strangely colorize is preserving the alpha chanel of the image. My Examples indicate that it should also tint the fully transparent areas!
Is this a bug?
Somewhere along the way, -colorize changed. You have to specify -channel rgba -fill "rgba(rr,gg,bb,aa)" -colorize yyy if you want to include the alpha channel.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Make png image semi transparent

Post by anthony »

So it has gone back to what it was before v6.7.9 where it pretty much ignored the alpha channel.
making it equivelent to +level-color {color}
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Make png image semi transparent

Post by fmw42 »

I do not recall when nor what the reason was. Sorry! Perhaps the changelog says.
Post Reply