how to change the opacity value of a png file?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: how to change the opacity value of a png file?
Please provide a link to the image you want to change? I don't know if you are trying to change a constant opacity in the image or a gradient opacity in the image? Please clarify.
see transparent canvas at http://www.imagemagick.org/Usage/canvas/#other
especially
convert test.png -matte -channel A -evaluate set 0 +channel trans_evaluate.png
change the set value to some value between 0 and 1
see transparent canvas at http://www.imagemagick.org/Usage/canvas/#other
especially
convert test.png -matte -channel A -evaluate set 0 +channel trans_evaluate.png
change the set value to some value between 0 and 1
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: how to change the opacity value of a png file?
if this is to change a gradient transparency from 0-100% to 0-70%, then try
convert test.png -matte -channel A +level 0,70% +channel trans_evaluate.png
if this is the wrong way opacity vs transparency, then use +level 30,100%
convert test.png -matte -channel A +level 0,70% +channel trans_evaluate.png
if this is the wrong way opacity vs transparency, then use +level 30,100%
Re: how to change the opacity value of a png file?
original png
code:
preview in firefox
why the png is completly transparent ?
code:
Code: Select all
<?php
exec("convert opacity.png -matte -channel A -evaluate set 0.5 +channel laji.png");
echo "<img src='opacity.png'/>";
echo "<img src='laji.png'/>";
?>
<style type="text/css">
html{background-color:gray;}
</style>
why the png is completly transparent ?
Re: how to change the opacity value of a png file?
not to change the contract , I only want to chage the png's opacity ,from 100% to 74% ,such as what i showed in photoshop above .but your code output a completly transparent png . Why?
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: how to change the opacity value of a png file?
I'm suprised there isn't a broken image!
Can the PHP write in that directory. is there a transparent image in that directory that is not writable by the PHP?
Better to check these thing without the complication of web page processing.
Can the PHP write in that directory. is there a transparent image in that directory that is not writable by the PHP?
Better to check these thing without the complication of web page processing.
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: how to change the opacity value of a png file?
please provide a link to your png image (not in a screen snap) so we can see what is really happening.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: how to change the opacity value of a png file?
Your png file is composed of a white base image and a gradient alpha channel. So there is no one alpha value in that file. So what is that you want to do. If you make the opacity/transparency a constant, then you will lose your gradient.
To see this, look at the results of:
convert opacity-2.png -alpha off opacity-2_aoff.png
convert opacity-2.png -alpha extract opacity-2_alpha.pn
You would be better making a gradient base image and then making the alpha channel some constant say 70% as was describe above.
Try this:
convert -size 128x128 gradient: -matte -channel A -evaluate set 70% -channel rgba tmp.png
or
convert -size 128x128 gradient: -matte -channel A -evaluate set 30% -channel rgba tmp.png
Not sure which way you want it.
To see this, look at the results of:
convert opacity-2.png -alpha off opacity-2_aoff.png
convert opacity-2.png -alpha extract opacity-2_alpha.pn
You would be better making a gradient base image and then making the alpha channel some constant say 70% as was describe above.
Try this:
convert -size 128x128 gradient: -matte -channel A -evaluate set 70% -channel rgba tmp.png
or
convert -size 128x128 gradient: -matte -channel A -evaluate set 30% -channel rgba tmp.png
Not sure which way you want it.
Re: how to change the opacity value of a png file?
Thank you , it helps