Cannot get imageConvert to work
See original GitHub issueHi,
I’m trying to get a custom image converter working, but it does not seem to get called. I’m trying to write the image out to a file. If I also change the return src to be “dataxxxxxxxx”, the resulting output still just shows “data:”
Here is my code. Any thoughts would be appreciated.
var options = {
path: dir + "/sig.docx",
convertImage: mammoth.images.inline(function(element) {
return element.read("base64").then(function(imageBuffer) {
fs.writeFile(dir + "/image.jpg", imageBuffer, function(err) {
if(err) {
console.log(err);
} else {
console.log("The file was saved!");
}
});
return {
src: "dataxxxxxxx:" + element.contentType + ";base64," + imageBuffer
};
});
})
};
mammoth.convertToHtml(options).....
Thanks Gary.
Issue Analytics
- State:
- Created 9 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Can't get simple JPEG convert to work - Legacy ImageMagick ...
Can't get simple JPEG convert to work ... I have ImageMagick working on the command line (although it didn't until I added the...
Read more >Can't get image thumbnailing to work / ImageMagick 7
Images and image uploading work fine, but we can't get image thumbnailing to work. I've installed ImageMagick 7 on the host machine ...
Read more >Imagemagick convert: Can't get -pointsize to use a calculated ...
I've confirmed that the pointsize option itself does work when setting a static value, e.g. convert image.jpg -pointsize 30 -annotate 0 ' ...
Read more >Can't get ImageMagick -fft to execute in Command Prompt
I downloaded ImageMagick (Windows 7 64-bit) and FFTW, and I can do simple commands but I can't use the -fft option. Commands are...
Read more >Emacs is compiled with imagemagick and has right PATH but ...
The best "solution" I was able to find was to use the "emacs-mac" port of emacs (https://github.com/railwaycat/homebrew-emacsmacport):
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
What was happening was that it was converting the images to base64 and doing it inline, which is great! But I believe we would like to have an option as well to save the images as a file and put it in the directory. I dont think its advisable to base64 all images of a word doc
You can do this using your own image converter. Take a look at the one the CLI uses for an example.
https://github.com/mwilliamson/mammoth.js/blob/eaefb859906c56e44c6a0ae4efeb407cf92a8e7d/lib/main.js#L27
On Mon, 18 Sep 2017 16:02:01 -0700 Nino Ross Rodriguez notifications@github.com wrote: