Transparency usage story

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?".
Post Reply
Janek
Posts: 3
Joined: 2012-02-28T06:26:37-07:00
Authentication code: 8675308

Transparency usage story

Post by Janek »

Hi,

After long inactivity on ImageMagick I've upgraded binaries to ImageMagick-6.7.54, and I saw that some commands works different. Problem was with transparencies.
I've solved problem and now I can show you story of changes in transparency usage.
If you just want to put coloured text on transparent background, and save image to png you need:

before ImageMagick-6.5.23-Q8:

Code: Select all

convert -background transparent -pointsize 55 label:"test" outputPNG32.png
ImageMagick-6.5.23-Q8

Code: Select all

convert -background transparent -pointsize 55 label:"test" -define png:color-type=6 outputPNG32.png
ImageMagick-6.7.54-Q8

Code: Select all

convert -background transparent -virtual-pixel background -pointsize 55 label:"test" -define png:color-type=6 outputPNG32.png
Have you simpler and more version independent way for this task?
Last edited by Janek on 2012-02-29T00:58:05-07:00, edited 1 time in total.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Transparency usage story

Post by anthony »

Janek wrote:Hi,

After long inactivity on ImageMagick I've upgraded binaries to ImageMagick-6.7.54, and I saw that some commands works different. Problem was with transparencies.
I've solved problem and now I can show you story of changes in transparency usage.
If you just want to put coloured text on transparent background, and save image to png you need:

before ImageMagick-6.5.23-Q8: convert -background transparent -pointsize 55 label:"test" outputPNG32.png
ImageMagick-6.5.23-Q8 convert -background transparent -pointsize 55 label:"test" -define png:color-type=6 outputPNG32.png
ImageMagick-6.7.54-Q8 convert -background transparent -virtual-pixel background -pointsize 55 label:"test" -define png:color-type=6 outputPNG32.png

Have you simpler and more version independent way for this task?
I don't understand your need for the virtual-pixel setting (highlighted above).

Virtual pixels are used in operations such as blurs, convolve, morphology, distortions, and some FX user functions, where images are being referenced outside their normal 'real' boundaries.
See http://www.imagemagick.org/Usage/misc/#virtual-pixel
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Janek
Posts: 3
Joined: 2012-02-28T06:26:37-07:00
Authentication code: 8675308

Re: Transparency usage story

Post by Janek »

I don't know meaning of virtual-pixel operator. I'm don't understand too why this work, but example from ImageMagick-6.5.23-Q8 doesn't work in ImageMagick-6.7.54-Q8.
I'm just guessing how bring transparency and saw that virtual-pixel helps.

See that

Code: Select all

convert -background transparent -pointsize 55 label:"test" -define png:color-type=6 outputPNG32.png
doesn't produce transparent background in ImageMagick-6.7.54-Q8 and newer.

maybe this is bug

Here is comment for 6.7.5-4

Code: Select all

2012-02-08  6.7.5-4 Cristy  <quetzlzacatenango@image...>
  * Set image alpha channel for -virtual-pixel background and transparent.
  * Get tiff:fill-order as an image artifact, not an image option.

p.s. thank you for fast reply
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: Transparency usage story

Post by glennrp »

Janek wrote: Have you simpler and more version independent way for this task?
Instead of

Code: Select all

... -define png:color-type=6 outputPNG32.png
you can just write

Code: Select all

... PNG32:outputPNG32.png
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Transparency usage story

Post by anthony »

Janek wrote:See that

Code: Select all

convert -background transparent -pointsize 55 label:"test" -define png:color-type=6 outputPNG32.png
doesn't produce transparent background in ImageMagick-6.7.54-Q8 and newer.

maybe this is bug
Yes I would say this is a bug...

I can confirm that the lable comes out all black

Code: Select all

convert -background none -pointsize 55 label:"test" -verbose info:

Code: Select all

  ...
    Format: LABEL (Image label)
  Class: DirectClass
  Geometry: 90x63+0+0
  Resolution: 72x72
  Print size: 1.25x0.875
  Units: Undefined
  Type: Bilevel
  Base type: Bilevel
  Endianess: Undefined
  Colorspace: sRGB
  Depth: 16/1-bit
  Channel depth:
    gray: 1-bit
    alpha: 1-bit
  Channel statistics:
    Gray:
      min: 0 (0)
      max: 0 (0)
      mean: 0 (0)
      standard deviation: 0 (0)
      kurtosis: 0
      skewness: 0
    Alpha:
      min: 65535 (1)
      max: 65535 (1)
      mean: 65535 (1)
      standard deviation: 0 (0)
      kurtosis: 0
      skewness: 0
  Colors: 1
  ...
Alpha is present, image it should be black with variable alpha but it is totally opaque!

Definatally something is wrong. -- reporting
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: Transparency usage story

Post by glennrp »

I used IM 7.0.0-0 2012-01-02 Q16 and it looks fine. However, using IM 6.7.5-8 Q16 (svn r 7001) it's just a black image When I use .txt format instead of .png it still behaves the same, just a black opaque image. The bug seems to be in the "label:" format, not in the PNG format.
Janek
Posts: 3
Joined: 2012-02-28T06:26:37-07:00
Authentication code: 8675308

Re: Transparency usage story

Post by Janek »

Hi,

I've seen that in new ImageMagick-6.7.5-9 works fine. In changelog is mentioned that bug is fixed in ImageMagick-6.7.5-8.

thank you for fixing
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Transparency usage story

Post by anthony »

Yes confirmed. It is now working again. IM v6.7.5-9
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply