Page 1 of 2

Make png image semi transparent

Posted: 2016-12-14T04:59:11-07:00
by Artman
Hello all, I read in ImageMagick v6 Examples -- Color Basics and Channels
what i can draw images semi transparent.

Code: Select all

convert -size 50x50    xc:'#00FF0030'   color_hex_5.png
if i can convert existing png image to semi transparent?
so while it used on web page will be possible see page background?

Re: Make png image semi transparent

Posted: 2016-12-14T05:24:47-07:00
by snibgo
Multiply the alpha channel by a number between zero and one, eg by 0.75 to give an opaque image 75% opacity (25% transparency):

Code: Select all

convert in.png -channel A -evaluate Multiply 0.75 +channel out.png

Re: Make png image semi transparent

Posted: 2016-12-14T06:04:26-07:00
by Artman
Sir, while i use this command on this Image sweet guy its seems not work.
Image
but if i use as IN.PNG result of this command

Code: Select all

magick 000.png -alpha set -gravity center -extent 90x90 ^
          badge_mask.png -compose DstIn -composite ^
          badge_shading.png -compose Over -composite kitty.png
Image
its work! magick!
Image
you can explain to me that i miss please.
my soft

Code: Select all

ImageMagick-7.0.3-10-portable-Q16-x64

Re: Make png image semi transparent

Posted: 2016-12-14T10:51:56-07:00
by GeeMack
Artman wrote:you can explain to me that i miss please.
Using snibgo's command example above, try putting "-alpha set" right after you read in the input image, like this...

Code: Select all

convert in.png -alpha set -channel A -evaluate Multiply 0.75 +channel out.png
Also, although unrelated to ImageMagick, you can make almost any image on a web page semi-transparent by applying a style. That can be done on the CSS, or directly in the HTML tag for a particular image. Something like this should work on nearly any modern browser...

Code: Select all

<img src="imagepath/image.png" alt="My Transparent Picture" style="opacity: 0.5;" />

Re: Make png image semi transparent

Posted: 2016-12-14T11:50:43-07:00
by Artman
Yep. Now its work. Thanks a lot to everyone.
ps: GeeMack, i'm only user in this specific site but thanks for advise anyway.

Re: Make png image semi transparent

Posted: 2016-12-14T12:01:25-07:00
by Artman
I have one more question. if its possible use this technique in GIF?
I never see semi transparent gif and i try now but its give just white image.

Re: Make png image semi transparent

Posted: 2016-12-14T13:15:16-07:00
by fmw42
GIF only supports binary transparency (on or off). It does not support values other than 100% and 0%.

Re: Make png image semi transparent

Posted: 2016-12-14T13:16:55-07:00
by glennrp
Artman wrote:I have one more question. if its possible use this technique in GIF?
I never see semi transparent gif and i try now but its give just white image.
GIF only offers full transparency. To get partial transparency you'd need to convert your GIF to PNG and then proceed.

Re: Make png image semi transparent

Posted: 2016-12-14T14:35:57-07:00
by Artman
test
Image
second test
Image

GIF created from semi transparent PNG's just completely transparent.


thanks to all so far.

Re: Make png image semi transparent

Posted: 2016-12-15T05:19:28-07:00
by Artman
Hello again. Guys, maybe you can provide help to me with something else?
please tell me witch command will color from black to gold this image Image
and witch command will put together two images like this Image

Re: Make png image semi transparent

Posted: 2016-12-15T05:50:59-07:00
by snibgo
See the "opaque" and "composite" commands at http://www.imagemagick.org/script/comma ... ptions.php

Re: Make png image semi transparent

Posted: 2016-12-15T09:59:55-07:00
by Artman
snibgo thanks. i read and create next batch file

Code: Select all

magick ../img/background.png ^
	( ../img/overlay2.png -resize 230% ) ^
	-gravity center ^
	-composite ^
	../composite.png
the result look like this
Image
not so best. i download vector http://www.clker.com/cliparts/d/7/J/8/r/Z/percy.svg
and run command

Code: Select all

magick  ../img/background.png ^
	( ../img/overlay.svg -resize 55% ) ^
	-gravity center ^
	-composite ^
	../composite2.png
result:
Image
tell me please how i can fix it. i never not work with vector.

Re: Make png image semi transparent

Posted: 2016-12-15T10:18:23-07:00
by snibgo
Converting a vector (SVG) file to pixels, then enlarging that ("-resize 230%") will give a fuzzy result. I suggest you use "-density" instead.

Re: Make png image semi transparent

Posted: 2016-12-17T15:14:50-07:00
by Artman
snibgo wrote:Converting a vector (SVG) file to pixels, then enlarging that ("-resize 230%") will give a fuzzy result. I suggest you use "-density" instead.
thank you for help.


i not want open new topic for something little so i ask here:
i try examples from guide and one not work for me

Code: Select all

.\bin\magick -size 320x100 xc:lightblue -font georgia -pointsize 42 ^
			-fill black -draw text '28,68 "Led Zeppelin"' ^
			-fill white -draw text '25,65 "Led Zeppelin"' ^
			font_shadow.png
console output:

Code: Select all

magick: NonconformingDrawingPrimitiveDefinition `text' @ error/draw.c/DrawImage/3269.
tell me please how i make it work under windows?

Re: Make png image semi transparent

Posted: 2016-12-17T15:24:13-07:00
by Artman
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?