Skip to content

Commit

Permalink
feat: initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
alekmaul committed May 1, 2024
1 parent 6f9fb9c commit 03521c8
Show file tree
Hide file tree
Showing 7 changed files with 1,803 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tools/tiledpalettequant/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 rilden

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Binary file added tools/tiledpalettequant/carina-nebula.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 32 additions & 0 deletions tools/tiledpalettequant/enums.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

161 changes: 161 additions & 0 deletions tools/tiledpalettequant/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
<!doctype html>
<html lang="en">

<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" href="data:;base64,iVBORw0KGgo=">
<link rel="stylesheet" href="style.css">
<title>Tiled Palette Quantization</title>
</head>

<body id="body">
<div>
<h2>Tiled Palette Quantization</h2>
<p>Quick way to create a palletized image</p>

<div>
<img id="source_img" src="carina-nebula.png" alt="source image">
<table>
<tr>
<td><label for="image_selector">Input image:</label></td>
<td><input type="file" id="image_selector" accept="image/*"></td>
</tr>
<tr>
<td><label for="tile_width">Tile width</label></td>
<td><input type="number" id="tile_width" min="1" max="32" step="1" value="8"></td>
</tr>
<tr>
<td><label for="tile_height">Tile height</label></td>
<td><input type="number" id="tile_height" min="1" max="32" step="1" value="8"></td>
</tr>
<tr>
<td><label for="palette_num">Palettes:</label></td>
<td><input type="number" id="palette_num" min="1" max="16" step="1" value="8"></td>
</tr>
<tr>
<td><label for="colors_per_palette">Colors per palette:</label></td>
<td><input type="number" id="colors_per_palette" min="2" max="256" step="1" value="4"></td>
</tr>
<tr>
<td><label for="bits_per_channel">Bits per channel:</label></td>
<td><input type="number" id="bits_per_channel" min="2" max="8" step="1" value="5"></td>
</tr>
<tr>
<td><label for="fraction_of_pixels">Fraction of pixels:</label></td>
<td><input type="number" id="fraction_of_pixels" min="0.01" max="10" step="any" value="0.1"></td>
</tr>
</table>
</div>
<fieldset>
<legend>Color index zero behaviour</legend>
<table>
<tr>
<td>
<input type="radio" id="unique" name="color_zero" value="unique" checked>
<label for="unique">unique</label>
</td>
</tr>
<tr>
<td>
<input type="radio" id="shared" name="color_zero" value="shared">
<label for="shared">shared color:</label>
<input type="color" id="shared_color" value="#000000" aria-label="shared color">
</td>
</tr>
<tr>
<td>
<input type="radio" id="transparent_from_transparent" name="color_zero" value="transparent_from_transparent">
<label for="transparent_from_transparent">transparent, from transparent pixels</label>
</td>
</tr>
<tr>
<td>
<input type="radio" id="transparent_from_color" name="color_zero" value="transparent_from_color">
<label for="transparent_from_color">transparent color:</label>
<input type="color" id="transparent_color" value="#ff00ff" aria-label="transparent color">
</td>
</tr>
</table>
</fieldset>
<fieldset>
<legend>Dithering</legend>
<table>
<tr>
<td>
<input type="radio" id="dither_off" name="dither" value="dither_off" checked>
<label for="dither_off">disabled</label>
</td>
</tr>
<tr>
<td>
<input type="radio" id="dither_fast" name="dither" value="dither_fast">
<label for="dither_fast">fast</label>
</td>
</tr>
<tr>
<td>
<input type="radio" id="dither_slow" name="dither" value="dither_slow">
<label for="dither_slow">slow</label>
</td>
</tr>
<tr>
<td><label for="dither_weight">Dither weight:</label></td>
<td><input type="number" id="dither_weight" min="0.01" max="1" step="any" value="0.5"></td>
</tr>
</table>
</fieldset>
<fieldset>
<legend>Dither pattern</legend>
<table>
<tr>
<td>
<input type="radio" id="dither_diagonal4" name="dither_pattern" value="dither_diagonal4" checked>
<label for="dither_diagonal4">diagonal4</label>
</td>
<td>
<input type="radio" id="dither_diagonal2" name="dither_pattern" value="dither_diagonal2">
<label for="dither_diagonal2">diagonal2</label>
</td>
</tr>
<tr>
<td>
<input type="radio" id="dither_horizontal4" name="dither_pattern" value="dither_horizontal4">
<label for="dither_horizontal4">horizontal4</label>
</td>
<td>
<input type="radio" id="dither_horizontal2" name="dither_pattern" value="dither_horizontal2">
<label for="dither_horizontal2">horizontal2</label>
</td>
</tr>
<tr>
<td>
<input type="radio" id="dither_vertical4" name="dither_pattern" value="dither_vertical4">
<label for="dither_vertical4">vertical4</label>
</td>
<td>
<input type="radio" id="dither_vertical2" name="dither_pattern" value="dither_vertical2">
<label for="dither_vertical2">vertical2</label>
</td>
</tr>
</table>
</fieldset>
<div>
<button type="button" id="quantizeButton">Quantize</button>
<progress id="progress" max="100" value="0"></progress>
</div>
<div id="quantized_images">
</div>
<script type="module" src="script.js"></script>

<p>
Written by rilden in 2022.
</p>

<p>
<a href="https://github.com/rilden/tiledpalettequant" target="github">[Source on github]</a>
</p>
</div>
</body>

</html>
Loading

0 comments on commit 03521c8

Please sign in to comment.