Dirty Transparency
Dirty Transparency
Good afternoon!
Prompt, please, as it is possible to make such through ImageMagick?
Dirty Transparency
Prompt, please, as it is possible to make such through ImageMagick?
Dirty Transparency
Re: Dirty Transparency
It is necessary to me, something on similarity of it
http://www.translate.ru/links/8020eb12
http://www.translate.ru/links/8020eb12
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Dirty Transparency
try
convert image.png \
\( -clone 0 -alpha extract \) \
\( -clone 0 -clone 1 -compose multiply -composite \) \
-delete 0 +swap -alpha off -compose copy_opacity -composite -depth 8 image_new.png
or
convert image.png \
\( -clone 0 -alpha extract \) \
\( -clone 0 -clone 1 -compose multiply -composite \) \
-delete 0 +swap -alpha off -compose copy_opacity -composite -define png:color-type=2 -define png:bit-depth=8 image_new.png
see http://www.imagemagick.org/Usage/formats/#png_write
This will make all the transparent pixels black.
If on windows, see http://www.imagemagick.org/Usage/windows/ for syntax differences with unix.
But I am not sure this will make the file smaller in IM. In fact, it may still be larger as IM is not very good at png optimization. You may still need to use one of the non-IM utilities to compress the png to get the benefit. See http://www.imagemagick.org/Usage/formats/#png_non-im
Let us know if this helps.
P.S. In IM you can remove the alpha channel to see if the transparent pixels are already black by
convert image.png -alpha off image_no_alpha.png
convert image.png \
\( -clone 0 -alpha extract \) \
\( -clone 0 -clone 1 -compose multiply -composite \) \
-delete 0 +swap -alpha off -compose copy_opacity -composite -depth 8 image_new.png
or
convert image.png \
\( -clone 0 -alpha extract \) \
\( -clone 0 -clone 1 -compose multiply -composite \) \
-delete 0 +swap -alpha off -compose copy_opacity -composite -define png:color-type=2 -define png:bit-depth=8 image_new.png
see http://www.imagemagick.org/Usage/formats/#png_write
This will make all the transparent pixels black.
If on windows, see http://www.imagemagick.org/Usage/windows/ for syntax differences with unix.
But I am not sure this will make the file smaller in IM. In fact, it may still be larger as IM is not very good at png optimization. You may still need to use one of the non-IM utilities to compress the png to get the benefit. See http://www.imagemagick.org/Usage/formats/#png_non-im
Let us know if this helps.
P.S. In IM you can remove the alpha channel to see if the transparent pixels are already black by
convert image.png -alpha off image_no_alpha.png
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Dirty Transparency
Does this do what is wanted?
convert image.png -background Black -alpha Background image_new.jpg
convert image.png -background Black -alpha Background image_new.jpg
snibgo's IM pages: im.snibgo.com
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Dirty Transparency
snibgo wrote:Does this do what is wanted?
convert image.png -background Black -alpha Background image_new.jpg
Alan,
Nice shortcut. But you really mean image_new.png.
convert image.png -background Black -alpha Background image_new.png
But I still get the same size output as input with yours or my first method and only a small decrease with my second method (via the -defines). I believe some external png optimising utility will be necessary to actually get the size reduction.
Fred
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Dirty Transparency
Yes, output should be to PNG, thanks Fred. (Can I have a new brain, please?)
I use pngcrush to compress pngs, but I don't know if it is better than the rest.
I use pngcrush to compress pngs, but I don't know if it is better than the rest.
snibgo's IM pages: im.snibgo.com
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Dirty Transparency
Can you specify what file sizes before and after pngcrush with the before and after images from the black background processing?snibgo wrote: I use pngcrush to compress pngs, but I don't know if it is better than the rest.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Dirty Transparency
Basically Dirty transparency, is when the transparency has many color values! that its it contains a lot of fully-transparent junk colors.lorents wrote:Good afternoon!
Prompt, please, as it is possible to make such through ImageMagick?
Dirty Transparency
The -alpha background setting will set all the fully-transparent colors to the current background color. A good background color is just black.
this and a few other techniques that do the same thing is given in
http://www.imagemagick.org/Usage/basics ... background
You can specify different compression types and techniques using -quality setting for PNG.
This is NOT a percentage! See http://www.imagemagick.org/Usage/formats/#png_quality
However pngcrush is still recommended as a final post-processing method.
You could generate a 'delegate' for pngcrush! Might make a good addition to the delegate configuration (and example of an output delegate)
http://www.imagemagick.org/Usage/files/#delegate_output
That same delegate could also include a convert command to automatically handle 'dirty transparency' too

If someone gives this a go, please contribute!
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: Dirty Transparency
I have not absolutely understood, how to me to make, that I have conceived.
I use Portable the version, and at me operating system Windows. And I should write a batch-file for this business
I use Portable the version, and at me operating system Windows. And I should write a batch-file for this business
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Dirty Transparency
Using as input:
http://media.smashingmagazine.com/cdn_s ... ample1.png
dirty-tr-sample1.png is 75458 bytes.
dirtyclean1.png is 29378 bytes.
Using pngcrush makes no significant difference for these files.
http://media.smashingmagazine.com/cdn_s ... ample1.png
dirty-tr-sample1.png is 75458 bytes.
Code: Select all
convert dirty-tr-sample1.png -background Black -alpha Background dirtyclean1.png
Using pngcrush makes no significant difference for these files.
snibgo's IM pages: im.snibgo.com
Re: Dirty Transparency
Many thanks, all have turned out
Re: Dirty Transparency
Whether prompt, please, as it is possible to learn is PNG a transparency, or not?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Dirty Transparency
convert image.png -format "%A" info:
Will return True or False
see http://www.imagemagick.org/script/escape.php
Will return True or False
see http://www.imagemagick.org/script/escape.php
Re: Dirty Transparency
thanks
Re: Dirty Transparency
Has noticed one strangeness into account PNG c a transparency.
If the picture is kept in PNG 32bit, and actually it PNG 24bit, i.e. in it there is no transparency. ImageMagick asserts that it is a picture with a transparency
Here a picture example
http://img2.immage.de/0707cddlogo.png
If the picture is kept in PNG 32bit, and actually it PNG 24bit, i.e. in it there is no transparency. ImageMagick asserts that it is a picture with a transparency
Here a picture example
http://img2.immage.de/0707cddlogo.png