| <<<Back 1 day (to 2022/07/06) | Fwd 1 day (to 2022/07/08) >>> | 20220707 |
artifexirc-bot | <xx> I want to convert the first page of a PDF into a PNG. I have the option of using imagemagick, graphicsmagick, pdftoppm or ghostscript. Which one of those is preferable? Is ghostscript good at this or should I use the other tools for now? | 14:38.25 |
| <chrisl> imagemagick and graphicsmagick use Ghostscript | 14:38.51 |
| <chrisl> And since this is a Ghostscript channel, we'd obviously recommend using it.... | 14:39.39 |
| <xx> strangely I get different outputs when I use ghostcript/imagemagick/graphicsmagick | 14:40.33 |
| <xx> thought it would all give me the same file | 14:40.38 |
| <xx> hence I wonder what they do differently | 14:40.46 |
| <KenSharp> ImageMagick and GraphicsMagick might be doing 'soemthing' to the PNG file after Ghostscript render sit. Or might be using different arguments to Ghostscript (eg resolution) | 14:41.21 |
| <xx> all set to 300DPI, original pdf is 66288 bytes, imagemagick produces 786391 bytes png, graphicsmagick 400871 bytes, ghostscript 59025 bytes, and poppler 210216 bytes | 14:42.41 |
| <KenSharp> Hard to comment, as I say IM ad GM could be doing soemthing to the file after it is produced. | 14:43.16 |
| <KenSharp> We can't help you with those, only Ghostscript | 14:43.28 |
| <xx> understood | 14:43.35 |
| <chrisl> Chances are, imagemagick/graphicsmagick and poppler(?) default to producing anti-aliased output, Ghostscript doesn't | 14:43.36 |
| <xx> hmm, that's good thinking, I'll check that out | 14:43.54 |
| <xx> thanks | 14:44.29 |
| <chrisl> But given the way PNG compression works, relatively tiny differences in the rendered output could result in non-trivial differences in file size. | 14:44.32 |
| <chrisl> So, I'd base the judgement on visual inspection of the ouput rather than file size or whatever | 14:45.01 |
| <xx> you are correct, ghostscript does not antialias the edges, it's just black & white, no gray on the edges | 14:48.03 |
| <chrisl> Ghostscript has a couple of ways to do antialising, if that's the output you want - each with their own trade-offs | 14:58.02 |
| <xx> yeah I'm reading the docs about -dTextAlphaBits=n | 14:58.16 |
| <chrisl> There's TextAlphaBits and GraphicsAlphaBits | 14:59.29 |
| <chrisl> And also DownScaleFactor | 15:00.12 |
| <Robin_Watts> In this day and age, we recommend DownScaleFactor rather than XXXAlphaBits | 15:02.51 |
| <xx> I'll check it out, I still see XXXAlphaBits documented more on https://ghostscript.com/doc/current/Devices.htm | 15:11.06 |
| <xx> but I'm likely looking at the wrong documentation page | 15:11.20 |
| <xx> I will read all the docs anyway | 15:11.28 |
| <chrisl> No, the XXXAlphaBits is still there. It's been around for so long, we daren't remove it.... | 15:12.12 |
| <chrisl> But it has issues with how it interacts with certain features, like PDF transparency. | 15:12.38 |
| <chrisl> (it predates PDF transparency by a *long* time!) | 15:12.58 |
| <xx> so I guess instead of -r 300, I'd do -r 2400 and -dDownScaleFactor=8, to get the same 300DPI output, but better looking? | 15:13.49 |
| <chrisl> I really wouldn't use more than 4 for DownScaleFactor. | 15:14.23 |
| <xx> performance issue or something else? | 15:14.33 |
| <chrisl> "Better" is an extremely subjective term! | 15:14.39 |
| <chrisl> Especially with text, there comes a point where the "fuzzy edges" impede legibility | 15:15.28 |
| <xx> true, I just want something that can replace -dTextAlphaBits=4 -dGraphicsAlphaBits=4 | 15:16.29 |
| <chrisl> -dDownScaleFactor=4 should be fine | 15:17.09 |
| <chrisl> Basically, the way XXXAlphaBits works is that it rendered each individual "object" into a temporary buffer at 4x the resolution, downsamples that temporary buffer, and pushes the result onto the output page | 15:18.40 |
| <chrisl> The way DownScaleFactor works is to render the entire page at the higher resolution, and downsample the entire page. | 15:19.18 |
| <xx> after some testing, downscalefactor=4 indeed looks "better" than alphabits=4 | 15:33.48 |
| <xx> and I'm slowly getting closer to what imagemagick/graphicsmagick produce (without making them spit out the actual ghostscript command they use) | 15:34.39 |
| <xx> "Why doesn’t my text look as good as it should?" https://ghostscript.com/faq/index.html still talks about AlphaBits and -dDOINTERPOLATE | 15:48.48 |
| <xx> and "What should I do if I uncover a bug?" links to freenode | 15:50.40 |
| <KenSharp> Well TBH we mostly spend our time working on bugs and features, documentation is third place and an FAQ more or less off the list | 15:51.30 |
| <<<Back 1 day (to 2022/07/06) | Forward 1 day (to 2022/07/08)>>> | |