The alpha of SVG to PNG file is not recognized

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
chanbuu
Posts: 9
Joined: 2014-05-06T19:46:27-07:00
Authentication code: 6789

The alpha of SVG to PNG file is not recognized

Post by chanbuu »

I try converting SVG to PNG with ImageMagick-6.8.7-0.

I tried the command, but output is different between my local server and service server.
On local server, PNG file is transparent.
But on service server, PNG file isn't transparent.

The command is as follows:

Code: Select all

convert a.svg -resize 1024x1024 -verbose -identify b.png
I also tried:

Code: Select all

convert a.svg -resize 1024x1024 -background none b.png

Code: Select all

convert a.svg -resize 1024x1024 -background transparent b.png

Code: Select all

convert a.svg -resize 1024x1024 -background none -alpha On b.png

Code: Select all

convert a.svg -resize 1024x1024 -background transparent -alpha On b.png
etc...



I include the following: the differences are

1. Channel depth
■Local Server

Code: Select all

 Channel depth:
    red: 8-bit
    green: 8-bit
    blue: 8-bit
    alpha: 8-bit
■Service Server

Code: Select all

Channel depth:
    red: 8-bit
    green: 8-bit
    blue: 8-bit
    alpha: 1-bit
2. False Recognition of Geometory
■Local Server

Code: Select all

  Geometry: 1024x1024+0+0
  Base geometry: 2048x2048
There aren't the descriptions that are "Resolution" and "Print size".

■Service Server

Code: Select all

  Geometry: 1024x1024+0+0
  Base geometry: 2560x2560
  Resolution: 90x90
  Print size: 11.3778x11.3778
3. Channel Statistics
■Local Server

Code: Select all

    Red:
      min: 0 (0)
      max: 255 (1)
      mean: 2.37697 (0.00932144)
      standard deviation: 21.4034 (0.0839347)
      kurtosis: 117.412
      skewness: 10.6119
    Green:
      min: 0 (0)
      max: 255 (1)
      mean: 1.88739 (0.00740152)
      standard deviation: 17.9426 (0.0703631)
      kurtosis: 130.818
      skewness: 11.2439
    Blue:
      min: 0 (0)
      max: 255 (1)
      mean: 1.64421 (0.00644789)
      standard deviation: 16.2222 (0.0636166)
      kurtosis: 137.088
      skewness: 11.5417
    Alpha:
      min: 0 (0)
      max: 255 (1)
      mean: 3.57922 (0.0140361)
      standard deviation: 29.4608 (0.115532)
      kurtosis: 66.7091
      skewness: -8.2599

■Service Server

Code: Select all

    Red:
      min: 50 (0.196078)
      max: 255 (1)
      mean: 253.288 (0.993285)
      standard deviation: 17.642 (0.0691842)
      kurtosis: 111.157
      skewness: -10.5784
    Green:
      min: 28 (0.109804)
      max: 255 (1)
      mean: 252.906 (0.991788)
      standard deviation: 19.8629 (0.0778939)
      kurtosis: 105.394
      skewness: -10.2382
    Blue:
      min: 0 (0)
      max: 255 (1)
      mean: 252.718 (0.991051)
      standard deviation: 20.9297 (0.0820771)
      kurtosis: 100.597
      skewness: -9.96305
    Alpha:
      min: 255 (1)
      max: 255 (1)
      mean: 255 (1)
      standard deviation: 0 (0)
      kurtosis: 0
      skewness: 0
How would you think is where the funny ?



I have put the full text of the output.
------FULL OUTPUT------
■Local Server

Code: Select all

Image: a.svg
  Format: SVG (Scalable Vector Graphics)
  Class: DirectClass
  Geometry: 1024x1024+0+0
  Base geometry: 2048x2048
  Units: Undefined
  Type: TrueColorAlpha
  Endianess: Undefined
  Colorspace: sRGB
  Depth: 8-bit
  Channel depth:
    red: 8-bit
    green: 8-bit
    blue: 8-bit
    alpha: 8-bit
  Channel statistics:
    Red:
      min: 0 (0)
      max: 255 (1)
      mean: 2.37697 (0.00932144)
      standard deviation: 21.4034 (0.0839347)
      kurtosis: 117.412
      skewness: 10.6119
    Green:
      min: 0 (0)
      max: 255 (1)
      mean: 1.88739 (0.00740152)
      standard deviation: 17.9426 (0.0703631)
      kurtosis: 130.818
      skewness: 11.2439
    Blue:
      min: 0 (0)
      max: 255 (1)
      mean: 1.64421 (0.00644789)
      standard deviation: 16.2222 (0.0636166)
      kurtosis: 137.088
      skewness: 11.5417
    Alpha:
      min: 0 (0)
      max: 255 (1)
      mean: 3.57922 (0.0140361)
      standard deviation: 29.4608 (0.115532)
      kurtosis: 66.7091
      skewness: -8.2599
  Image statistics:
    Overall:
      min: 0 (0)
      max: 255 (1)
      mean: 64.3323 (0.252284)
      standard deviation: 21.8583 (0.0857187)
      kurtosis: 1493.01
      skewness: 146.504
  Alpha: none   #00000000
  Rendering intent: Perceptual
  Gamma: 0.454545
  Chromaticity:
    red primary: (0.64,0.33)
    green primary: (0.3,0.6)
    blue primary: (0.15,0.06)
    white point: (0.3127,0.329)
  Background color: white
  Border color: srgba(223,223,223,1)
  Matte color: grey74
  Transparent color: none
  Interlace: None
  Intensity: Undefined
  Compose: Over
  Page geometry: 1024x1024+0+0
  Dispose: Undefined
  Iterations: 0
  Compression: Zip
  Orientation: Undefined
  Properties:
    date:create: 2014-05-07T05:47:07-07:00
    date:modify: 2014-05-07T05:47:07-07:00
    png:bKGD: chunk was found (see Background color, above)
    png:IHDR.bit-depth-orig: 8
    png:IHDR.bit_depth: 8
    png:IHDR.color-type-orig: 6
    png:IHDR.color_type: 6 (RGBA)
    png:IHDR.interlace_method: 0 (Not interlaced)
    png:IHDR.width,height: 2048, 2048
    png:sRGB: intent=0 (Perceptual Intent)
    signature: b5677c05951a66494421289c21f1cfd14e123f4a8f5b64ab9255ee03107654e0
  Artifacts:
    filename: test.svg
    verbose: true
  Tainted: True
  Filesize: 0B
  Number pixels: 1.049M
  Pixels per second: 2.097MB
  User time: 0.510u
  Elapsed time: 0:01.500
  Version: ImageMagick 6.8.7-0 2014-05-07 Q8 http://www.imagemagick.org
a.svg=>b.png SVG 2048x2048=>1024x1024 1024x1024+0+0 8-bit sRGB 31.4KB 0.180u 0:00.189


■Service server

Code: Select all

Image: a.svg
  Format: SVG (Scalable Vector Graphics)
  Class: DirectClass
  Geometry: 1024x1024+0+0
  Base geometry: 2560x2560
  Resolution: 90x90
  Print size: 11.3778x11.3778
  Units: Undefined
  Type: TrueColorAlpha
  Endianess: Undefined
  Colorspace: sRGB
  Depth: 8-bit
  Channel depth:
    red: 8-bit
    green: 8-bit
    blue: 8-bit
    alpha: 1-bit
  Channel statistics:
    Red:
      min: 50 (0.196078)
      max: 255 (1)
      mean: 253.288 (0.993285)
      standard deviation: 17.642 (0.0691842)
      kurtosis: 111.157
      skewness: -10.5784
    Green:
      min: 28 (0.109804)
      max: 255 (1)
      mean: 252.906 (0.991788)
      standard deviation: 19.8629 (0.0778939)
      kurtosis: 105.394
      skewness: -10.2382
    Blue:
      min: 0 (0)
      max: 255 (1)
      mean: 252.718 (0.991051)
      standard deviation: 20.9297 (0.0820771)
      kurtosis: 100.597
      skewness: -9.96305
    Alpha:
      min: 255 (1)
      max: 255 (1)
      mean: 255 (1)
      standard deviation: 0 (0)
      kurtosis: 0
      skewness: 0
  Image statistics:
    Overall:
      min: 0 (0)
      max: 255 (1)
      mean: 189.728 (0.744031)
      standard deviation: 16.9103 (0.0663147)
      kurtosis: 4157.78
      skewness: -314.514
  Rendering intent: Perceptual
  Gamma: 0.454545
  Chromaticity:
    red primary: (0.64,0.33)
    green primary: (0.3,0.6)
    blue primary: (0.15,0.06)
    white point: (0.3127,0.329)
  Background color: white
  Border color: srgba(223,223,223,1)
  Matte color: grey74
  Transparent color: none
  Interlace: None
  Intensity: Undefined
  Compose: Over
  Page geometry: 1024x1024+0+0
  Dispose: Undefined
  Iterations: 0
  Compression: Undefined
  Orientation: Undefined
  Properties:
    date:create: 2014-05-07T20:39:04+09:00
    date:modify: 2014-05-07T20:39:04+09:00
    signature: 6bf4b8330afa33d30d55a31e5655a9dbaa0da916975c02435067c0beb2efa1e3
    svg:base-uri: a.svg
  Artifacts:
    filename: a.svg
    verbose: true
  Tainted: True
  Filesize: 0B
  Number pixels: 1.049M
  Pixels per second: 874KB
  User time: 1.190u
  Elapsed time: 0:02.199
  Version: ImageMagick 6.8.7-0 2014-05-07 Q8 http://www.imagemagick.org
  a.svg=>b.png SVG 2560x2560=>1024x1024 1024x1024+0+0 8-bit sRGB 32.4KB 0.600u 0:00.589
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: The alpha of SVG to PNG file is not recognized

Post by fmw42 »

What are the versions of IM and platform for both computers? Are they the same? Might you have multiple versions of IM on either computer (type -a convert)?

Possible delegates for reading SVG files are IM internal MSVG (XML), RSVG or Inkscape.

What are the delegates and versions being used by IM on both servers for SVG and for PNG? (convert -list format). Perhaps you have different versions of the SVG reading delegates or two different versions of the PNG delegate for writing the files.

What delegates does IM recognize on both servers? (convert -list configure --- Line starting with DELEGATES)

Can you post a link to this SVG or find or create another that may not be proprietary that shows this issue?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: The alpha of SVG to PNG file is not recognized

Post by snibgo »

"-background none" is an instruction to whatever rasterises the SVG, so in modern versions of IM it should come before the input SVG filename.
snibgo's IM pages: im.snibgo.com
chanbuu
Posts: 9
Joined: 2014-05-06T19:46:27-07:00
Authentication code: 6789

Re: The alpha of SVG to PNG file is not recognized

Post by chanbuu »

> fmw42

IM on both servers is the same version that is 6.8.4-0.
But the version of packages that is SVG and PNG delegated are older on service server than on local server.
I had tried to update libpng and libsvg2 on service server. But the version of CentOS on service server is too old to update those packages.

The delegates that IM recognizes on each server are follows:

■Local Server

Code: Select all

DELEGATES      fontconfig freetype jng jpeg pango png rsvg x xml zlib
■Service Server

Code: Select all

DELEGATES      bzlib fontconfig freetype jng jpeg png rsvg x xml zlib

However, I've got the result that I wanted when I tried to put the option that is "-background none" before the input SVG filename as Snibgo's saying.
My problem has been resolved.

Thank you for your assistance.
Could not finish thanks.


> Snibgo
I've succeeded, thanks to your advice.
Post Reply