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?".
Artman
Posts: 13
Joined: 2016-12-14T04:44:21-07:00
Authentication code: 1151

Make png image semi transparent

Post by Artman » 2016-12-14T04:59:11-07:00

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?

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

Re: Make png image semi transparent

Post by snibgo » 2016-12-14T05:24:47-07:00

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
snibgo's IM pages: im.snibgo.com

Artman
Posts: 13
Joined: 2016-12-14T04:44:21-07:00
Authentication code: 1151

Re: Make png image semi transparent

Post by Artman » 2016-12-14T06:04:26-07:00

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

User avatar
GeeMack
Posts: 722
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

Re: Make png image semi transparent

Post by GeeMack » 2016-12-14T10:51:56-07:00

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;" />

Artman
Posts: 13
Joined: 2016-12-14T04:44:21-07:00
Authentication code: 1151

Re: Make png image semi transparent

Post by Artman » 2016-12-14T11:50:43-07:00

Yep. Now its work. Thanks a lot to everyone.
ps: GeeMack, i'm only user in this specific site but thanks for advise anyway.

Artman
Posts: 13
Joined: 2016-12-14T04:44:21-07:00
Authentication code: 1151

Re: Make png image semi transparent

Post by Artman » 2016-12-14T12:01:25-07:00

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.

User avatar
fmw42
Posts: 25662
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Make png image semi transparent

Post by fmw42 » 2016-12-14T13:15:16-07:00

GIF only supports binary transparency (on or off). It does not support values other than 100% and 0%.

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 » 2016-12-14T13:16:55-07:00

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.

Artman
Posts: 13
Joined: 2016-12-14T04:44:21-07:00
Authentication code: 1151

Re: Make png image semi transparent

Post by Artman » 2016-12-14T14:35:57-07:00

test
Image
second test
Image

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


thanks to all so far.

Artman
Posts: 13
Joined: 2016-12-14T04:44:21-07:00
Authentication code: 1151

Re: Make png image semi transparent

Post by Artman » 2016-12-15T05:19:28-07:00

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

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

Re: Make png image semi transparent

Post by snibgo » 2016-12-15T05:50:59-07:00

See the "opaque" and "composite" commands at http://www.imagemagick.org/script/comma ... ptions.php
snibgo's IM pages: im.snibgo.com

Artman
Posts: 13
Joined: 2016-12-14T04:44:21-07:00
Authentication code: 1151

Re: Make png image semi transparent

Post by Artman » 2016-12-15T09:59:55-07:00

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.

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

Re: Make png image semi transparent

Post by snibgo » 2016-12-15T10:18:23-07:00

Converting a vector (SVG) file to pixels, then enlarging that ("-resize 230%") will give a fuzzy result. I suggest you use "-density" instead.
snibgo's IM pages: im.snibgo.com

Artman
Posts: 13
Joined: 2016-12-14T04:44:21-07:00
Authentication code: 1151

Re: Make png image semi transparent

Post by Artman » 2016-12-17T15:14:50-07:00

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?

Artman
Posts: 13
Joined: 2016-12-14T04:44:21-07:00
Authentication code: 1151

Re: Make png image semi transparent

Post by Artman » 2016-12-17T15:24:13-07:00

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?

Post Reply