Conversion from PDF to PNG contains unwanted artifacts

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Locked
vmrob
Posts: 4
Joined: 2015-02-04T11:58:34-07:00
Authentication code: 6789

Conversion from PDF to PNG contains unwanted artifacts

Post by vmrob »

While attempting to convert a pdf document to a png using the following command, the output is inconsistent with the input. Note the artifacts near the arrows.

Version:
$ convert --version
Version: ImageMagick 6.9.0-3 Q16 x86_64 2015-02-04 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2015 ImageMagick Studio LLC
Features: DPC Modules
Delegates (built-in): bzlib cairo fontconfig freetype jng jp2 jpeg lcms ltdl lzma openexr png rsvg tiff webp xml zlib
Command:

Code: Select all

convert -density 400 gitdags.pdf gitdags.png
Input:
https://s3.amazonaws.com/vmrob/imagemag ... itdags.pdf

Output:
Image

Input PDF details:

Code: Select all

$ identify -verbose gitdags.pdf
Image: gitdags.pdf
  Format: PDF (Portable Document Format)
  Mime type: application/pdf
  Class: DirectClass
  Geometry: 159x76+0+0
  Resolution: 72x72
  Print size: 2.20833x1.05556
  Units: Undefined
  Type: PaletteAlpha
  Endianess: Undefined
  Colorspace: sRGB
  Depth: 16/8-bit
  Channel depth:
    red: 8-bit
    green: 8-bit
    blue: 8-bit
    alpha: 8-bit
  Channel statistics:
    Pixels: 12084
    Red:
      min: 0 (0)
      max: 65535 (1)
      mean: 18001.7 (0.274688)
      standard deviation: 24388.9 (0.37215)
      kurtosis: -0.914249
      skewness: 0.869938
      entropy: 0.385675
    Green:
      min: 0 (0)
      max: 65535 (1)
      mean: 18532.3 (0.282786)
      standard deviation: 24553.6 (0.374664)
      kurtosis: -1.06098
      skewness: 0.789896
      entropy: 0.395248
    Blue:
      min: 0 (0)
      max: 65535 (1)
      mean: 17772.3 (0.271187)
      standard deviation: 23235.7 (0.354554)
      kurtosis: -1.11204
      skewness: 0.743544
      entropy: 0.39425
    Alpha:
      min: 0 (0)
      max: 65535 (1)
      mean: 20267.9 (0.309268)
      standard deviation: 28534.5 (0.435408)
      kurtosis: -1.1953
      skewness: -0.833664
      entropy: 0.312278
  Image statistics:
    Overall:
      min: 0 (0)
      max: 65535 (1)
      mean: 24893.4 (0.379848)
      standard deviation: 25257.7 (0.385408)
      kurtosis: -0.919662
      skewness: 0.561842
      entropy: 0.371863
  Alpha: srgba(255,255,255,0)   #FFFFFFFFFFFF0000
  Colors: 195
  Histogram:
      7273: (    0,    0,    0,    0) #0000000000000000 none
         1: (10794,11822,12593,65535) #2A2A2E2E3131 srgba(42,46,49,1)
         3: (11822,12079,10537,65535) #2E2E2F2F2929 srgba(46,47,41,1)
         1: (13107,12850,10023,65535) #333332322727 srgba(51,50,39,1)
        10: (14649,15934,16962,65535) #39393E3E4242 srgba(57,62,66,1)
         7: (15934,16191,13878,65535) #3E3E3F3F3636 srgba(62,63,54,1)
         3: (16962,14649,14649,65535) #424239393939 srgba(66,57,57,1)
         7: (17476,17219,13364,65535) #444443433434 srgba(68,67,52,1)
         1: (17990,15420,15420,65535) #46463C3C3C3C srgba(70,60,60,1)
         1: (18247,17990,13878,65535) #474746463636 srgba(71,70,54,1)
         6: (18247,19789,21074,65535) #47474D4D5252 srgba(71,77,82,1)
         1: (18504,16191,17476,65535) #48483F3F4444 srgba(72,63,68,1)
         6: (19789,20046,17476,65535) #4D4D4E4E4444 srgba(77,78,68,1)
         1: (21074,18504,19789,65535) #525248484D4D srgba(82,72,77,1)
         3: (21845,21331,16705,65535) #555553534141 srgba(85,83,65,1)
        18: (21845,23901,25186,65535) #55555D5D6262 srgba(85,93,98,1)
       230: (22616,28270,30069,65535) #58586E6E7575 srgba(88,110,117,1)
       144: (22616,28270,30069,48059) #58586E6E7575BBBB srgba(88,110,117,0.733333)
       130: (22616,28270,30069,17476) #58586E6E75754444 srgba(88,110,117,0.266667)
        87: (22616,28270,30069,34952) #58586E6E75758888 srgba(88,110,117,0.533333)
        22: (22616,28270,30069,61166) #58586E6E7575EEEE srgba(88,110,117,0.933333)
        18: (22616,28270,30069, 4369) #58586E6E75751111 srgba(88,110,117,0.0666667)
        16: (22616,28270,30069,39321) #58586E6E75759999 srgba(88,110,117,0.6)
        13: (22616,28270,30069, 8738) #58586E6E75752222 srgba(88,110,117,0.133333)
        12: (22616,28270,30069,56797) #58586E6E7575DDDD srgba(88,110,117,0.866667)
        11: (22616,28270,30069,52428) #58586E6E7575CCCC srgba(88,110,117,0.8)
         8: (22616,28270,30069,21845) #58586E6E75755555 srgba(88,110,117,0.333333)
         7: (22616,28270,30069,26214) #58586E6E75756666 srgba(88,110,117,0.4)
         7: (22616,28270,30069,30583) #58586E6E75757777 srgba(88,110,117,0.466667)
         6: (22616,28270,30069,13107) #58586E6E75753333 srgba(88,110,117,0.2)
         5: (22616,28270,30069,43690) #58586E6E7575AAAA srgba(88,110,117,0.666667)
         2: (22616,28270,30069,57054) #58586E6E7575DEDE srgba(88,110,117,0.870588)
         1: (22616,28270,30069,61423) #58586E6E7575EFEF srgba(88,110,117,0.937255)
        12: (22873,28270,30069,61937) #59596E6E7575F1F1 srgba(89,110,117,0.945098)
         1: (22873,28270,30069,48573) #59596E6E7575BDBD srgba(89,110,117,0.741176)
         4: (22873,28527,30069,48830) #59596F6F7575BEBE srgba(89,111,117,0.745098)
        13: (22873,28527,30326,58082) #59596F6F7676E2E2 srgba(89,111,118,0.886275)
         1: (22873,28527,30326,40092) #59596F6F76769C9C srgba(89,111,118,0.611765)
         8: (23130,28527,30326,54484) #5A5A6F6F7676D4D4 srgba(90,111,118,0.831373)
         1: (23130,28527,30326,35980) #5A5A6F6F76768C8C srgba(90,111,118,0.54902)
         1: (23130,28527,30326,17990) #5A5A6F6F76764646 srgba(90,111,118,0.27451)
         1: (23130,28527,30326,13621) #5A5A6F6F76763535 srgba(90,111,118,0.207843)
         1: (23130,28527,30326,31868) #5A5A6F6F76767C7C srgba(90,111,118,0.486275)
         1: (23130,28527,30326,54227) #5A5A6F6F7676D3D3 srgba(90,111,118,0.827451)
         1: (23130,28527,30326,49858) #5A5A6F6F7676C2C2 srgba(90,111,118,0.760784)
         1: (23130,28527,30326,50115) #5A5A6F6F7676C3C3 srgba(90,111,118,0.764706)
         1: (23130,28527,30326,49344) #5A5A6F6F7676C0C0 srgba(90,111,118,0.752941)
         1: (23130,28784,30326,36494) #5A5A707076768E8E srgba(90,112,118,0.556863)
       151: (23387,28784,30326,50629) #5B5B70707676C5C5 srgba(91,112,118,0.772549)
         1: (23387,28784,30326,27499) #5B5B707076766B6B srgba(91,112,118,0.419608)
         1: (23387,28784,30326,41377) #5B5B70707676A1A1 srgba(91,112,118,0.631373)
         9: (23644,24158,21074,65535) #5C5C5E5E5252 srgba(92,94,82,1)
         9: (23644,29041,30583,47031) #5C5C71717777B7B7 srgba(92,113,119,0.717647)
         1: (23901,29041,30583,19018) #5D5D717177774A4A srgba(93,113,119,0.290196)
         1: (23901,29041,30583,33410) #5D5D717177778282 srgba(93,113,119,0.509804)
         6: (23901,29041,30840,43176) #5D5D71717878A8A8 srgba(93,113,120,0.658824)
         1: (23901,29041,30840,19275) #5D5D717178784B4B srgba(93,113,120,0.294118)
         1: (23901,29041,30840,38293) #5D5D717178789595 srgba(93,113,120,0.584314)
         2: (24158,29298,30840,39064) #5E5E727278789898 srgba(94,114,120,0.596078)
         2: (24158,29298,30840,29298) #5E5E727278787272 srgba(94,114,120,0.447059)
         1: (24158,29298,30840,34438) #5E5E727278788686 srgba(94,114,120,0.52549)
        38: (24415,29298,30840,39578) #5F5F727278789A9A srgba(95,114,120,0.603922)
         1: (24415,29298,30840,34695) #5F5F727278788787 srgba(95,114,120,0.529412)
         1: (24672,29555,30840,51657) #606073737878C9C9 srgba(96,115,120,0.788235)
         4: (24672,29555,31097,35723) #6060737379798B8B srgba(96,115,121,0.545098)
         1: (24672,29555,31097,65535) #606073737979 srgba(96,115,121,1)
         1: (24672,29555,31097,25186) #6060737379796262 srgba(96,115,121,0.384314)
         5: (25186,22102,23644,65535) #626256565C5C srgba(98,86,92,1)
         1: (25186,27499,29298,65535) #62626B6B7272 srgba(98,107,114,1)
         1: (25186,29812,31354,10537) #626274747A7A2929 srgba(98,116,122,0.160784)
         9: (25443,22102,21845,65535) #636356565555 srgba(99,86,85,1)
        33: (25443,27756,29555,65535) #63636C6C7373 srgba(99,108,115,1)
         6: (25443,30069,31354,32125) #636375757A7A7D7D srgba(99,117,122,0.490196)
         1: (25700,30069,31611,21845) #646475757B7B5555 srgba(100,117,123,0.333333)
         1: (25700,30326,31611,52685) #646476767B7BCDCD srgba(100,118,123,0.803922)
         1: (25700,30326,31611,11051) #646476767B7B2B2B srgba(100,118,123,0.168627)
        13: (25957,30326,31868,28270) #656576767C7C6E6E srgba(101,118,124,0.431373)
         7: (26214,25700,20046,65535) #666664644E4E srgba(102,100,78,1)
         1: (26214,30583,31868,11565) #666677777C7C2D2D srgba(102,119,124,0.176471)
         1: (26214,30583,31868,17219) #666677777C7C4343 srgba(102,119,124,0.262745)
         1: (26471,29298,30840,65535) #676772727878 srgba(103,114,120,1)
         1: (26471,30583,32125,23644) #676777777D7D5C5C srgba(103,119,125,0.360784)
       124: (26985,31097,32125,24672) #696979797D7D6060 srgba(105,121,125,0.376471)
         1: (26985,31097,32382,18761) #696979797E7E4949 srgba(105,121,126,0.286275)
         2: (27499,31354,32639,13107) #6B6B7A7A7F7F3333 srgba(107,122,127,0.2)
        35: (27756,28270,24415,65535) #6C6C6E6E5F5F srgba(108,110,95,1)
         7: (28013,31611,32896,20817) #6D6D7B7B80805151 srgba(109,123,128,0.317647)
         1: (28270,31868,32896,46260) #6E6E7C7C8080B4B4 srgba(110,124,128,0.705882)
         5: (29041,31868,33667,65535) #71717C7C8383 srgba(113,124,131,1)
         6: (29555,25700,27499,65535) #737364646B6B srgba(115,100,107,1)
        17: (29812,25700,25443,65535) #747464646363 srgba(116,100,99,1)
         5: (30069,32896,33667,17219) #7575808083834343 srgba(117,128,131,0.262745)
        18: (30583,30069,23387,65535) #777775755B5B srgba(119,117,91,1)
         1: (30583,33153,33924, 9252) #7777818184842424 srgba(119,129,132,0.141176)
         1: (31611,32125,28013,65535) #7B7B7D7D6D6D srgba(123,125,109,1)
         1: (32125,34181,34952,12336) #7D7D858588883030 srgba(125,133,136,0.188235)
         1: (32125,34181,34952,40606) #7D7D858588889E9E srgba(125,133,136,0.619608)
        13: (32639,34438,35209,13364) #7F7F868689893434 srgba(127,134,137,0.203922)
         9: (32639,35723,38036,65535) #7F7F8B8B9494 srgba(127,139,148,1)
         1: (33153,34952,35466,36751) #818188888A8A8F8F srgba(129,136,138,0.560784)
         1: (33667,35209,35466,47288) #838389898A8AB8B8 srgba(131,137,138,0.721569)
         3: (33924,29298,29298,65535) #848472727272 srgba(132,114,114,1)
         2: (34181,29555,29298,65535) #858573737272 srgba(133,115,114,1)
         2: (34181,33410,25957,65535) #858582826565 srgba(133,130,101,1)
         3: (34952,34181,26471,65535) #888885856767 srgba(136,133,103,1)
         6: (35723,36237,31354,65535) #8B8B8D8D7A7A srgba(139,141,122,1)
         8: (36237,39835,42148,65535) #8D8D9B9BA4A4 srgba(141,155,164,1)
       265: (37522,37522,37522, 9766) #9292929292922626 srgba(146,146,146,0.14902)
       158: (37522,37522,37522, 7196) #9292929292921C1C srgba(146,146,146,0.109804)
        74: (37522,37522,37522,34952) #9292929292928888 srgba(146,146,146,0.533333)
        20: (37522,37522,37522, 4369) #9292929292921111 srgba(146,146,146,0.0666667)
        20: (37522,37522,37522, 8738) #9292929292922222 srgba(146,146,146,0.133333)
        19: (37522,37522,37522,13107) #9292929292923333 srgba(146,146,146,0.2)
        19: (37522,37522,37522,52428) #929292929292CCCC srgba(146,146,146,0.8)
        19: (37522,37522,37522,17476) #9292929292924444 srgba(146,146,146,0.266667)
        12: (37522,37522,37522,21845) #9292929292925555 srgba(146,146,146,0.333333)
        12: (37522,37522,37522,26214) #9292929292926666 srgba(146,146,146,0.4)
        11: (37522,37522,37522,  771) #9292929292920303 srgba(146,146,146,0.0117647)
        11: (37522,37522,37522,30583) #9292929292927777 srgba(146,146,146,0.466667)
        10: (37522,37522,37522,48059) #929292929292BBBB srgba(146,146,146,0.733333)
        10: (37522,37522,37522,56797) #929292929292DDDD srgba(146,146,146,0.866667)
         9: (37522,37522,37522, 5140) #9292929292921414 srgba(146,146,146,0.0784314)
         8: (37522,37522,37522,43690) #929292929292AAAA srgba(146,146,146,0.666667)
         8: (37522,37522,37522,61166) #929292929292EEEE srgba(146,146,146,0.933333)
         8: (37522,37522,37522, 2570) #9292929292920A0A srgba(146,146,146,0.0392157)
         7: (37522,37522,37522, 3855) #9292929292920F0F srgba(146,146,146,0.0588235)
         7: (37522,37522,37522,39321) #9292929292929999 srgba(146,146,146,0.6)
         5: (37522,37522,37522,65535) #929292929292 srgba(146,146,146,1)
         4: (37522,37522,37522, 3341) #9292929292920D0D srgba(146,146,146,0.0509804)
         4: (37522,37522,37522,43176) #929292929292A8A8 srgba(146,146,146,0.658824)
         4: (37522,37522,37522, 5911) #9292929292921717 srgba(146,146,146,0.0901961)
         3: (37522,37522,37522, 4626) #9292929292921212 srgba(146,146,146,0.0705882)
         3: (37522,37522,37522, 1285) #9292929292920505 srgba(146,146,146,0.0196078)
         3: (37522,37522,37522, 6425) #9292929292921919 srgba(146,146,146,0.0980392)
         3: (37522,37522,37522, 2056) #9292929292920808 srgba(146,146,146,0.0313725)
         3: (37522,37522,37522, 8995) #9292929292922323 srgba(146,146,146,0.137255)
         2: (37522,37522,37522,17219) #9292929292924343 srgba(146,146,146,0.262745)
         2: (37522,37522,37522,51657) #929292929292C9C9 srgba(146,146,146,0.788235)
         2: (37522,37522,37522,51143) #929292929292C7C7 srgba(146,146,146,0.780392)
         2: (37522,37522,37522,47288) #929292929292B8B8 srgba(146,146,146,0.721569)
         2: (37522,37522,37522,32125) #9292929292927D7D srgba(146,146,146,0.490196)
         2: (37522,37522,37522,22873) #9292929292925959 srgba(146,146,146,0.34902)
         2: (37522,37522,37522,20817) #9292929292925151 srgba(146,146,146,0.317647)
         2: (37522,37522,37522,14906) #9292929292923A3A srgba(146,146,146,0.227451)
         2: (37522,37522,37522,11565) #9292929292922D2D srgba(146,146,146,0.176471)
         2: (37522,37522,37522, 8481) #9292929292922121 srgba(146,146,146,0.129412)
         1: (37522,37522,37522, 7453) #9292929292921D1D srgba(146,146,146,0.113725)
         1: (37522,37522,37522,61423) #929292929292EFEF srgba(146,146,146,0.937255)
         1: (37522,37522,37522,24672) #9292929292926060 srgba(146,146,146,0.376471)
         1: (37522,37522,37522,23901) #9292929292925D5D srgba(146,146,146,0.364706)
         1: (37522,37522,37522,52685) #929292929292CDCD srgba(146,146,146,0.803922)
         1: (37522,37522,37522,54998) #929292929292D6D6 srgba(146,146,146,0.839216)
         1: (37522,37522,37522,16448) #9292929292924040 srgba(146,146,146,0.25098)
         1: (37522,37522,37522,13364) #9292929292923434 srgba(146,146,146,0.203922)
         1: (37522,37522,37522, 7710) #9292929292921E1E srgba(146,146,146,0.117647)
         1: (37522,37522,37522,57568) #929292929292E0E0 srgba(146,146,146,0.878431)
         1: (37522,37522,37522,35723) #9292929292928B8B srgba(146,146,146,0.545098)
         1: (37522,37522,37522,39578) #9292929292929A9A srgba(146,146,146,0.603922)
         1: (37522,37522,37522,41120) #929292929292A0A0 srgba(146,146,146,0.627451)
         1: (37522,37522,37522,46774) #929292929292B6B6 srgba(146,146,146,0.713725)
         1: (37522,37522,37522,48316) #929292929292BCBC srgba(146,146,146,0.737255)
         3: (38036,33153,35466,65535) #949481818A8A srgba(148,129,138,1)
         4: (38293,32896,32896,65535) #959580808080 srgba(149,128,128,1)
         1: (39321,38550,29812,65535) #999996967474 srgba(153,150,116,1)
         3: (39578,40349,34952,65535) #9A9A9D9D8888 srgba(154,157,136,1)
        22: (39835,43690,46260,65535) #9B9BAAAAB4B4 srgba(155,170,180,1)
         3: (42148,36751,39321,65535) #A4A48F8F9999 srgba(164,143,153,1)
         1: (42405,36751,36494,65535) #A5A58F8F8E8E srgba(165,143,142,1)
        26: (43433,44204,38550,65535) #A9A9ACAC9696 srgba(169,172,150,1)
         5: (43690,42919,33153,65535) #AAAAA7A78181 srgba(170,167,129,1)
         7: (43690,47802,50629,65535) #AAAABABAC5C5 srgba(170,186,197,1)
         1: (44204,38036,38036,65535) #ACAC94949494 srgba(172,148,148,1)
         8: (46260,40606,43433,65535) #B4B49E9EA9A9 srgba(180,158,169,1)
         9: (46774,40349,40092,65535) #B6B69D9D9C9C srgba(182,157,156,1)
        11: (47288,51657,54741,65535) #B8B8C9C9D5D5 srgba(184,201,213,1)
         5: (47545,48316,41891,65535) #B9B9BCBCA3A3 srgba(185,188,163,1)
         3: (48059,47031,36494,65535) #BBBBB7B78E8E srgba(187,183,142,1)
         3: (50629,44204,47288,65535) #C5C5ACACB8B8 srgba(197,172,184,1)
         5: (50886,43947,43690,65535) #C6C6ABABAAAA srgba(198,171,170,1)
        10: (50886,55769,59110,65535) #C6C6D9D9E6E6 srgba(198,217,230,1)
         9: (51400,52428,45489,65535) #C8C8CCCCB1B1 srgba(200,204,177,1)
         4: (52428,51400,39835,65535) #CCCCC8C89B9B srgba(204,200,155,1)
       547: (54484,59624,63222,65535) #D4D4E8E8F6F6 srgba(212,232,246,1)
         5: (54741,47802,51143,65535) #D5D5BABAC7C7 srgba(213,186,199,1)
         7: (55255,47545,47545,65535) #D7D7B9B9B9B9 srgba(215,185,185,1)
         7: (55512,56283,48830,65535) #D8D8DBDBBEBE srgba(216,219,190,1)
         2: (56797,55769,43176,65535) #DDDDD9D9A8A8 srgba(221,217,168,1)
         2: (59110,51657,55255,65535) #E6E6C9C9D7D7 srgba(230,201,215,1)
         2: (59367,51400,51143,65535) #E7E7C8C8C7C7 srgba(231,200,199,1)
      1117: (59367,60395,52428,65535) #E7E7EBEBCCCC srgba(231,235,204,1)
         2: (61166,59881,46517,65535) #EEEEE9E9B5B5 srgba(238,233,181,1)
       223: (63222,55255,59110,65535) #F6F6D7D7E6E6 srgba(246,215,230,1)
       176: (63736,54998,54741,65535) #F8F8D6D6D5D5 srgba(248,214,213,1)
       305: (65535,64250,49858,65535) #FFFFFAFAC2C2 srgba(255,250,194,1)
        76: (65535,65535,65535,    0) #FFFFFFFFFFFF0000 srgba(255,255,255,0)
  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: 159x76+0+0
  Dispose: Undefined
  Iterations: 0
  Compression: Undefined
  Orientation: Undefined
  Properties:
    date:create: 2015-02-04T13:16:00-06:00
    date:modify: 2015-02-04T13:16:00-06:00
    pdf:Version: PDF-1.5 
    signature: 7e9bb187fbfef57c0e1a9c6c0862ad82b1efde9a64d842e3a627d4dc6457092a
  Artifacts:
    filename: gitdags.pdf
    verbose: true
  Tainted: False
  Filesize: 5.08KB
  Number pixels: 12.1K
  Pixels per second: 12.084EB
  User time: 0.000u
  Elapsed time: 0:01.000
  Version: ImageMagick 6.9.0-3 Q16 x86_64 2015-02-04 http://www.imagemagick.org

pipitas
Posts: 168
Joined: 2012-07-15T14:06:46-07:00
Authentication code: 15

Re: Conversion from PDF to PNG contains unwanted artifacts

Post by pipitas »

What 'identify -verbose some.pdf' tells you are many details supposedly about the input PDF which are not relevant at all for the PDF. The reason: identify (as ImageMagick in general) cannot directly handle PDF itself. It uses Ghostscript as its 'delegate' to process input PDF pages and convert them to a series of raster images.

Only then 'identify' gets its turn: it then reports all the many details -- but most of these are details about the newly generated raster image, not about the original PDF. The only items which are appropriate for the input PDF are the few (3-5?) lines (out of almost 300!) reported underneath the 'Properties' line: 'date:create', 'date:modify', 'pdf:Version' and 'signature'. How reliable these are, is doubtful...

So unfortunately, the info you provided does not help much.

There are better (free) command line tools tools to investigate the PDF. First, 'pdfinfo':

Code: Select all

pdfinfo gitdags.pdf 

 Creator:        TeX
 Producer:       pdfTeX-1.40.15
 CreationDate:   Tue Feb  3 17:56:43 2015 
 ModDate:        Tue Feb  3 17:56:43 2015
 Tagged:         no 
 UserProperties: no
 Suspects:       no
 Form:           none
 JavaScript:     no
 Pages:          1
 Encrypted:      no
 Page size:      158.799 x 75.717 pts
 Page rot:       0
 File size:      44261 bytes
 Optimized:      no
 PDF version:    1.5
As you can see, this PDF info is more complete than what you get from 'identify -verbose'. Also, the 'CreationDate' and 'ModDate' metadata do differ from what identify reports... (OK, I tested shortly: `identify` reports the current time as 'date:create' and 'date:modify'. This is plain wrong by identify and has to be regarded as a bug!)

Second, 'pdfimages':

Code: Select all

pdfimages -list gitdags.pdf 

 page   num  type   width height color comp bpc  enc interp  object ID x-ppi y-ppi size ratio
 --------------------------------------------------------------------------------------------
So, no results here. There are no embedded images in the PDF. What we see is vector graphics.

Third, 'pdffonts':

Code: Select all

pdffonts gitdags.pdf
 name                     type    encoding  emb sub uni object ID
 ------------------------ ------- --------- --- --- --- ---------
 APTQJI+LMMono9-Regular   Type 1  Custom    yes yes no      32  0
 NSZVGH+LMMono8-Regular   Type 1  Custom    yes yes no      33  0
Now let's see how ImageMagick processes the PDF:

Code: Select all

convert -verbose gitdags.pdf gitdags.png

 /var/tmp/magick-38522tfS9sU7JKOO01 PNG 159x76 159x76+0+0 8-bit sRGB 5.4KB 0.000u 0:00.000
 gitdags.pdf PDF 159x76 159x76+0+0 16-bit sRGB 5.4KB 0.000u 0:00.000
 gitdags.pdf=>gitdags.png PDF 159x76 159x76+0+0 8-bit sRGB 186c 2.79KB 0.000u 0:00.000
 
 [ghostscript library] -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 \
    -dAlignToPixels=0 -dGridFitTT=2 "-sDEVICE=pngalpha" -dTextAlphaBits=4 -dGraphicsAlphaBits=4 \
    "-r72x72"  "-sOutputFile=/var/tmp/magick-38522tfS9sU7JKOO0%d" "-f/var/tmp/magick-38522GemGFJkDIY3Z" \
    "-f/var/tmp/magick-38522zBpgqK8MGSKz"
You can clearly see how Ghostscript is at work as ImageMagick's delegate for processing PDF input.

Finally, I did run the conversion with a direct Ghostscript command like so:

Code: Select all

gs -r400 -sDEVICE=pngalpha -o gitdags.png gitdags.pdf
I used different Ghostscript versions: v9.10, v9.15 and a self-compiled v9.16 (from today's Git clone of the Ghostscript sources). I also tried it with different resulutions (up to 1200 PPI!, not just your 400 PPI).

I'm sorry to report: in every single case this results in similar artifacts you you reported.

So this is nothing the ImageMagick developers can do anything about.

Maybe you should report this problem in the Ghostscript bugzilla? ( http://bugs.ghostscript.com/ )
Last edited by pipitas on 2015-02-05T08:52:36-07:00, edited 1 time in total.

User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: Conversion from PDF to PNG contains unwanted artifacts

Post by glennrp »

I don't see the artifacts. I'm using IM-6.9.0-4 with libnpg-1.6.16 and (I believe) ghostscript 9.10. I do see drop shadows but I assume those were deliberately included.

vmrob
Posts: 4
Joined: 2015-02-04T11:58:34-07:00
Authentication code: 6789

Re: Conversion from PDF to PNG contains unwanted artifacts

Post by vmrob »

pipitas wrote:I'm sorry to report: in every single case this results in similar artifacts you you reported.

So this is nothing the ImageMagick developers can do anything about.

Maybe you should report this problem in the Ghostscript bugzilla? ( http://bugs.ghostscript.com/ )
Thanks for the quick reply! I'll be sure to submit something to Ghostscript for that bug though. I really appreciate the additional debug work you put into it as well. The additional commands are also really helpful; I'll keep those in mind next time I need to debug this sort of thing.
glennrp wrote:I don't see the artifacts. I'm using IM-6.9.0-4 with libnpg-1.6.16 and (I believe) ghostscript 9.10. I do see drop shadows but I assume those were deliberately included.
Would you happen to have an output example? I would really like to see what that looked like.

User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: Conversion from PDF to PNG contains unwanted artifacts

Post by glennrp »

Here's my output: http://www.simplesystems.org/users/glennrp/im/
Note that the transparency was lost.

EDIT: transparency is not lost. About 5 columns along the left border are fully transparent; all others are opaque.

vmrob
Posts: 4
Joined: 2015-02-04T11:58:34-07:00
Authentication code: 6789

Re: Conversion from PDF to PNG contains unwanted artifacts

Post by vmrob »

The artifacts are present in the centers of the arrowheads:

Image

User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: Conversion from PDF to PNG contains unwanted artifacts

Post by glennrp »

OK I do see those. I thought they were put there on purpose.

vmrob
Posts: 4
Joined: 2015-02-04T11:58:34-07:00
Authentication code: 6789

Re: Conversion from PDF to PNG contains unwanted artifacts

Post by vmrob »

glennrp wrote:OK I do see those. I thought they were put there on purpose.
Nope. I know it's a little small, but this is the reference pdf: https://s3.amazonaws.com/vmrob/imagemag ... itdags.pdf

User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: Conversion from PDF to PNG contains unwanted artifacts

Post by glennrp »

I added a -density 4800 closeup of one of the arrowheads to the above-mentioned web page. It does look to me as though the little triangle was deliberately drawn there.

pipitas
Posts: 168
Joined: 2012-07-15T14:06:46-07:00
Authentication code: 15

Re: Conversion from PDF to PNG contains unwanted artifacts

Post by pipitas »

glennrp wrote:I added a -density 4800 closeup of one of the arrowheads to the above-mentioned web page. It does look to me as though the little triangle was deliberately drawn there.
If so, then all the PDF viewers I tested[*][/color][/b] the input PDF with (apart from Ghostscript-based 'gv'), do have the same bug: because these do not show this intentional 'artifacts', not even with their respective maximum zoom-in level. Likely?!?

(I still have to test with Acrobat...)

[*]:[/b][/color] These were: Chrome's builtin PDF viewer, Firefox with PDF.js, evince, XPDF, Preview.app, MuPDF -- all on Mac OS X.

snibgo
Posts: 13034
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Conversion from PDF to PNG contains unwanted artifacts

Post by snibgo »

Adobe Reader 11.0.6 does not show white outlined triangles. The arrowheads show as solid gray.
snibgo's IM pages: im.snibgo.com

User avatar
fmw42
Posts: 26383
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Conversion from PDF to PNG contains unwanted artifacts

Post by fmw42 »

For me, Mac Preview on OSX 10.6.8 (snow leopard) does not show the white triangles in the middle of arrow heads for the original PDF file. It does not show in my Safari browser 5.1.10 either, nor in my Acrobat Reader 11.

pipitas
Posts: 168
Joined: 2012-07-15T14:06:46-07:00
Authentication code: 15

Re: Conversion from PDF to PNG contains unwanted artifacts

Post by pipitas »

It's clear then: a Ghostscript bug.

pipitas
Posts: 168
Joined: 2012-07-15T14:06:46-07:00
Authentication code: 15

Re: Conversion from PDF to PNG contains unwanted artifacts

Post by pipitas »

I tested a few more (direct) Ghostscript-conversions to raster formats: '-sDEVICE={tiff24nc,png16m,jpeg}'. All these didn't produce the artifact. It's only the 'pngalpha'-device which has the problem.

Maybe this is a chance to find a workaround?[*][/b][/color]

Provided, your IM has a setup which does not go through Ghostscript's 'pngalpha' device when converting to TIFF in the first stage:

Code: Select all

convert -verbose -density 400 gitdag.pdf gitdag.tiff

convert gitdag.tiff gitdag.png
You can check your specific delegates setup for PDF processing like this:

Code: Select all

convert -list delegate | grep pdf
Check here how you can change or add your own delegate setup: If this isn't possible, you'll need to run a Ghostscript command first:

Code: Select all

gs -o gitdag.tiff -r400x400 -sDEVICE=tiff32nc gitdag.pdf

convert gitdag.tiff gitdag.png
I hope one of these approaches will work for you.

[*][/b][/color] (It may be quite a long time before a GS bugfix arrives in user space for this specific problem...)

aaron.cuffman
Posts: 1
Joined: 2016-01-23T21:22:44-07:00
Authentication code: 1151

Re: Conversion from PDF to PNG contains unwanted artifacts

Post by aaron.cuffman »

pipitas wrote:I tested a few more (direct) Ghostscript-conversions to raster formats: '-sDEVICE={tiff24nc,png16m,jpeg}'. All these didn't produce the artifact. It's only the 'pngalpha'-device which has the problem.
I've come from the future to thank you. Thanks! I'm a noob with Ghostscript and had no clue why my images had those crappy artifacts. I was using Png256 and simply switching to Png16m fixed the issue completely. Again, thank you!

Locked