GeneralExtracting Latex source from .png

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
kkzs
Posts: 5
Joined: Wed Mar 26, 2008 11:58 pm

Extracting Latex source from .png

Post by kkzs »

suppose i have a website like this > http://www.relativitycalculator.com/Alb ... t_II.shtml


does anybody know you can extract the latex coding from the equations which are all in .png format??

thanks, this would be an enormous help

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Re: Extracting Latex source from .png

Post by localghost »

There is no LaTeX coding in PNG files, hence there is nothing to extract. You have to rewrite the equations by yourself. Not really a big challenge.


Best regards
Thorsten¹
kkzs
Posts: 5
Joined: Wed Mar 26, 2008 11:58 pm

Extracting Latex source from .png

Post by kkzs »

thankyou for your reply, although i am a total newbie to latex i know its not difficult however it would save me a great deal of time if i could get to the coding so basically i am looking for a shortcut

i found this on the net form here http://www-cdf.fnal.gov/~cplager/latex/#png

Code: Select all

Extracting Latex source from .png File

To get the source code out of a png file that has been made with tex2png.pl, you use the script itself: 
cplager@Fcdflnx4> tex2png.pl -extract example.png
Extracting tex source from example.png to example.tex
or 
cplager@Fcdflnx4> tex2png.pl -extract example.png savetexhere.tex
Extracting tex source from example.png to savetexhere.tex
cannot be used??


or even this

http://www.fauskes.net/nb/htmleqII/
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Extracting Latex source from .png

Post by localghost »

Until now, I didn't know this Perl script. So, just test it on the PNG files from that website. You only need a Perl interpreter (for instance from ActiveState) and Netpbm. Any report about success is appreciated.
kkzs
Posts: 5
Joined: Wed Mar 26, 2008 11:58 pm

Re: Extracting Latex source from .png

Post by kkzs »

yes, thanks, as i said before i am a newbie and im really looking to save time so cant spend too much time trying to figure to figure things out as im already struggling :(
User avatar
Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Extracting Latex source from .png

Post by Stefan Kottwitz »

Hi kkzs!

I believe if you want to write LaTeX code, you will have to learn it. Of course it could save some time if you could convert those png images, but it does'nt require much knowledge to set common formulas.

Usually png files store all information with bitmap data, just pixels, plus some metadata. From the pixels you cannot reproduce the corresponding LaTeX code, at least I don't know a program that's able to do expression recognition this way.

The mentioned tex2png.pl puts latex code into the image as metadata. Very good, because you are able to extract the original LaTeX code later. But I'm afraid that will not help you, if the png files you need are not created this way.
I just ran pngmeta with one file, that was created by tex2png.pl, and one from that website. The first had LaTeX metadata inside, the other had not.

Stefan
kkzs
Posts: 5
Joined: Wed Mar 26, 2008 11:58 pm

Extracting Latex source from .png

Post by kkzs »

I believe if you want to write LaTeX code, you will have to learn it.

lol, thankyou for your help, i feared as much

however i am wondering if i can copy and paste from wikipedia? is this possible?
User avatar
Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Re: Extracting Latex source from .png

Post by Stefan Kottwitz »

Hi,

mathmatical wikipedia articles use TeX Syntax. You can click on edit and see the embedded formulas between <math> ... </math> tags. This way you can get their TeX source code.

Stefan
kkzs
Posts: 5
Joined: Wed Mar 26, 2008 11:58 pm

Re: Extracting Latex source from .png

Post by kkzs »

yes i know, but its not a good strategy as im finding it does not always work or the coding is incomplete, its fine for say a normal equation but if you want matrices then i encounter problems
User avatar
Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Re: Extracting Latex source from .png

Post by Stefan Kottwitz »

It should work with matrices too. Of course they are just code snippets, not working standalone. Important is that you include the amsmath package in your LaTeX document, escpecially for matrices and more complex expressions.

Stefan
Post Reply