/** * [[include:src/codecs/png/README.md]] * * @module codecs/png */ import schema from '@stencila/schema'; import * as vfile from '../../util/vfile'; import { Codec, CommonDecodeOptions, CommonEncodeOptions } from '../types'; export type DecodeOptions = CommonDecodeOptions; export interface EncodeOptions extends CommonEncodeOptions { /** * CSS selector for item/s to take an image of */ selector?: string; /** * The size of the image to create. Only applicable when * screen-shotting a node to create the image. */ size?: { width: number; height: number; }; } export declare class PngCodec extends Codec implements Codec { /** * @override {@link Codec.mediaTypes} */ readonly mediaTypes: string[]; /** * Decode a PNG image to a `ImageObject` node. * * If the `VFile` does not have a path, then it * is written to a temporary file, and that path used * for the image's `contentUrl`. * * @override {@link Codec.decode} */ readonly decode: (file: vfile.VFile) => Promise; /** * @override Overrides {@link Codec.preWrite} so that media files * do NOT get written to a sibling folder (since they are effectively * included in the PNG file). */ preWrite(node: schema.Node): Promise; /** * Encode a Stencila `Node` to a PNG. * * For `ImageObject` nodes, this simply saves the `contentUrl` as a * local, temporary file. For other node types, by dumping the node to HTML, and then * "screen-shotting" the HTML to a PNG. * * @override {@link Codec.encode} */ readonly encode: (node: schema.Node, options?: EncodeOptions) => Promise; }