Converting problematic pdf's to png

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?".
User avatar
michelle
Posts: 31
Joined: 2011-08-24T06:45:50-07:00
Authentication code: 8675308

Converting problematic pdf's to png

Post by michelle »

Hi there

My PROBLEM
convert convert.pdf -scale @550000 PNG8:convertedPDF.png
My command above works wonderfully on some pdf's but on others it does not as shown in the picture. There is not enough detail in convertedPDF.png to identify a basic drawing shape.

Image

My QUESTION ?
How can I modify my command to be more robust so that it encompasses problematic pdf's such as convert.pdf?

SOFTWARE VERSIONS
ImageMagick: 6.8.9-6 Q8 x64 2014-07-22
Gohst Script: gs914w64

VERBOSE IDENTIFICATION CONVERT.pdf

Code: Select all

C:\Users\mp\Desktop>identify -verbose convert.pdf
Image: convert.pdf
  Format: PDF (Portable Document Format)
  Mime type: application/pdf
  Class: DirectClass
  Geometry: 842x595+0+0
  Resolution: 72x72
  Print size: 11.6944x8.26389
  Units: Undefined
  Type: GrayscaleAlpha
  Base type: GrayscaleAlpha
  Endianess: Undefined
  Colorspace: Gray
  Depth: 8-bit
  Channel depth:
    gray: 8-bit
    alpha: 8-bit
  Channel statistics:
    Gray:
      min: 0 (0)
      max: 255 (1)
      mean: 228.351 (0.895495)
      standard deviation: 77.9119 (0.305537)
      kurtosis: 4.69217
      skewness: -2.5858
    Alpha:
      min: 0 (0)
      max: 255 (1)
      mean: 11.0847 (0.0434695)
      standard deviation: 36.8531 (0.144522)
      kurtosis: 14.7704
      skewness: -3.75933
  Alpha: graya(255,0)   #FFFFFF00
  Colors: 201
  Histogram:
     13527: (  0,  0,  0, 68) #00000044 graya(0,0.266667)
     11789: (  0,  0,  0,136) #00000088 graya(0,0.533333)
      3433: (  0,  0,  0, 17) #00000011 graya(0,0.0666667)
      3284: (  0,  0,  0, 51) #00000033 graya(0,0.2)
      2663: (  0,  0,  0,119) #00000077 graya(0,0.466667)
      2239: (  0,  0,  0, 34) #00000022 graya(0,0.133333)
      2204: (  0,  0,  0, 85) #00000055 graya(0,0.333333)
      1898: (  0,  0,  0,117) #00000075 graya(0,0.458824)
      1806: (  0,  0,  0,223) #000000DF graya(0,0.87451)
      1409: (  0,  0,  0,102) #00000066 graya(0,0.4)
       531: (  0,  0,  0,153) #00000099 graya(0,0.6)
       397: (  0,  0,  0,167) #000000A7 graya(0,0.654902)
       333: (  0,  0,  0,199) #000000C7 graya(0,0.780392)
       321: (  0,  0,  0, 80) #00000050 graya(0,0.313725)
       288: (  0,  0,  0, 92) #0000005C graya(0,0.360784)
       244: (  0,  0,  0,151) #00000097 graya(0,0.592157)
       222: (  0,  0,  0, 48) #00000030 graya(0,0.188235)
       220: (  0,  0,  0,105) #00000069 graya(0,0.411765)
       195: (  0,  0,  0, 32) #00000020 graya(0,0.12549)
       180: (  0,  0,  0, 63) #0000003F graya(0,0.247059)
       178: (  0,  0,  0, 78) #0000004E graya(0,0.305882)
       166: (  0,  0,  0, 64) #00000040 graya(0,0.25098)
       163: (  0,  0,  0,142) #0000008E graya(0,0.556863)
       157: (  0,  0,  0,143) #0000008F graya(0,0.560784)
       157: (  0,  0,  0,159) #0000009F graya(0,0.623529)
       131: (  0,  0,  0,187) #000000BB graya(0,0.733333)
       127: (  0,  0,  0, 91) #0000005B graya(0,0.356863)
       127: (  0,  0,  0,170) #000000AA graya(0,0.666667)
       125: (  0,  0,  0,112) #00000070 graya(0,0.439216)
       123: (  0,  0,  0,155) #0000009B graya(0,0.607843)
       122: (  0,  0,  0,122) #0000007A graya(0,0.478431)
       115: (  0,  0,  0,163) #000000A3 graya(0,0.639216)
       114: (  0,  0,  0,130) #00000082 graya(0,0.509804)
       105: (  0,  0,  0,132) #00000084 graya(0,0.517647)
       103: (  0,  0,  0,255) #000000 graya(0,1)
        98: (  0,  0,  0,128) #00000080 graya(0,0.501961)
        96: (  0,  0,  0,137) #00000089 graya(0,0.537255)
        88: (  0,  0,  0,183) #000000B7 graya(0,0.717647)
        87: (  0,  0,  0,107) #0000006B graya(0,0.419608)
        87: (  0,  0,  0,191) #000000BF graya(0,0.74902)
        80: (  0,  0,  0,126) #0000007E graya(0,0.494118)
        78: (  0,  0,  0,182) #000000B6 graya(0,0.713725)
        75: (  0,  0,  0,228) #000000E4 graya(0,0.894118)
        73: (  0,  0,  0,180) #000000B4 graya(0,0.705882)
        67: (  0,  0,  0,175) #000000AF graya(0,0.686275)
        65: (  0,  0,  0,221) #000000DD graya(0,0.866667)
        63: (  0,  0,  0,173) #000000AD graya(0,0.678431)
        63: (  0,  0,  0,146) #00000092 graya(0,0.572549)
        61: (  0,  0,  0,135) #00000087 graya(0,0.529412)
        54: (  0,  0,  0, 96) #00000060 graya(0,0.376471)
        53: (  0,  0,  0,202) #000000CA graya(0,0.792157)
        46: (  0,  0,  0,231) #000000E7 graya(0,0.905882)
        46: (  0,  0,  0,206) #000000CE graya(0,0.807843)
        45: (  0,  0,  0,213) #000000D5 graya(0,0.835294)
        43: (  0,  0,  0,240) #000000F0 graya(0,0.941176)
        43: (  0,  0,  0,141) #0000008D graya(0,0.552941)
        39: (  0,  0,  0,181) #000000B5 graya(0,0.709804)
        38: (  0,  0,  0,172) #000000AC graya(0,0.67451)
        36: (  0,  0,  0,204) #000000CC graya(0,0.8)
        36: (  0,  0,  0,164) #000000A4 graya(0,0.643137)
        34: (  0,  0,  0,186) #000000BA graya(0,0.729412)
        34: (  0,  0,  0,196) #000000C4 graya(0,0.768627)
        32: (  0,  0,  0,166) #000000A6 graya(0,0.65098)
        31: (  0,  0,  0,242) #000000F2 graya(0,0.94902)
        30: (  0,  0,  0,190) #000000BE graya(0,0.745098)
        29: (  0,  0,  0,144) #00000090 graya(0,0.564706)
        29: (  0,  0,  0,207) #000000CF graya(0,0.811765)
        28: (  0,  0,  0,169) #000000A9 graya(0,0.662745)
        28: (  0,  0,  0,205) #000000CD graya(0,0.803922)
        26: (  0,  0,  0,238) #000000EE graya(0,0.933333)
        26: (  0,  0,  0,216) #000000D8 graya(0,0.847059)
        25: (  0,  0,  0,165) #000000A5 graya(0,0.647059)
        25: (  0,  0,  0,210) #000000D2 graya(0,0.823529)
        24: (  0,  0,  0,217) #000000D9 graya(0,0.85098)
        23: (  0,  0,  0,193) #000000C1 graya(0,0.756863)
        22: (  0,  0,  0,211) #000000D3 graya(0,0.827451)
        22: (  0,  0,  0,178) #000000B2 graya(0,0.698039)
        21: (  0,  0,  0,101) #00000065 graya(0,0.396078)
        21: (  0,  0,  0,215) #000000D7 graya(0,0.843137)
        20: (  0,  0,  0,194) #000000C2 graya(0,0.760784)
        20: (  0,  0,  0,192) #000000C0 graya(0,0.752941)
        19: (  0,  0,  0, 75) #0000004B graya(0,0.294118)
        19: (  0,  0,  0,157) #0000009D graya(0,0.615686)
        18: (  0,  0,  0,150) #00000096 graya(0,0.588235)
        18: (  0,  0,  0,103) #00000067 graya(0,0.403922)
        18: (  0,  0,  0,200) #000000C8 graya(0,0.784314)
        18: (  0,  0,  0,235) #000000EB graya(0,0.921569)
        18: (  0,  0,  0,201) #000000C9 graya(0,0.788235)
        18: (  0,  0,  0, 46) #0000002E graya(0,0.180392)
        18: (  0,  0,  0,203) #000000CB graya(0,0.796078)
        18: (  0,  0,  0,149) #00000095 graya(0,0.584314)
        16: (  0,  0,  0,220) #000000DC graya(0,0.862745)
        16: (  0,  0,  0,113) #00000071 graya(0,0.443137)
        16: (  0,  0,  0,239) #000000EF graya(0,0.937255)
        16: (  0,  0,  0,148) #00000094 graya(0,0.580392)
        15: (  0,  0,  0,229) #000000E5 graya(0,0.898039)
        15: (  0,  0,  0,156) #0000009C graya(0,0.611765)
        14: (  0,  0,  0,115) #00000073 graya(0,0.45098)
        14: (  0,  0,  0,161) #000000A1 graya(0,0.631373)
        14: (  0,  0,  0, 76) #0000004C graya(0,0.298039)
        14: (  0,  0,  0, 61) #0000003D graya(0,0.239216)
        13: (  0,  0,  0,134) #00000086 graya(0,0.52549)
        13: (  0,  0,  0,127) #0000007F graya(0,0.498039)
        13: (  0,  0,  0,179) #000000B3 graya(0,0.701961)
        13: (  0,  0,  0,233) #000000E9 graya(0,0.913725)
        12: (  0,  0,  0,184) #000000B8 graya(0,0.721569)
        12: (  0,  0,  0,185) #000000B9 graya(0,0.72549)
        12: (  0,  0,  0,138) #0000008A graya(0,0.541176)
        12: (  0,  0,  0,195) #000000C3 graya(0,0.764706)
        12: (  0,  0,  0,212) #000000D4 graya(0,0.831373)
        12: (  0,  0,  0,230) #000000E6 graya(0,0.901961)
        12: (  0,  0,  0,145) #00000091 graya(0,0.568627)
        11: (  0,  0,  0,225) #000000E1 graya(0,0.882353)
        11: (  0,  0,  0,197) #000000C5 graya(0,0.772549)
        11: (  0,  0,  0,152) #00000098 graya(0,0.596078)
        10: (  0,  0,  0,247) #000000F7 graya(0,0.968627)
        10: (  0,  0,  0,123) #0000007B graya(0,0.482353)
        10: (  0,  0,  0,125) #0000007D graya(0,0.490196)
         9: (  0,  0,  0,189) #000000BD graya(0,0.741176)
         9: (  0,  0,  0,236) #000000EC graya(0,0.92549)
         9: (  0,  0,  0,241) #000000F1 graya(0,0.945098)
         8: (  0,  0,  0,209) #000000D1 graya(0,0.819608)
         8: (  0,  0,  0,188) #000000BC graya(0,0.737255)
         8: (  0,  0,  0,232) #000000E8 graya(0,0.909804)
         8: (  0,  0,  0,208) #000000D0 graya(0,0.815686)
         8: (  0,  0,  0,139) #0000008B graya(0,0.545098)
         8: (  0,  0,  0,171) #000000AB graya(0,0.670588)
         7: (  0,  0,  0,168) #000000A8 graya(0,0.658824)
         7: (  0,  0,  0,106) #0000006A graya(0,0.415686)
         7: (  0,  0,  0,249) #000000F9 graya(0,0.976471)
         7: (  0,  0,  0,176) #000000B0 graya(0,0.690196)
         7: (  0,  0,  0,158) #0000009E graya(0,0.619608)
         7: (  0,  0,  0,237) #000000ED graya(0,0.929412)
         7: (  0,  0,  0,226) #000000E2 graya(0,0.886275)
         7: (  0,  0,  0, 88) #00000058 graya(0,0.345098)
         7: (  0,  0,  0,227) #000000E3 graya(0,0.890196)
         7: (  0,  0,  0, 89) #00000059 graya(0,0.34902)
         7: (  0,  0,  0,218) #000000DA graya(0,0.854902)
         6: (  0,  0,  0,114) #00000072 graya(0,0.447059)
         6: (  0,  0,  0,121) #00000079 graya(0,0.47451)
         6: (  0,  0,  0,131) #00000083 graya(0,0.513725)
         6: (  0,  0,  0,177) #000000B1 graya(0,0.694118)
         6: (  0,  0,  0,224) #000000E0 graya(0,0.878431)
         6: (  0,  0,  0,222) #000000DE graya(0,0.870588)
         6: (  0,  0,  0,219) #000000DB graya(0,0.858824)
         6: (  0,  0,  0,214) #000000D6 graya(0,0.839216)
         5: (  0,  0,  0,234) #000000EA graya(0,0.917647)
         5: (  0,  0,  0,174) #000000AE graya(0,0.682353)
         5: (  0,  0,  0,245) #000000F5 graya(0,0.960784)
         5: (  0,  0,  0,111) #0000006F graya(0,0.435294)
         4: (  0,  0,  0,246) #000000F6 graya(0,0.964706)
         4: (  0,  0,  0,154) #0000009A graya(0,0.603922)
         4: (  0,  0,  0,124) #0000007C graya(0,0.486275)
         3: (  0,  0,  0, 87) #00000057 graya(0,0.341176)
         3: (  0,  0,  0,140) #0000008C graya(0,0.54902)
         3: (  0,  0,  0,198) #000000C6 graya(0,0.776471)
         3: (  0,  0,  0,147) #00000093 graya(0,0.576471)
         3: (  0,  0,  0,248) #000000F8 graya(0,0.972549)
         2: (  0,  0,  0,109) #0000006D graya(0,0.427451)
         2: (  0,  0,  0,244) #000000F4 graya(0,0.956863)
         2: (  0,  0,  0,160) #000000A0 graya(0,0.627451)
         2: (  0,  0,  0,250) #000000FA graya(0,0.980392)
         1: (  0,  0,  0, 97) #00000061 graya(0,0.380392)
         1: (  0,  0,  0,251) #000000FB graya(0,0.984314)
         1: (  0,  0,  0,162) #000000A2 graya(0,0.635294)
         1: (  0,  0,  0, 59) #0000003B graya(0,0.231373)
         1: (  0,  0,  0,133) #00000085 graya(0,0.521569)
         1: (  0,  0,  0,129) #00000081 graya(0,0.505882)
         1: (  0,  0,  0,110) #0000006E graya(0,0.431373)
         1: (  0,  0,  0,243) #000000F3 graya(0,0.952941)
         1: (  0,  0,  0,100) #00000064 graya(0,0.392157)
         3: ( 17, 17, 17,255) #111111 graya(17,1)
         4: ( 34, 34, 34,255) #222222 graya(34,1)
        12: ( 51, 51, 51,255) #333333 graya(51,1)
         2: ( 59, 59, 59,255) #3B3B3B graya(59,1)
         2: ( 63, 63, 63,255) #3F3F3F graya(63,1)
        46: ( 68, 68, 68,255) #444444 graya(68,1)
         1: ( 75, 75, 75,255) #4B4B4B graya(75,1)
        46: ( 85, 85, 85,255) #555555 graya(85,1)
         1: ( 88, 88, 88,255) #585858 graya(88,1)
        37: (102,102,102,255) #666666 graya(102,1)
         1: (108,108,108,240) #6C6C6CF0 graya(108,0.941176)
       134: (119,119,119,255) #777777 graya(119,1)
        39: (136,136,136,255) #888888 graya(136,1)
         2: (137,137,137,255) #898989 graya(137,1)
         6: (143,143,143,243) #8F8F8FF3 graya(143,0.952941)
         1: (144,144,144,241) #909090F1 graya(144,0.945098)
         2: (150,150,150,255) #969696 graya(150,1)
        36: (153,153,153,255) #999999 graya(153,1)
        18: (170,170,170,255) #AAAAAA graya(170,1)
         2: (175,175,175,255) #AFAFAF graya(175,1)
        74: (187,187,187,255) #BBBBBB graya(187,1)
         1: (194,194,194,246) #C2C2C2F6 graya(194,0.964706)
        31: (204,204,204,255) #CCCCCC graya(204,1)
         1: (214,214,214,223) #D6D6D6DF graya(214,0.87451)
        24: (221,221,221,255) #DDDDDD graya(221,1)
        39: (238,238,238,255) #EEEEEE graya(238,1)
    447585: (255,255,255,  0) #FFFFFF00 graya(255,0)
       572: (255,255,255,255) #FFFFFF graya(255,1)
       166: (255,255,255,187) #FFFFFFBB graya(255,0.733333)
         1: (255,255,255,136) #FFFFFF88 graya(255,0.533333)
  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: graya(255,1)
  Border color: graya(223,1)
  Matte color: graya(189,1)
  Transparent color: graya(0,0)
  Interlace: None
  Intensity: Undefined
  Compose: Over
  Page geometry: 842x595+0+0
  Dispose: Undefined
  Iterations: 0
  Compression: Undefined
  Orientation: Undefined
  Properties:
    date:create: 2014-08-19T11:53:35+02:00
    date:modify: 2014-08-19T11:53:35+02:00
    pdf:HiResBoundingBox: 595.22x842+0+0
    pdf:Version: PDF-1.5
    signature: 7a72059b0aa555ce84073bb3e094f950cfebc7a826713a230367267ede316dc6
  Artifacts:
    filename: convert.pdf
    verbose: true
  Tainted: True
  Filesize: 63.7KB
  Number pixels: 501K
  Pixels per second: 27.83MB
  User time: 0.016u
  Elapsed time: 0:01.017
  Version: ImageMagick 6.8.9-6 Q8 x64 2014-07-22 http://www.imagemagick.org

Thank-you in advance,
Michelle
Last edited by michelle on 2014-08-19T15:15:06-07:00, edited 2 times in total.
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Converting problematic pdf's to png

Post by dlemstra »

You should specify the density before you read the PDF file. Not sure which number is good for you.

Code: Select all

convert -density 300 convert.pdf -scale @550000 PNG8:convertedPDF.png
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Converting problematic pdf's to png

Post by fmw42 »

Did you try dlemstra's suggestion? If that does not work, then please post your image to some free image hosting service such as dropbox.com and put the URL here, so we can test with it.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Converting problematic pdf's to png

Post by snibgo »

You don't say what you don't like about the output. Perhaps you don't want transparency. Or something else.
snibgo's IM pages: im.snibgo.com
User avatar
michelle
Posts: 31
Joined: 2011-08-24T06:45:50-07:00
Authentication code: 8675308

Re: Converting problematic pdf's to png

Post by michelle »

Thank you all for getting back to me, in turn:

dlemstra: Your suggestion is actually how I previously had my command. Since "-density 300" never seemed make a difference (to successful or unsuccessful) conversions, I dropped it out. Regardless my command is now revised to your suggestion. Re-running the command for convert.pdf yielded the same unfavorable result.

fmw42: I have sent you each a private message with a download link for the files including convert.pdf

snibgo: Oops! Sorry Snibgo I didn't even spec out what I am trying to achieve here: I need to convert pdfs and tif files to png format with a reduced area of 550000. The converted png's get attached to our visual workflow system. They need to be clear enough for anyone in our Engineering workshop to be able to see the basic job shape so that they can identify the job physically in the workshop. That is why the little picture I posted up previously was in adequate - you can't see enough detail of the job to identify it's basic shape.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Converting problematic pdf's to png

Post by snibgo »

The convert2.pdf in your PM has a natural resolution of 200 dpi, and was probably scanned at that dpi. Therefore, using that density works well. Then I scale it to fit in 550000 pixels.

Code: Select all

convert -density 200 michelle\convert2.pdf -scale @550000 PNG8:c.png
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Converting problematic pdf's to png

Post by fmw42 »

First you have not said what is wrong with the PNG output you get. You did not provide an example of what you get from the pdf nor from the tiff.

You have a very strange PDF with transparency that should contribute to the result. But keeping the transparency causes the result to be transparent even if I specify -background white before reading the pdf. If I try to use a larger density, it also gives a bad result. The best result that I have been able to achieve is by turning off the transparency. But even doing that, I cannot give it a larger density to supersample. Even flattening with a white background causes oddly overly white (low contrast) results.

This looks OK to me.

Code: Select all

convert -density 200 convert.pdf -alpha off -resize @550000 PNG8:result.png

I am using IM 6.8.9.7 Q16 Mac OSX.

Perhaps the PDF needs further review by some one more expert than I. I also get the same kind of bad results using gif for the output, so it is not likely a PNG problem.

Perhaps Ghostscript has a problem with grayalpha image types?

Was this a raster image that was imbedded into a vector PDF shell? That could be the reason that supersampling does not work correctly on this image.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Converting problematic pdf's to png

Post by snibgo »

The two PDFs are different. convert.pdf contains a vector image. convert2.pdf contains a raster image.

For the vector image, I suggest:

Code: Select all

convert -density 72 convert.pdf -flatten PNG8:c0.png
This doesn't need rescaling to fit with 550000 pixels.

The difficulty is in creating an automated script that applies the appropriate conversion. I don't know of a batch tool that tells us whether a PDF contains vector or raster images. I expect Adobe has something.

[EDIT: corrected typo in command.]
snibgo's IM pages: im.snibgo.com
User avatar
michelle
Posts: 31
Joined: 2011-08-24T06:45:50-07:00
Authentication code: 8675308

Re: Converting problematic pdf's to png

Post by michelle »

Hello gentlemen, thank-you for your replies. I have to dash off for a few hours but will work through them upon my return. (Thank-you)

Just one quick question though: If I swapped to have a .jpg output as apposed to .png would it make things simpler?
fmw42 wrote:First you have not said what is wrong with the PNG output you get
Here is the convertedPDF.png mentioned in my initial post: http://www.michellepace.com/pics/convertedPDF.png The output from the problematic pdf is unreadable - the person on the workshop floor who needs to read the .png can not recognise the physical part (see my previous post) from the .png -- I mentioned it to snibgo a couple of posts up.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Converting problematic pdf's to png

Post by fmw42 »

Either of our (snibgo or my) last command lines (posted above) seem to produce good quality results. Using JPG as output will cause a loss in quality, since JPG compression does not do a good job on regions of the same color.

Here is my result:
[Mod note: image removed at Michelle's request.]

It could be your GS version. I was using Ghostscript 9.10 on IM 6.8.9.7 Q16 Mac OSX.

Let us know if you get good or bad results from our command lines.
User avatar
michelle
Posts: 31
Joined: 2011-08-24T06:45:50-07:00
Authentication code: 8675308

Re: Converting problematic pdf's to png

Post by michelle »

snibgo wrote:The two PDFs are different. convert.pdf contains a vector image. convert2.pdf contains a raster image.

For the vector image, I suggest:

Code: Select all

convert -density 72 convert.pdf -flatten PNG8:c0.png
This doesn't need rescaling to fit with 550000 pixels.

The difficulty is in creating an automated script that applies the appropriate conversion. I don't know of a batch tool that tells us whether a PDF contains vector or raster images. I expect Adobe has something.
Snibgo, it works!! What is more - I used your command on all three files (convert.pdf, convert2.pdf, convert.tif) and it worked fantastically. I put my scaling back in because I need it a certain "ruler" dimension (not bigger) so that it displays properly in my software. Just want to have your go-ahead here before I modify my calling code - - do you think it is ok I use this command on all my .tif's and raster .pdf's (in addition to the vector .pdf's)

Code: Select all

convert -density 72 convert.tif -scale @550000 -flatten PNG8:converted-hooray.png
User avatar
michelle
Posts: 31
Joined: 2011-08-24T06:45:50-07:00
Authentication code: 8675308

Re: Converting problematic pdf's to png

Post by michelle »

fmw42 wrote:Either of our (snibgo or my) last command lines (posted above) seem to produce good quality results. Using JPG as output will cause a loss in quality, since JPG compression does not do a good job on regions of the same color.

It could be your GS version. I was using Ghostscript 9.10 on IM 6.8.9.7 Q16 Mac OSX.

Let us know if you get good or bad results from our command lines.
Hi Fred - thank-you - I was too curious to leave without trying at least one suggestion - reeeeeally late now - ha ha - I'll give yours a burl when I get back in. Thanks a lot. :-)
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Converting problematic pdf's to png

Post by snibgo »

michelle wrote:Just want to have your go-ahead here before I modify my calling code - - do you think it is ok I use this command on all my .tif's and raster .pdf's (in addition to the vector .pdf's)

convert -density 72 convert.tif -scale @550000 -flatten PNG8:converted-hooray.png
I would say that whatever works for you, works for you.

That command used on convert.png gives slightly less resolution that the command I gave upthread. This might be a price worth paying for a one-size-fits-all solution.
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Converting problematic pdf's to png

Post by fmw42 »

Hi Fred - thank-you - I was too curious to leave without trying at least one suggestion - reeeeeally late now - ha ha - I'll give yours a burl when I get back in. Thanks a lot.
Using supersampling as I did by using a large density will not help with raster images such as TIF. So you may be better of sticking with snibgo's solution.
User avatar
michelle
Posts: 31
Joined: 2011-08-24T06:45:50-07:00
Authentication code: 8675308

Re: Converting problematic pdf's to png

Post by michelle »

What works for me sounds good to me! Then this is the command I'll use. Splendid! Thank-you for your continued patience and time. :-)

Code: Select all

convert -density 72 convert.tif -scale @550000 -flatten PNG8:converted-hooray.png
Post Reply