question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Poor exported PNG quality and text cutting

See original GitHub issue

Thank you so much for this great extension.

First issue My text gets cutted. Se the numbers in the images.

Next “issiue” I have installed the extension on my vb.net server and I am linking to a function (called latex2png - see below) in the code:

Shared Function latex2png(latex As String) As MemoryStream
        Dim parser = New TexFormulaParser()
        Dim formula = parser.Parse(latex)
        formula.GetRenderer(TexStyle.Script, 15.0, "Arial")

        Dim pngBytes = formula.RenderToPng(15.0, 0.0, 0.0, "Arial")
        Dim latexpng As New MemoryStream(pngBytes)

        Return latexpng
    End Function

Everything is working great, but sadly the quality of the image could be much better. Is there any way to get a higher quality of the png image that is created? Hope you can help me.

Seems like making the scale bigger is better. But the image gets to large in the end.

SCALE 12 image

SCALE 15 image

SCALE 25 image

BTW. I am writing the code in vb.net in aspx, and I am a novice. So go easy on me, when explaining. 😃

Kind regards Troels Christensen

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:14 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
ForNeVeRcommented, Nov 12, 2018

Alright, after some additional research I have the working prototype. There’re two problems:

  1. “Text cutting”: with default settings, some of the letter elements are sometimes drawn out of bounds of our images. See image attached (this is SVG, but it has the same problems anyway): image Solution: Fix the images by adding a TranslateTransform to them if they’re out of bounds.
  2. Images generated by TexRenderer.RenderToBitmap have poor resolution by default (something like 96 DPI because that’s the default resolution for “Display Independent Pixels”). Solution: Allow the users to define their own resolution instead of the default one.
2reactions
ForNeVeRcommented, Nov 12, 2018

@troelschristensen one of the quality solutions for now would be to use SVG instead of PNG. Take a look at our example project: it has the stuff to render the formula into SVG image, it will scale much better.

I was able to reproduce your “cutting” issue and I’m investigating it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Poor exported PNG quality and text cutting · Issue #168
Poor exported PNG quality and text cutting #168 ... Is there any way to get a higher quality of the png image that...
Read more >
Poor export quality in adobe xD
I'm facing the issue in export for design (x1) JPG or PNG. ... at these lower factors, so your text will indeed be...
Read more >
Exporting PNG - Blurry - InkscapeForum.com
Hello, When I am trying to export my work to a PNG file it is coming out rather blurry. People who have saved...
Read more >
Exporting fonts in image cutting off letters
I am trying to export a png of copy and Figma is cutting off the curvature of “S” or “C” in the image....
Read more >
text blured when exporting to png for website use
When I export an image to PNG the text appears blurred or pixelated in windows pic viewer as well as on my website....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found