# Incorporating photos into a Mathematica-made web page

I use Mathematica to make my web page. I make various .nb files, usually with photos, and then use an Export command to convert the .nb file to an .html file with auxiliary links and photo files. This has worked well for me...

... except: Once in a while the photos come out at poor resolution despite my best efforts. I have tried

Export["my.html", nb, "HTML", "GraphicsOutput" -> "JPEG"]


to guarantee that a jpg appears but I think it gets rasterized at a low resolution regardless of how high a resolution the pasted jpeg in the notebook has.

Has anyone run into this?

Any ideas how to force the Export command to generate the image file (whether a jpg or gif) at some minimum resolution?

• Thanks. It sounds like just the thing....but it failed. I used: Export[outputstring, Import[inputstring], "Notebook", "ConvertClosed" -> "LinkedPage", "GraphicsOutput" -> {"JPEG", "CompressionLevel" -> 0}] But no change. It turned the source image of size about 6 mb to a jpeg have size 91 kb. So the compression is 65 times, which is of course a big problem. – stan wagon May 16 '15 at 14:30
• Does PNG fare any better as export format? – Yves Klett May 16 '15 at 16:26
• Re. PNG: Yes I had tried that an hour ago and indeed it is creating larger image files, and the overall result is better. Rasterizing each of the many images in the file? Well I will try one as a test to see if that helps. But PNG seems to be a step in the right direction. A little frustrating though since there ought to be a way to get a JPG at appropriate size. – stan wagon May 16 '15 at 17:06
• Sometimes I have also encountered different frontend behaviour depending on whether an image is a Graphics  or Image construct. Perhaps you can supply more specific info or an example to reproduce the issue. – Yves Klett May 16 '15 at 19:22
• Actually, I cannot reproduce this problem on OS X. – Jens May 17 '15 at 3:37

I haven't seen a clear cut solution listed anywhere even though this question is quite old. Thus, I will post my solution here. The easiest solution is to use SVG format rather than to fiddle with JPEG, GIF, or PNG format.

filePath = "path of the file";
nb = Import[filepath];
Export["my3.html", nb, "HTML", "GraphicsOutput" -> "SVG", "MathOutput" -> "SVG"]


This will make sure that your graphics and math output in HTML will be shown in high resolution.

For more information check out the wolfram documentation center, http://reference.wolfram.com/language/ref/format/HTML.html especially under column "Options" → "Export options".

• Thank you. I will try it. – stan wagon Aug 9 '17 at 13:13
• This works well and might help out with some problems I had with my former method. But when I used the code thus: Export[outputstring, Import[inputstring], "Notebook", "ConvertClosed" -> "LinkedPage", "GraphicsOutput" -> "SVG", "MathOutput" -> "SVG"]; the font in the html file became Helvetica. My original file uses Times. Might you know how to control this? – stan wagon Aug 29 '17 at 17:58
• Inside the notebook that you want to export, add the following code, Export["desktop.html", InputNotebook[], "HTML", "ConvertClosed"->False, "GraphicsOutput"->"SVG","MathOutput"->"SVG"] .See if this creates a html file without the error. – Tadashi Kikuno Aug 31 '17 at 5:55
• Also check and see if other fonts are displayed correctly. For example, choose Georgia instead of Times. – Tadashi Kikuno Aug 31 '17 at 6:14