mirror of
https://github.com/Nexoniarz/YAPF.git
synced 2026-11-03 04:54:26 +00:00
YAPF v1: fast byte-aligned format, SIMD, tools and plugins
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>
This commit is contained in:
parent
b9b8c93a22
commit
2ca726e3af
48 changed files with 14905 additions and 710 deletions
40
extensions/photoshop/Save as YAPF.jsx
Normal file
40
extensions/photoshop/Save as YAPF.jsx
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
// Save as YAPF — writes the active document as a .yapf image.
|
||||
// Copyright 2026 Nexoniarz — Apache License 2.0.
|
||||
// The visible result is saved: a flattened 8-bit RGB (or grayscale) copy,
|
||||
// transparency kept. Your document is not modified.
|
||||
|
||||
#target photoshop
|
||||
#include "yapf_common.jsxinc"
|
||||
|
||||
(function () {
|
||||
if (!app.documents.length) { alert("Open a document first."); return; }
|
||||
var doc = app.activeDocument;
|
||||
|
||||
var base = doc.name.replace(/\.[^.]+$/, "");
|
||||
var start = new File((doc.saved && doc.path ? doc.path.fsName : Folder.desktop.fsName) + "/" + base + ".yapf");
|
||||
var out = start.saveDlg("Save as YAPF", YAPF_IS_WINDOWS ? "YAPF images:*.yapf" : undefined);
|
||||
if (!out) return;
|
||||
if (!/\.yapf$/i.test(out.name)) out = new File(out.fsName + ".yapf");
|
||||
var mips = confirm("Also store mipmaps (for game engines / GPUs)?", true, "YAPF");
|
||||
|
||||
var tmp = yapfTempFile(".png");
|
||||
var copy = doc.duplicate(base + " (YAPF export)", true); // merged copy
|
||||
try {
|
||||
if (copy.mode !== DocumentMode.RGB && copy.mode !== DocumentMode.GRAYSCALE)
|
||||
copy.changeMode(ChangeMode.RGB);
|
||||
if (copy.bitsPerChannel !== BitsPerChannelType.EIGHT)
|
||||
copy.bitsPerChannel = BitsPerChannelType.EIGHT;
|
||||
var opts = new PNGSaveOptions();
|
||||
opts.interlaced = false;
|
||||
copy.saveAs(tmp, opts, true, Extension.LOWERCASE);
|
||||
} finally {
|
||||
copy.close(SaveOptions.DONOTSAVECHANGES);
|
||||
}
|
||||
|
||||
var args = [tmp.fsName, out.fsName];
|
||||
if (mips) args.push("--mips");
|
||||
var ok = yapfRun(args, out);
|
||||
tmp.remove();
|
||||
if (!ok) { alert("Could not write " + out.name + ".\n\n" + YAPF_TOOL_HELP); return; }
|
||||
alert("Saved " + out.fsName + " (" + Math.round(out.length / 1024) + " KB)");
|
||||
})();
|
||||
Loading…
Reference in a new issue