WebsiteTemplate/cheatsheets/chafa.html
2026-01-25 11:33:37 -04:00

181 lines
6.6 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'; style-src 'self'; font-src 'self' data:; img-src 'self' data:; connect-src 'self'; base-uri 'self'; form-action 'self' https://defcon.social https://bsky.app;">
<meta http-equiv="X-Content-Type-Options" content="nosniff">
<link rel="stylesheet" href="../assets/css/style.css">
<link rel="icon" type="image/x-icon" href="../favicon.ico">
<script>
// Apply theme immediately to prevent flash
(function() {
const theme = localStorage.getItem('theme') ||
(window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light');
document.documentElement.setAttribute('data-theme', theme);
})();
</script>
<title>chafa Cheatsheet - Cheatsheets - Launch Pad</title>
</head>
<body>
<button class="theme-toggle" id="themeToggle" aria-label="Toggle dark mode">
<svg class="theme-icon theme-icon-moon" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"></path></svg>
<svg class="theme-icon theme-icon-sun" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="display: none;"><circle cx="12" cy="12" r="5"></circle><line x1="12" y1="1" x2="12" y2="3"></line><line x1="12" y1="21" x2="12" y2="23"></line><line x1="4.22" y1="4.22" x2="5.64" y2="5.64"></line><line x1="18.36" y1="18.36" x2="19.78" y2="19.78"></line><line x1="1" y1="12" x2="3" y2="12"></line><line x1="21" y1="12" x2="23" y2="12"></line><line x1="4.22" y1="19.78" x2="5.64" y2="18.36"></line><line x1="18.36" y1="5.64" x2="19.78" y2="4.22"></line></svg>
</button>
<br/><br/>
<div class="name">
__ _______________________ _________._________________________
\_ _____/ \______ \ / _ \ / _____/ / _____/ | | \_ _____/
| __) | _/ / /_\ \ / \ ___ / \ ___ | | | __)_
| \ | | \ / | \ \ \_\ \ \ \_\ \ | |___ | \
\___ / |____|_ / \____|__ / \______ / \______ / |_______ \ /_______ /
\/ \/ \/ \/ \/ \/ \/
</div>
<div class="blog-page-header">
<div class="blog-header-content">
<a href="/cheatsheets" class="back-link" title="Back to Cheatsheets">
<svg xmlns="http://www.w3.org/2000/svg" width="42" height="42" viewBox="0 0 24 24" class="home-icon"><path fill="currentColor" d="M10 20v-6h4v6h5v-8h3L12 3 2 12h3v8z"/></svg>
</a>
<h1 class="blog-page-title">chafa Cheatsheet</h1>
</div>
</div>
<div class="blog-post-container">
<div class="blog-posts-container" style="max-width: 900px; margin: 0 auto;">
<div class="blog-post">
<div class="blog-post-content">
<p><a href="index.html">← Back to cheatsheets</a></p>
<p><a href="../index.html">← Home</a></p>
<hr>
<p>chafa is a terminal image viewer and converter. Converts images to ANSI art, Unicode blocks, or sixel graphics for display in terminals.</p>
<hr>
<h2>Basic Usage</h2>
<ul>
<li>chafa &lt;image&gt; - Display image in terminal</li>
</ul>
<ul>
<li>chafa -f &lt;format&gt; &lt;image&gt; - Specify output format</li>
</ul>
<ul>
<li>chafa -s &lt;size&gt; &lt;image&gt; - Set output size</li>
</ul>
<ul>
<li>chafa -c &lt;colors&gt; &lt;image&gt; - Set color mode</li>
</ul>
<hr>
<h2>Output Formats</h2>
<ul>
<li>chafa -f symbols &lt;image&gt; - Unicode symbols (default)</li>
</ul>
<ul>
<li>chafa -f sixel &lt;image&gt; - Sixel graphics</li>
</ul>
<ul>
<li>chafa -f kitty &lt;image&gt; - Kitty terminal protocol</li>
</ul>
<ul>
<li>chafa -f iterm2 &lt;image&gt; - iTerm2 protocol</li>
</ul>
<ul>
<li>chafa -f none &lt;image&gt; - No output (for testing)</li>
</ul>
<hr>
<h2>Size Options</h2>
<ul>
<li>chafa -s &lt;width&gt;x&lt;height&gt; &lt;image&gt; - Set dimensions</li>
</ul>
<ul>
<li>chafa -s &lt;size&gt; &lt;image&gt; - Set size (width only, auto height)</li>
</ul>
<ul>
<li>chafa -s auto &lt;image&gt; - Auto size based on terminal</li>
</ul>
<ul>
<li>chafa -s max &lt;image&gt; - Maximum size</li>
</ul>
<hr>
<h2>Color Options</h2>
<ul>
<li>chafa -c 16 &lt;image&gt; - 16 colors</li>
</ul>
<ul>
<li>chafa -c 256 &lt;image&gt; - 256 colors</li>
</ul>
<ul>
<li>chafa -c full &lt;image&gt; - Full color (24-bit)</li>
</ul>
<ul>
<li>chafa -c none &lt;image&gt; - No color (monochrome)</li>
</ul>
<hr>
<h2>Display Options</h2>
<ul>
<li>chafa --animate &lt;image&gt; - Animate GIF/APNG</li>
</ul>
<ul>
<li>chafa --center &lt;image&gt; - Center image</li>
</ul>
<ul>
<li>chafa --bg &lt;color&gt; &lt;image&gt; - Set background color</li>
</ul>
<ul>
<li>chafa --fg &lt;color&gt; &lt;image&gt; - Set foreground color</li>
</ul>
<ul>
<li>chafa --dither &lt;mode&gt; &lt;image&gt; - Set dithering mode</li>
</ul>
<ul>
<li>chafa --threshold &lt;value&gt; &lt;image&gt; - Set threshold for symbols</li>
</ul>
<hr>
<h2>Common Examples</h2>
<h3>Basic Display</h3>
<pre><code>chafa image.png</code></pre>
<p>Display image in terminal.</p>
<h3>Custom Size</h3>
<pre><code>chafa -s 80x40 image.png</code></pre>
<p>Display at specific dimensions.</p>
<h3>Sixel Format</h3>
<pre><code>chafa -f sixel image.png</code></pre>
<p>Use sixel graphics format.</p>
<h3>Full Color</h3>
<pre><code>chafa -c full -s 100 image.png</code></pre>
<p>Full color at 100 width.</p>
<h3>Animated GIF</h3>
<pre><code>chafa --animate animation.gif</code></pre>
<p>Display animated GIF.</p>
<h3>Monochrome</h3>
<pre><code>chafa -c none image.png</code></pre>
<p>Display in monochrome.</p>
<hr>
<h2>Tips</h2>
<ul>
<li>Use -s auto for automatic sizing based on terminal</li>
</ul>
<ul>
<li>Use -c full for best color quality in modern terminals</li>
</ul>
<ul>
<li>Use -f sixel for better quality in terminals that support it</li>
</ul>
<ul>
<li>Use --animate to view animated images</li>
</ul>
<ul>
<li>Works great with image previewers in file managers</li>
</ul>
<ul>
<li>Can be piped to other commands for processing</li>
</ul>
<ul>
<li>Supports many image formats: PNG, JPEG, GIF, WebP, etc.</li>
</ul>
</div>
</div>
</div>
</div>
<script async type="text/javascript" src="../blog/analytics.js"></script>
<script src="../theme.js"></script>
</body>
</html>