-9

I answered this question a year ago, based off an existing answer which helped me a lot.
In the meantime, my answer received 6 upvotes before the question was deleted 2 months ago.

I want to convert following HTML to PNG image in Python.

<html>
    <b>Bold text</b>
</html>

This HTML is, of course, an example. I have tried 'pisa' but it converts html to PDF, not to image. I can convert HTML to PDF and then convert PDF to PNG, but I was wondering if there is any direct solution (i.e HTML to PNG). Any built-in or external module will work nicely.

If this can be done in Graphicsmagick or Imagemagick, then it will be perfect.

I understand that we don't like questions that ask for software recommendation. But since this Q&A now is more of a guide how to use the recommended tools than just "use this", I think it has value to future visitors.

I was close to click "undelete" on my answer, but I do not know what exactly happens then so I wanted to ask here first whether that would be a reasonable action.

For comparison, the imho clearly less useful question that is linked there in a now-deleted comment was closed and not deleted.

7
  • 2
    Why don't you post a question about how to use webkit2png, and post your answer there? There might even be a dupe around where you could post a variation of your answer. Found this one, but looks equally bad.
    – yivi
    Dec 13, 2019 at 13:02
  • Fair enough, thanks @yivi !
    – lucidbrot
    Dec 13, 2019 at 13:16
  • 7
    It is not a recommendation question. That the answers recommend using a tool instead of writing code is entirely normal. Voted to undelete. Dec 13, 2019 at 13:31
  • 2
    @HansPassant That is why we have softwarerecs.stackexchange.com It is obviously tool recommendation question or too broad. Either we should leave all of them here or we should treat all such questions the same way. I didn't wrote the rules... Dec 13, 2019 at 13:53
  • @DalijaPrasnikar I disagree there. That question reads to me like "I have tool x which should do what I want, but I can't get to do that. How do I use that tool correctly" and that is on-topic on Stack Overflow.
    – Tom
    Dec 13, 2019 at 14:02
  • 4
    @Tom Question literally says I have a tool x which does not do what I want is there another tool that can do it. I guess we disagree here. Dec 13, 2019 at 14:07
  • 4
    I don't think there is a right or a wrong party here. The question is broad, or maybe I should say open-ended. "I kind of sort of prefer this buuuuuut something else is also fine". And in doing so, it literally opens the door for everyone and their grandma to do tool/library/framework recommendations. Its the easy answer to this open-ended question. But that's only the question, answers are what really matters. If there are good answers in there, I would not appose undeletion.
    – Gimby
    Dec 13, 2019 at 14:10

2 Answers 2

1

Undeleted. Putting aside whether the question should be closed, it has a good answer, so it should not be deleted.

And...I actually think the question itself can be salvaged and re-opened, but I don’t have time for that at the moment. Will try to have a look later. If someone else wants to give it a stab, feel free. You just need to rephrase so it doesn’t sound like it’s asking for a library recommendation, but rather asking how to accomplish a clearly defined task.

1
  • 1
    Thanks! I totally agree that closing is a different discussion (I would not have spoken up against the question being closed)
    – lucidbrot
    Dec 13, 2019 at 18:46
0

"How to render HTML to an [image|PDF]" is a complex subject, and if it were to be interpreted literally, it'd be too broad. Because who in their right mind would want to write an HTML and CSS parsing and rendering engine, let alone write an answer on Stack Overflow explaining how to do so? It wouldn't even fit in the answer box.

So a group of users, with that in mind, vote to close such questions as off-topic or too broad and even delete them, despite their usefulness for many other developers.

Then again, people already wrote such software, and packed it up in reusable libraries. And answering a "How To" question with a library, preferably with some example code showing how to use said library, is just fine.

Questions like this should not be closed and deleted.

1
  • I think the answer is fine. I purged the comments so you can undelete, if you want. Dec 13, 2019 at 20:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .