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, 733🔥, 0💬
Popular Posts:
Molecule Summary: ID: FYI-1003442 Names: InChIKey: BISZVQBJVGCQJV-UHFFFAOYS A-NSMILES: [Na+].[Na+].F...
Molecule Summary: ID: FYI-1000951 SMILES: CCCCCC1=CC(=C(C(=C1)O)C2 C=C(CCC2C(=C)C)C)OReceived at FYI...
Molecule Summary: ID: FYI-1003337 Names: InChIKey: GUXJRQNFMUDSRU-UHFFFAOYS A-NSMILES: CC(C)C(C(=O)N...
Molecule Summary: ID: FYI-1005412 Names: InChIKey: YIMQCDZDWXUDCA-UHFFFAOYS A-NSMILES: OCC1CCC(CO)CC...
Molecule Summary: ID: FYI-1003644 Names: InChIKey: JUCACKLNHTWUCA-UHFFFAOYS A-NSMILES: Cn1nccc1c2cc(...