mirror of
https://github.com/Nexoniarz/YAPF.git
synced 2026-11-02 20:44:27 +00:00
Format (version 1, replaces the earlier experimental versions): - per-tile YCoCg-R or subtract-green colour transform, 8-bit modular - 12 row filters per 8-row band (Left, Gradient, Up-right, Up-average, Up 1-8 rows), none with more than a one-add serial dependency - residuals in groups of 8 at the group's width (w bits x 8 = w bytes), 4-bit control codes with repeat-previous-width runs chosen by DP - constant and stored tiles, independent 64x64 tiles, mips, GPU hints - all sizes validated before decoding; corrupt input is rejected Library: - SIMD on by default: SSSE3 (runtime CPUID check; GCC, Clang, MSVC, MinGW) and NEON on ARM64; -DYAPF_NO_SIMD for plain C - yapf_load_memory, yapf_load_mt, yapf_load_memory_mt - 6-10x faster decoding than PNG (stb_image) on one core; -O2 and -O3 builds perform the same - fixes for macOS (sysconf) and the Windows import library exports Tools and integrations: - `yapf` CLI: convert PNG/JPG/TGA/BMP/PSD/GIF <-> YAPF, info, bench, thumbnail, mips - JavaScript and Python bindings (byte-identical to the C encoder) - GIMP 3 plugin: exports the flattened image, optional mipmaps - Blender extension: import (also as plane), export, drag and drop - VS Code preview, Figma plugin, Photoshop scripts, Linux MIME type and thumbnailer - Makefile, updated build.sh / build.bat, tools/build_release.sh - tests/test_yapf.c (784 checks) and bindings/js/test.js Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
41 lines
1.6 KiB
Text
41 lines
1.6 KiB
Text
// Shared helpers for the YAPF Photoshop scripts.
|
|
// Copyright 2026 Nexoniarz — Apache License 2.0.
|
|
//
|
|
// The scripts convert through the `yapf` command-line tool. It is looked
|
|
// up next to these scripts first (yapf.exe / yapf), then on the PATH.
|
|
|
|
var YAPF_IS_WINDOWS = $.os.indexOf("Windows") !== -1;
|
|
|
|
function yapfQuote(s) {
|
|
return '"' + String(s).replace(/"/g, '\\"') + '"';
|
|
}
|
|
|
|
function yapfTool() {
|
|
var here = new File($.fileName).parent;
|
|
var names = YAPF_IS_WINDOWS ? ["yapf.exe"] : ["yapf"];
|
|
for (var i = 0; i < names.length; i++) {
|
|
var f = new File(here.fsName + "/" + names[i]);
|
|
if (f.exists) return f.fsName;
|
|
}
|
|
return names[0]; // rely on the PATH
|
|
}
|
|
|
|
// Runs the tool; returns true when `expectOut` was produced.
|
|
function yapfRun(args, expectOut) {
|
|
var cmd = yapfQuote(yapfTool());
|
|
for (var i = 0; i < args.length; i++) cmd += " " + (args[i].charAt(0) === "-" ? args[i] : yapfQuote(args[i]));
|
|
if (YAPF_IS_WINDOWS) cmd = '"' + cmd + '"'; // cmd.exe strips one pair of quotes
|
|
if (expectOut.exists) expectOut.remove();
|
|
app.system(cmd);
|
|
return expectOut.exists;
|
|
}
|
|
|
|
function yapfTempFile(ext) {
|
|
return new File(Folder.temp.fsName + "/yapf_" + new Date().getTime() + "_" +
|
|
Math.floor(Math.random() * 1e6) + ext);
|
|
}
|
|
|
|
var YAPF_TOOL_HELP =
|
|
"The 'yapf' command-line tool was not found or failed.\n\n" +
|
|
"Put yapf" + (YAPF_IS_WINDOWS ? ".exe" : "") + " in the same folder as this script, " +
|
|
"or add it to your PATH.\nDownload or build it: https://github.com/Nexoniarz/YAPF";
|