优化打印算法

This commit is contained in:
admin
2026-02-24 23:34:10 +08:00
parent 92ac92f514
commit e9ac05592c
2 changed files with 142 additions and 16 deletions

View File

@@ -64,7 +64,7 @@ static const char *s_web_index =
" </div>\n"
"\n"
" <label>Z-Image Prompt</label>\n"
" <textarea id='imagePrompt'>一只坐在窗边的橘猫,午后阳光,胶片质感,写实风格。</textarea>\n"
" <textarea id='imagePrompt'>一只可爱橘猫正脸特写,黑白线稿风格,白色背景,主体居中,边缘清晰,细节简洁。</textarea>\n"
" <div class='row'>\n"
" <select id='imgSize' style='max-width:180px'>\n"
" <option value='1024*1024'>1024*1024</option>\n"
@@ -121,6 +121,7 @@ static const char *s_web_index =
" const imgScaleToWidthEl = document.getElementById('imgScaleToWidth');\n"
" const imgInvertEl = document.getElementById('imgInvert');\n"
" const imgPromptExtendEl = document.getElementById('imgPromptExtend');\n"
" const thermalPromptSuffix = 'black and white line art, pure white background, high contrast, clean edges, minimal texture, no dark background, no heavy shadows, centered subject, thermal printer friendly';\n"
"\n"
" function log(obj) {\n"
" if (typeof obj === 'string') {\n"
@@ -152,8 +153,13 @@ static const char *s_web_index =
" throw new Error('please input image prompt');\n"
" }\n"
"\n"
" const mergedPrompt = prompt + '\\n\\n' + thermalPromptSuffix;\n"
" if (mergedPrompt.length > 800) {\n"
" throw new Error('prompt too long after thermal optimization, please shorten it');\n"
" }\n"
"\n"
" return {\n"
" prompt,\n"
" prompt: mergedPrompt,\n"
" size: imgSizeEl.value || '1120*1440',\n"
" prompt_extend: imgPromptExtendEl.checked,\n"
" threshold: toInt(imgThresholdEl.value, 160, 0, 255),\n"