How to use term-img - 6 common examples

To help you get started, we’ve selected a few term-img examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github palmerhq / cypress-image-snapshot / src / reporter.js View on Github external
cache.forEach(({ diffRatio, diffPixelCount, diffOutputPath }) => {
        console.log(
          `\n  - ${diffOutputPath}\n    Screenshot was ${diffRatio *
            100}% different from saved snapshot with ${diffPixelCount} different pixels.\n`
        );
        termImage(diffOutputPath, { fallback });
      });
    }
github dongy7 / twitch-chat-cli / cli.js View on Github external
emotes.forEach(emote => {
      const { id, code } = emote
      const img = termImg.string(path.join(IMAGES_DIR, `${id}.png`))
      map[code] = img
    })
  })
github freaktechnik / twitch-chatlog / lib / index.js View on Github external
return stringReplaceAsync(f.text, /(^|\b)([0-9a-z]+[a-z])(\d+)(\b|$)/g, async (match, prefix, type, amount, postfix) => {
                        if(cheerEmoteList.includes(type)) {
                            const tier = getCheerTier(type, amount, cheerEmotes);
                            if(loadImages) {
                                const emote = await getCheerEmote(type, tier);
                                return prefix + termImg.string(emote, {
                                    fallback: () => cheers.formatCheer(amount, tier.color)
                                }) + chalk.bold.hex(tier.color)(amount) + postfix;
                            }
                            return prefix + cheers.formatCheer(amount, tier.color) + postfix;
                        }
                        return match;
                    });
                }
github sindresorhus / terminal-image / index.js View on Github external
exports.buffer = async buffer => {
	return termImg.string(buffer, {
		width: '100%',
		height: '100%',
		fallback: () => render(buffer)
	});
};
github freaktechnik / twitch-chatlog / lib / index.js View on Github external
const frags = await Promise.all(msg.message.fragments.map(async (f) => {
                if(f.emoticon && loadImages) {
                    const emote = await getEmoticon(f.emoticon.emoticon_id);
                    return termImg.string(emote, {
                        fallback: () => f.text
                    });
                }
                else if(msg.message.bits_spent) {
                    return stringReplaceAsync(f.text, /(^|\b)([0-9a-z]+[a-z])(\d+)(\b|$)/g, async (match, prefix, type, amount, postfix) => {
                        if(cheerEmoteList.includes(type)) {
                            const tier = getCheerTier(type, amount, cheerEmotes);
                            if(loadImages) {
                                const emote = await getCheerEmote(type, tier);
                                return prefix + termImg.string(emote, {
                                    fallback: () => cheers.formatCheer(amount, tier.color)
                                }) + chalk.bold.hex(tier.color)(amount) + postfix;
                            }
                            return prefix + cheers.formatCheer(amount, tier.color) + postfix;
                        }
                        return match;
github flood-io / element / packages / element / src / runtime / Browser.ts View on Github external
public async saveScreenshot(fn: (path: string) => Promise): Promise {
		const path = this.workRoot.join('screenshots', `${cuid()}.jpg`)
		debugScreenshot(`Saving screenshot to: ${path}`)

		if (await fn(path)) {
			this.screenshots.push(path)
			debugScreenshot(`Saved screenshot to: ${path}`)

			termImg(path, {
				width: '40%',
				fallback: () => {
					return `Screenshot path: ${path}`
				},
			})
		}
	}
}

term-img

Display images in iTerm

MIT
Latest version published 5 months ago

Package Health Score

70 / 100
Full package analysis

Popular term-img functions