Error in converting a PDF to a PNG in ImageMagick

8,325

Solution 1

Try adding -colorspace RGB before the outfile name.

convert -density 300 PointOnLine.pdf -quality 90 -colorspace RGB PointOnLine.png

Solution 2

The documentation says this:

PNG RW Portable Network Graphics Requires libpng-1.0.11 or later, libpng-1.2.5 or later recommended. The PNG specification does not support pixels-per-inch units, only pixels-per-centimeter. To avoid reading a particular associated image profile, use -define profile:skip=name (e.g. profile:skip=ICC).

So try adding -define profile:skip=ICC (or skip="*") before the outfile name.

See also: documentation on the define command

Share:
8,325

Related videos on Youtube

hermes
Author by

hermes

Updated on September 18, 2022

Comments

  • hermes
    hermes over 1 year

    I use Imagemagick convert to convert pdf file to png as follows:

    Magick convert -density 300 PointOnLine.pdf -quality 90 PointOnLine.png
    

    It gives warning:

    convert: profile 'icc': 'RGB ': RGB color space not permitted on grayscale PNG `PointOnLine.png' @ warning/png.c/MagickPNGWarningHandler/1744.
    

    And png image created is all black. However, convert to jpg image is fine. What is the problem? Thanks.

  • hermes
    hermes over 6 years
    No, after setting -define profile:skip=ICC, image is still dark. But if convert to jpg and then to png, it is ok, but background is dark. The same warning happens.
  • user74094
    user74094 about 4 years
    Nice. For me the white background became transparent, but this can still be used.
  • DannyB
    DannyB over 3 years
    Note that this solution, although removing the warning, also changes the shades of gray in the generated PNG.
  • DannyB
    DannyB over 3 years
    This works better than setting -colorspace RGB - for me it removes the warning and does not alter the shades of gray of the output.
  • Torsten Bronger
    Torsten Bronger almost 3 years
    I don’t want to put the validity of this answer in question but I just don’t understand the connection between “pixels per centimetre/inch” and a colour profile. Can somebody explain this to me?