mirror of
https://github.com/Nexoniarz/YAPF.git
synced 2026-11-02 20:44:27 +00:00
- KDE thumbnailer: texture loader, decodes only the mip it needs; GPU blocks, 16-bit and float via the new yapf_tex_to_rgba8. Tested through KDE's plugin loader with KF6 from nixpkgs. - Photoshop: shows the tool's error message; HDR textures open as 32-bit (.hdr), 16-bit stays 16-bit; 16-bit documents save as 16-bit. - CLI: 16-bit PNG export, readable conversion errors. - default.nix: yapf tool, library, header, MIME type and thumbnailer (absolute store path); runs the test suite. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DVrVthWN8GsmgHGUhhsCYm
42 lines
1.9 KiB
JavaScript
42 lines
1.9 KiB
JavaScript
// 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);
|
|
// 8 and 16 bits per channel are kept (16-bit becomes a 16-bit
|
|
// YAPF texture); 32-bit documents are saved as 16-bit.
|
|
if (copy.bitsPerChannel === BitsPerChannelType.THIRTYTWO)
|
|
copy.bitsPerChannel = BitsPerChannelType.SIXTEEN;
|
|
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" + yapfFailText()); return; }
|
|
alert("Saved " + out.fsName + " (" + Math.round(out.length / 1024) + " KB)");
|
|
})();
|