Collections:
indigo.generateImageAsBase64() - Generate Image as Base64
How to generate images of a given structure as a Base64 encoded string with the indigo.generateImageAsBase64() method?
✍: FYIcenter.com
If you want to generate an image of a given structure
in PNG, JPEG, or SVG format and Base64 encoded,
you can use the indigo.generateImageAsBase64() method on the Ketcher Indigo interface.
Here is an HTML document that shows you how to export the chemical structure from the Ketcher editor and generate an image.
<html> <!-- indigo-generate-image-as-base64.html Copyright (c) FYIcenter.com. --> <head> <title>Generate Image as Base64 Encoded String</title> </head> <body> <p>Create a chemical structure, then click generate button below the editor:</p> <iframe id=frmKetcher src="/ketcher/index.html" style="width: 680px; height: 400px;"></iframe> <p><button onclick="generate();">Generate Image</button></p> <p>SMILES:</p> <pre id=smiles style="background-color: #ddd;"></pre> <p>Output:</p> <img id=output /> <script> var ketcher = null; function generate() { frm = document.getElementById("frmKetcher"); ketcher = frm.contentWindow.ketcher; indigo = ketcher.indigo; promiseSmiles = ketcher.getSmiles(); promiseOutput = promiseSmiles.then(consumeSmiles, consumeSmiles); promiseOutput.then(consumeOutput, consumeOutput); } function consumeSmiles(result) { document.getElementById("smiles").innerHTML = result; opts = {outputFormat: "png", backgroundColor: "255, 255, 255"}; return indigo.generateImageAsBase64(result, opts); } function consumeOutput(result) { src = "data:image/png;base64,"+result; document.getElementById("output").src = src; } </script> </body> </html>
Open the above HTML document on your local Web server. Draw a molecule in the editor.
Click "Generate Image" button, you will see that the SMILES representation of the molecule and its image are displayed:
⇒ indigo.convert() - Convert Structure Formats
2023-11-09, 879🔥, 0💬
Popular Posts:
What Is PK (Pharmacokinetic) Related Terminologies? Here are main PK (Pharmacokinetic) related termi...
Molecule Summary: ID: FYI-1003309 Names: InChIKey: NVTQFXCWYXLLFT-UHFFFAOYS A-NSMILES: COc1ccccc1c3n...
Molecule Summary: ID: FYI-1004021 Names: InChIKey: KYGDFYAYDFGOTK-UHFFFAOYS A-NSMILES: O=N(=O)c3ccc(...
Molecule Summary: ID: FYI-1004430 Names: InChIKey: DFWFIQKMSFGDCQ-UHFFFAOYS A-NSMILES: CC(C)Nc1nc(N)...
Molecule Summary: ID: FYI-1003035 Names: InChIKey: BOXGZKHQZSJSRH-ONEGZZNKS A-NSMILES: CCc1nc(CS/C=C...