Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikachu2333 authored Dec 19, 2023
1 parent fee7718 commit e63c07c
Show file tree
Hide file tree
Showing 3 changed files with 179 additions and 179 deletions.
2 changes: 1 addition & 1 deletion default.aproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<project ver="10" name="RealesrganRimagePicImprove" libEmbed="true" icon="asdf.ico" ui="win" output="RealesrganRimagePicImprove.exe" CompanyName="None" FileDescription="ImproveAnimePic" LegalCopyright="Copyright (C) MIKA 2023 MIT License" ProductName="AnimePicImprover" InternalName="RealesrganRimagePicImprove" FileVersion="1.3.2.14" ProductVersion="1.3.2.14" publishDir="/dist/" dstrip="true">
<project ver="10" name="RealesrganRimagePicImprove" libEmbed="true" icon="asdf.ico" ui="win" output="RealesrganRimagePicImprove.exe" CompanyName="None" FileDescription="ImproveAnimePic" LegalCopyright="Copyright (C) MIKA 2023 MIT License" ProductName="AnimePicImprover" InternalName="RealesrganRimagePicImprove" FileVersion="1.3.3.14" ProductVersion="1.3.3.14" publishDir="/dist/" dstrip="true">
<file name="main.aardio" path="main.aardio" comment="main.aardio"/>
<folder name="资源文件" path="res" embed="true" local="false" ignored="false"/>
<folder name="窗体文件" path="dlg" comment="目录" embed="true" local="false" ignored="false"/>
Expand Down
356 changes: 178 additions & 178 deletions main.aardio
Original file line number Diff line number Diff line change
@@ -1,179 +1,179 @@
import fsys.dlg
import gdip
import process
import process.popen
import sevenZip.decoder2
import win.ui
/*DSG{{*/
mainForm = win.form(cls="RIMG_GUI_FORM";text="RealesrganRimagePicImprove";right=587;bottom=412;border="thin";max=false)
mainForm.add(
auto_del={cls="checkbox";text="删除原图";left=486;top=119;right=580;bottom=144;bgcolor=65535;color=255;font=LOGFONT(h=-16;name='微软雅黑');z=10};
auto_improve={cls="checkbox";text="自动缩小";left=486;top=39;right=580;bottom=64;bgcolor=65535;checked=1;color=255;font=LOGFONT(h=-16;name='微软雅黑');z=12};
edit_o_d={cls="edit";left=158;top=381;right=477;bottom=406;autovscroll=false;clip=1;edge=1;font=LOGFONT(h=-14;name='微软雅黑');readonly=1;z=15};
edit_o_q={cls="edit";text="95";left=508;top=184;right=554;bottom=209;align="center";edge=1;font=LOGFONT(h=-16;name='微软雅黑');multiline=1;num=1;z=7};
file_list={cls="listbox";left=8;top=35;right=479;bottom=329;edge=1;font=LOGFONT(h=-14;name='微软雅黑');hscroll=1;items={};vscroll=1;z=3};
out_format={cls="combobox";left=495;top=301;right=570;bottom=327;edge=1;font=LOGFONT(h=-16;name='微软雅黑');items={"jpg";"png";"webp";"avif"};mode="dropdown";z=9};
process_show={cls="edit";left=8;top=327;right=477;bottom=378;clip=1;clipch=1;edge=1;font=LOGFONT(h=-14;name='微软雅黑');multiline=1;readonly=1;z=1};
show_hide={cls="checkbox";text="隐藏执行";left=486;top=78;right=580;bottom=103;bgcolor=65535;checked=1;color=255;font=LOGFONT(h=-16;name='微软雅黑');z=11};
size_to={cls="combobox";left=508;top=243;right=554;bottom=269;edge=1;font=LOGFONT(h=-16;name='微软雅黑');items={"2";"1";"4"};mode="dropdown";z=14};
start_cov={cls="button";text="开始";left=482;top=344;right=580;bottom=397;border=1;default=1;font=LOGFONT(h=-17;name='微软雅黑');z=5};
static={cls="static";text="放大倍数";left=494;top=215;right=569;bottom=240;align="center";center=1;font=LOGFONT(h=-16;name='微软雅黑');notify=1;transparent=1;z=13};
static_file_list={cls="static";text="文件列表 File list";left=3;top=7;right=137;bottom=32;align="center";center=1;font=LOGFONT(h=-16;name='微软雅黑');notify=1;transparent=1;z=4};
static_out_dir={cls="static";text="输出目录 Out-Dir:";left=10;top=381;right=158;bottom=406;align="center";center=1;font=LOGFONT(h=-16;name='微软雅黑');notify=1;transparent=1;z=2};
static_out_format={cls="static";text="输出格式";left=495;top=273;right=570;bottom=298;align="center";center=1;font=LOGFONT(h=-16;name='微软雅黑');notify=1;transparent=1;z=8};
static_out_quailty={cls="static";text="输出质量";left=494;top=156;right=569;bottom=181;align="center";center=1;font=LOGFONT(h=-16;name='微软雅黑');notify=1;transparent=1;z=6}
)
/*}}*/

if((not io.exist(io._exedir + "realesrgan_rimage\rimage.exe")) or (io.getSize(io._exedir + "realesrgan_rimage\rimage.exe") != 27413536)){
io.remove(io._exedir + "realesrgan_rimage.7z")
io.remove(io._exedir + "realesrgan_rimage\rimage.exe")
string.save(io._exedir + "realesrgan_rimage.7z",$"\res\realesrgan_rimage.7z",true)
var temp_7z = sevenZip.decoder2()
temp_7z.open(io._exedir + "realesrgan_rimage.7z")
temp_7z.extract(io._exedir)
temp_7z.close()
io.remove(io._exedir + "realesrgan_rimage.7z")
}
mainForm.show()

mainForm.process_show.text = "(双击清空)显示运行情况"
mainForm.file_list.add("双击左键添加,选中后使用右键删除")
mainForm.file_list.add("双击下方的“(双击清空)”以快速清空文件列表")

mainForm.process_show.wndproc = function(hwnd,message,wParam,lParam){
select(message){
case 0x203/*_WM_LBUTTONDBLCLK*/{
mainForm.file_list.clear()
}
}
}

mainForm.edit_o_d.wndproc = function(hwnd,message,wParam,lParam){
select(message){
case 0x203/*_WM_LBUTTONDBLCLK*/{
temp = fsys.dlg.openDir(,mainForm.hwnd,"请选择目录 Please select the Dir for output")
if(temp != null){
mainForm.edit_o_d.text = """" + temp + """"
}else{
win.msgbox('请选择正确的目录\nPlease select right dir to save.',"Warning",,mainForm.hwnd,2000)
}
}
}
}

mainForm.edit_o_d.text = """" + string.left(io._exedir,-2,true) + """"

var count = null
mainForm.onDropFiles = function(files){
if(count == null){
mainForm.file_list.clear()
count = 0
}
var temp_list = {
".png";
".jpg";
".jpeg";
}
for(k,v in files){
temp_ext = io.splitpath(v).ext
for m,n in temp_list{
if(n == temp_ext){
mainForm.file_list.add(v)
}
}
}
mainForm.edit_o_d.text = """" + string.left(io.splitpath(mainForm.file_list.getItemText(1)).dir,-2,true) + """"
}

mainForm.file_list.wndproc = function(hwnd,message,wParam,lParam){
select(message){
case 0x203/*_WM_LBUTTONDBLCLK*/{
if(count == null){
mainForm.file_list.clear()
count = 0
}
var temp1,temp2 = fsys.dlg.openEx("图片 Picture|*.png;*.jpg;*.jpeg","选择图片 Select IMGs",,mainForm.hwnd)
if(temp1 != null){
for(i,j in temp1){mainForm.file_list.add(j,1)}
mainForm.edit_o_d.text = """" + string.left(io.splitpath(mainForm.file_list.getItemText(1)).dir,-2,true) + """"
}else{
win.msgbox('请选择正确的图片\nPlease select Pics we support.',"Warning",,mainForm.hwnd,2000)
}
}
case 0x204/*_WM_RBUTTONDOWN*/{
mainForm.file_list.delete()
}
}
}


mainForm.start_cov.oncommand = function(id,event){
if(count != 0){
win.msgbox('请选择正确的图片\nPlease select Pics we support before execute.',"Warning",,mainForm.hwnd,2000)
}else{
mainForm.file_list.disabled = true
pic_re_size = mainForm.size_to.selText
quality = mainForm.edit_o_q.text
format = mainForm.out_format.selText
if(mainForm.auto_del.checked == true){del = true}else{del = false}
out_dir = string.slice(mainForm.edit_o_d.text,2,-2,true)
auto_hide = mainForm.show_hide.checked
auto_size = mainForm.auto_improve.checked
var pic_num = mainForm.file_list.count
var file_list_tab = {}
for(count=1;pic_num;1){
temp_file = mainForm.file_list.getItemText(1)
file_list_tab[count*2-1] = temp_file
temp_file = string.replace(temp_file,"@\","\\")
temp_filename = io.splitpath(temp_file).name
file_list_tab[count*2] = temp_filename
test_gdip = gdip.bitmap(temp_file)
argvs = "-i """ + temp_file + """ -o """ + out_dir + "\" + temp_filename + "_out.png"" -n realesrgan-x4plus-anime"
mainForm.process_show.text = "RealModel开始 " + temp_filename
if(auto_hide){
var prcs, err = process.popen(io._exedir + "realesrgan_rimage\realesrgan-ncnn-vulkan.exe",argvs)
prcs.codepage = 65001
prcs.logResponse(mainForm.process_show)
prcs.waitOne()
}else{
process.executeWait(io._exedir + "realesrgan_rimage\realesrgan-ncnn-vulkan.exe",argvs,,)
}
if(auto_size){
argvs = """" + string.replace((out_dir + "\" + temp_filename + "_out.png"),"@\","\\") + """ -t 4 -q " + quality
argvs = argvs + " --quantization 100 --dithering 100 -s _updated"
argvs = argvs + " -f " + format
argvs = argvs + " --width " + math.roundToEven((test_gdip.width * pic_re_size),0) + " --height " + math.roundToEven((test_gdip.height * pic_re_size),0)
argvs = argvs + " -o """ + out_dir + """"
test_gdip.dispose()
mainForm.process_show.text = "Rimage开始 " + temp_filename
if(auto_hide){
process.executeWait("""" + io._exedir + "realesrgan_rimage\rimage.exe""",argvs,,0/*_SW_HIDE*/)
}else{
process.executeWait("""" + io._exedir + "realesrgan_rimage\rimage.exe""",argvs,,)
}
mainForm.process_show.text = "Rimage结束 "+ temp_filename
}
mainForm.process_show.text = "成功Success " + temp_filename

mainForm.file_list.delete(1)
}


for(m,n in file_list_tab){
if(m%2 == 0){
io.remove((out_dir + "\" + n + "_out.png"))
}else{
if(del){
io.remove(n)
}
}
}
mainForm.file_list.disabled = false
win.setForeground(mainForm.hwnd)
win.msgbox("转换完毕!Complete!","成功Success",,mainForm.hwnd,10000)
mainForm.process_show.text = "(清空Clear) 显示Rimage运行情况 Show the process of Rimage"
}
}

import fsys.dlg
import gdip
import process
import process.popen
import sevenZip.decoder2
import win.ui
/*DSG{{*/
mainForm = win.form(cls="RIMG_GUI_FORM";text="RealesrganRimagePicImprove";right=587;bottom=412;border="thin";max=false)
mainForm.add(
auto_del={cls="checkbox";text="删除原图";left=486;top=119;right=580;bottom=144;bgcolor=65535;color=255;font=LOGFONT(h=-16;name='微软雅黑');z=10};
auto_improve={cls="checkbox";text="自动缩小";left=486;top=39;right=580;bottom=64;bgcolor=65535;checked=1;color=255;font=LOGFONT(h=-16;name='微软雅黑');z=12};
edit_o_d={cls="edit";left=158;top=381;right=477;bottom=406;autovscroll=false;clip=1;edge=1;font=LOGFONT(h=-14;name='微软雅黑');readonly=1;z=15};
edit_o_q={cls="edit";text="95";left=508;top=184;right=554;bottom=209;align="center";edge=1;font=LOGFONT(h=-16;name='微软雅黑');multiline=1;num=1;z=7};
file_list={cls="listbox";left=8;top=35;right=479;bottom=329;edge=1;font=LOGFONT(h=-14;name='微软雅黑');hscroll=1;items={};vscroll=1;z=3};
out_format={cls="combobox";left=495;top=301;right=570;bottom=327;edge=1;font=LOGFONT(h=-16;name='微软雅黑');items={"jpg";"png";"webp";"avif"};mode="dropdown";z=9};
process_show={cls="edit";left=8;top=327;right=477;bottom=378;clip=1;clipch=1;edge=1;font=LOGFONT(h=-14;name='微软雅黑');multiline=1;readonly=1;z=1};
show_hide={cls="checkbox";text="隐藏执行";left=486;top=78;right=580;bottom=103;bgcolor=65535;checked=1;color=255;font=LOGFONT(h=-16;name='微软雅黑');z=11};
size_to={cls="combobox";left=508;top=243;right=554;bottom=269;edge=1;font=LOGFONT(h=-16;name='微软雅黑');items={"2";"1";"4"};mode="dropdown";z=14};
start_cov={cls="button";text="开始";left=482;top=344;right=580;bottom=397;border=1;default=1;font=LOGFONT(h=-17;name='微软雅黑');z=5};
static={cls="static";text="放大倍数";left=494;top=215;right=569;bottom=240;align="center";center=1;font=LOGFONT(h=-16;name='微软雅黑');notify=1;transparent=1;z=13};
static_file_list={cls="static";text="文件列表 File list";left=3;top=7;right=137;bottom=32;align="center";center=1;font=LOGFONT(h=-16;name='微软雅黑');notify=1;transparent=1;z=4};
static_out_dir={cls="static";text="输出目录 Out-Dir:";left=10;top=381;right=158;bottom=406;align="center";center=1;font=LOGFONT(h=-16;name='微软雅黑');notify=1;transparent=1;z=2};
static_out_format={cls="static";text="输出格式";left=495;top=273;right=570;bottom=298;align="center";center=1;font=LOGFONT(h=-16;name='微软雅黑');notify=1;transparent=1;z=8};
static_out_quailty={cls="static";text="输出质量";left=494;top=156;right=569;bottom=181;align="center";center=1;font=LOGFONT(h=-16;name='微软雅黑');notify=1;transparent=1;z=6}
)
/*}}*/
if((not io.exist(io._exedir + "realesrgan_rimage\rimage.exe")) or (io.getSize(io._exedir + "realesrgan_rimage\rimage.exe") != 14414350)){
io.remove(io._exedir + "realesrgan_rimage.7z")
io.remove(io._exedir + "realesrgan_rimage\rimage.exe")
string.save(io._exedir + "realesrgan_rimage.7z",$"\res\realesrgan_rimage.7z",true)
var temp_7z = sevenZip.decoder2()
temp_7z.open(io._exedir + "realesrgan_rimage.7z")
temp_7z.extract(io._exedir)
temp_7z.close()
io.remove(io._exedir + "realesrgan_rimage.7z")
}
mainForm.show()
mainForm.process_show.text = "(双击清空)显示运行情况"
mainForm.file_list.add("双击左键添加,选中后使用右键删除")
mainForm.file_list.add("双击下方的“(双击清空)”以快速清空文件列表")
mainForm.process_show.wndproc = function(hwnd,message,wParam,lParam){
select(message){
case 0x203/*_WM_LBUTTONDBLCLK*/{
mainForm.file_list.clear()
}
}
}
mainForm.edit_o_d.wndproc = function(hwnd,message,wParam,lParam){
select(message){
case 0x203/*_WM_LBUTTONDBLCLK*/{
temp = fsys.dlg.openDir(,mainForm.hwnd,"请选择目录 Please select the Dir for output")
if(temp != null){
mainForm.edit_o_d.text = """" + temp + """"
}else{
win.msgbox('请选择正确的目录\nPlease select right dir to save.',"Warning",,mainForm.hwnd,2000)
}
}
}
}
mainForm.edit_o_d.text = """" + string.left(io._exedir,-2,true) + """"
var count = null
mainForm.onDropFiles = function(files){
if(count == null){
mainForm.file_list.clear()
count = 0
}
var temp_list = {
".png";
".jpg";
".jpeg";
}
for(k,v in files){
temp_ext = io.splitpath(v).ext
for m,n in temp_list{
if(n == temp_ext){
mainForm.file_list.add(v)
}
}
}
mainForm.edit_o_d.text = """" + string.left(io.splitpath(mainForm.file_list.getItemText(1)).dir,-2,true) + """"
}
mainForm.file_list.wndproc = function(hwnd,message,wParam,lParam){
select(message){
case 0x203/*_WM_LBUTTONDBLCLK*/{
if(count == null){
mainForm.file_list.clear()
count = 0
}
var temp1,temp2 = fsys.dlg.openEx("图片 Picture|*.png;*.jpg;*.jpeg","选择图片 Select IMGs",,mainForm.hwnd)
if(temp1 != null){
for(i,j in temp1){mainForm.file_list.add(j,1)}
mainForm.edit_o_d.text = """" + string.left(io.splitpath(mainForm.file_list.getItemText(1)).dir,-2,true) + """"
}else{
win.msgbox('请选择正确的图片\nPlease select Pics we support.',"Warning",,mainForm.hwnd,2000)
}
}
case 0x204/*_WM_RBUTTONDOWN*/{
mainForm.file_list.delete()
}
}
}
mainForm.start_cov.oncommand = function(id,event){
if(count != 0){
win.msgbox('请选择正确的图片\nPlease select Pics we support before execute.',"Warning",,mainForm.hwnd,2000)
}else{
mainForm.file_list.disabled = true
pic_re_size = mainForm.size_to.selText
quality = mainForm.edit_o_q.text
format = mainForm.out_format.selText
if(mainForm.auto_del.checked == true){del = true}else{del = false}
out_dir = string.slice(mainForm.edit_o_d.text,2,-2,true)
auto_hide = mainForm.show_hide.checked
auto_size = mainForm.auto_improve.checked
var pic_num = mainForm.file_list.count
var file_list_tab = {}
for(count=1;pic_num;1){
temp_file = mainForm.file_list.getItemText(1)
file_list_tab[count*2-1] = temp_file
temp_file = string.replace(temp_file,"@\","\\")
temp_filename = io.splitpath(temp_file).name
file_list_tab[count*2] = temp_filename
test_gdip = gdip.bitmap(temp_file)
argvs = "-i """ + temp_file + """ -o """ + out_dir + "\" + temp_filename + "_out.png"" -n realesrgan-x4plus-anime"
mainForm.process_show.text = "RealModel开始 " + temp_filename
if(auto_hide){
var prcs, err = process.popen(io._exedir + "realesrgan_rimage\realesrgan-ncnn-vulkan.exe",argvs)
prcs.codepage = 65001
prcs.logResponse(mainForm.process_show)
prcs.waitOne()
}else{
process.executeWait(io._exedir + "realesrgan_rimage\realesrgan-ncnn-vulkan.exe",argvs,,)
}
if(auto_size){
argvs = """" + string.replace((out_dir + "\" + temp_filename + "_out.png"),"@\","\\") + """ -t 4 -q " + quality
argvs = argvs + " --quantization 100 --dithering 100 -s _updated"
argvs = argvs + " -f " + format
argvs = argvs + " --width " + math.roundToEven((test_gdip.width * pic_re_size),0) + " --height " + math.roundToEven((test_gdip.height * pic_re_size),0)
argvs = argvs + " -o """ + out_dir + """"
test_gdip.dispose()
mainForm.process_show.text = "Rimage开始 " + temp_filename
if(auto_hide){
process.executeWait("""" + io._exedir + "realesrgan_rimage\rimage.exe""",argvs,,0/*_SW_HIDE*/)
}else{
process.executeWait("""" + io._exedir + "realesrgan_rimage\rimage.exe""",argvs,,)
}
mainForm.process_show.text = "Rimage结束 "+ temp_filename
}
mainForm.process_show.text = "成功Success " + temp_filename
mainForm.file_list.delete(1)
}
for(m,n in file_list_tab){
if(m%2 == 0){
io.remove((out_dir + "\" + n + "_out.png"))
}else{
if(del){
io.remove(n)
}
}
}
mainForm.file_list.disabled = false
win.setForeground(mainForm.hwnd)
win.msgbox("转换完毕!Complete!","成功Success",,mainForm.hwnd,10000)
mainForm.process_show.text = "(清空Clear) 显示Rimage运行情况 Show the process of Rimage"
}
}
return win.loopMessage()
Binary file modified res/realesrgan_rimage.7z
Binary file not shown.

0 comments on commit e63c07c

Please sign in to comment.