Under macOS I want to convert HTML files with referenced images on the command line/programatically to webarchives.
Given a sample file sample.html
containing:
<html><body>
<h1>File with resource</h1>
<p>This file shows text and references an image.</p>
<img src="sample.jpg" />
</body></html>
and an image sample.jpg
in the same directory, I can view the html file in any browser and it is render with the image. To convert to a webarchive I tried:
textutil -convert webarchive sample.html
but the resulting sample.webarchive
does not, when opened in Safari, render the image - though it contains it (see comments).
How can I do the conversion from the command line correctly, so that the result contains and renders the image? After all that's what webarchives are for!
sample.html
in Safari, create the webarchive from there, then move both files away and open the archive in Safari?plutil -p WEBARCHIVE
). I didn't look into the differences though.plutil
(I knew that webarchives use theplist
format, but didn't think of analysing them withplutil
.Will investigate in more detail.