fix lots of GUI bugs + styling a lil

This commit is contained in:
2023-06-09 17:03:25 +02:00
parent 73661fae19
commit c01948dc3f
11 changed files with 63 additions and 13 deletions

View File

@@ -23,6 +23,7 @@ class Scaler:
os.system( self.command ) os.system( self.command )
print( '\n\n==>Photo upscaled' ); print( '\n\n==>Photo upscaled' );
return True;
def videoScaler ( self, tmppath, threads, scalefactor, sharpening, filetype, mode ): def videoScaler ( self, tmppath, threads, scalefactor, sharpening, filetype, mode ):
modes = { 'av3':'realesr-animevideov3', 'x4plus': 'realesrgan-x4plus-anime' } modes = { 'av3':'realesr-animevideov3', 'x4plus': 'realesrgan-x4plus-anime' }

View File

@@ -86,10 +86,10 @@ class Handler:
# Determining filetype # Determining filetype
if str(filepath)[len(filepath) - 4:] == '.mp4' or str(filepath)[len(filepath) - 4:] == '.mkv' or str(filepath)[len(filepath) - 4:] == '.MP4': if str(filepath)[len(filepath) - 4:] == '.mp4' or str(filepath)[len(filepath) - 4:] == '.mkv' or str(filepath)[len(filepath) - 4:] == '.MP4':
print( '\n\n==> Upscaling video' ) print( '\n\n==> Upscaling video' )
self.video_scaling( filepath, output_path, scalefactor, threads, sharpening, filetype, mode, engine ) return self.video_scaling( filepath, output_path, scalefactor, threads, sharpening, filetype, mode, engine )
elif str(filepath)[len(filepath) - 4:] == '.JPG' or str(filepath)[len(filepath) - 4:] == '.png' or str(filepath)[len(filepath) - 4:] == '.jpg' or str(filepath)[len(filepath) - 5:] == '.jpeg': elif str(filepath)[len(filepath) - 4:] == '.JPG' or str(filepath)[len(filepath) - 4:] == '.png' or str(filepath)[len(filepath) - 4:] == '.jpg' or str(filepath)[len(filepath) - 5:] == '.jpeg':
print( '\n==> Upscaling Image' ) print( '\n==> Upscaling Image' )
self.photo_scaling( filepath, output_path, scalefactor, sharpening, threads, engine, mode ) return self.photo_scaling( filepath, output_path, scalefactor, sharpening, threads, engine, mode )
else: else:
print('not supported') print('not supported')
return False return False

View File

@@ -1,8 +1,9 @@
<template> <template>
<nav> <nav>
<router-link to="/">Home</router-link> | <router-link to="/">Home</router-link> |
<router-link to="/about">About</router-link> | <router-link to="/about">About</router-link>
<router-link to="/settings">Settings</router-link> <!-- |
<router-link to="/settings">Settings</router-link> -->
</nav> </nav>
<router-view v-slot="{ Component, route }"> <router-view v-slot="{ Component, route }">
<transition :name="route.meta.transition || 'scale'" mode="out-in"> <transition :name="route.meta.transition || 'scale'" mode="out-in">

BIN
frontend/src/assets/logo.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

After

Width:  |  Height:  |  Size: 592 KiB

View File

@@ -32,16 +32,26 @@ class UpscalingHandler {
let args = [] let args = []
args.push( '-i' + options.InputFile ); args.push( '-i' + options.InputFile );
args.push( '-o ' + options.OutputFile ); args.push( '-o' + options.OutputFile );
args.push( '-s ' + options.scale ) if ( options.scale != 0 ) {
args.push( '-s' + options.scale );
}
if ( options.sharpening != 0 ) {
args.push( '-S' + options.sharpening );
}
args.push( '-M' + options.algorithm );
args.push( '-E' + options.engine );
// add additional options // add additional options
// baseCommand += + ' -S ' + options.sharpening // baseCommand += + ' -S ' + options.sharpening
// baseCommand += ' -E ' + options.engine + ' -M ' + options.algorithm // baseCommand += ' -E ' + options.engine + ' -M ' + options.algorithm
console.log( 'upscaling' ); console.log( 'upscaling' );
console.log( args );
let child = child_process.spawn( baseCommand, args ); let child = child_process.spawn( baseCommand, args );
child.stdout.on( 'data', data => { child.stdout.on( 'data', data => {

View File

@@ -1,6 +1,6 @@
<template> <template>
<div class="about"> <div class="about">
<img src="@/assets/logo.png"> <img src="@/assets/logo.png" style="height: 30vh;">
<h1>About SimpleMediaUpscalerLite</h1> <h1>About SimpleMediaUpscalerLite</h1>
<p>SimpleMediaUpscalerLite is an application that allows you to upscale your videos and / or images. It uses an Electron GUI (Graphical User Interface) and a Python CLI (Command Line Interface).</p> <p>SimpleMediaUpscalerLite is an application that allows you to upscale your videos and / or images. It uses an Electron GUI (Graphical User Interface) and a Python CLI (Command Line Interface).</p>
<div class="version-info"> <div class="version-info">

View File

@@ -34,9 +34,21 @@
<tr id="group3" class="group"> <tr id="group3" class="group">
<td> <td>
<button @click="runCommand( 'InputFile' )">Input file</button><br> <button @click="runCommand( 'InputFile' )">Input file</button><br>
<div v-if="upscaleSettings.InputFile[ 0 ]" id="inputCheck" @mouseenter="showElement( 'inputfile' )" @mouseleave="hideElement( 'inputfile' )">&#10004;</div>
<div class="info-container">
<div class="info" id="inputfile">
{{ upscaleSettings.InputFile[ 0 ] }}
</div>
</div>
</td> </td>
<td> <td>
<button @click="runCommand( 'OutputFile' )">Output file</button><br> <button @click="runCommand( 'OutputFile' )">Output file</button><br>
<div v-if="upscaleSettings.OutputFile" id="outputCheck" @mouseenter="showElement( 'outputfile' )" @mouseleave="hideElement( 'outputfile' )">&#10004;</div>
<div class="info-container">
<div class="info" id="outputfile">
{{ upscaleSettings.OutputFile }}
</div>
</div>
</td> </td>
</tr> </tr>
</table> </table>
@@ -176,12 +188,35 @@ export default {
let fileExtension = this.upscaleSettings.InputFile[ 0 ].substring( this.upscaleSettings.InputFile[ 0 ].length - 4 ); let fileExtension = this.upscaleSettings.InputFile[ 0 ].substring( this.upscaleSettings.InputFile[ 0 ].length - 4 );
this.upscaleSettings.OutputFile = this.upscaleSettings.OutputFile.slice( 0, this.upscaleSettings.OutputFile[ 0 ].length - 5 ) + fileExtension; this.upscaleSettings.OutputFile = this.upscaleSettings.OutputFile.slice( 0, this.upscaleSettings.OutputFile[ 0 ].length - 5 ) + fileExtension;
this.fixed = true; this.fixed = true;
},
showElement( element ) {
document.getElementById( element ).classList.add( 'shown' );
},
hideElement( element ) {
document.getElementById( element ).classList.remove( 'shown' );
} }
}, },
} }
</script> </script>
<style scoped> <style scoped>
.info-container {
position: relative;
}
.info {
display: none;
position: absolute;
background-color: var( --dialog-color );
padding: 2vw;
width: 20vw;
height: 20vh;
word-wrap: break-word;
}
.shown {
display: block;
}
.table-container { .table-container {
width: 100%; width: 100%;
display: flex; display: flex;
@@ -198,6 +233,7 @@ export default {
margin-top: 5vh; margin-top: 5vh;
padding: 1vw 2vw; padding: 1vw 2vw;
margin-bottom: 0; margin-bottom: 0;
cursor: pointer;
} }
button { button {

View File

@@ -1,9 +1,7 @@
<template> <template>
<div class="about"> <div class="about">
<h1>Settings</h1> <h1>Settings</h1>
<h3>Engines</h3>
<p>WIP!</p> <p>WIP!</p>
<p>{{ engines }}</p>
</div> </div>
</template> </template>

BIN
logo_upscaled.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 MiB

View File

@@ -42,7 +42,7 @@ def performChecks ( args, ap ):
output = args.inputfile[ :len( args.inputfile ) - 4 ] + '_upscaled' + args.inputfile[ len( args.inputfile ) - 4: ] output = args.inputfile[ :len( args.inputfile ) - 4 ] + '_upscaled' + args.inputfile[ len( args.inputfile ) - 4: ]
# check if output file exists and if, prompt user if it should be overwritten and remove if, if yes # check if output file exists and if, prompt user if it should be overwritten and remove if, if yes
if ( os.path.exists( output ) ): if ( os.path.exists( output ) and ( args.overwrite == None or args.overwrite == '' ) ):
doReplace = input( '--> File already exists. Do you want to replace it? (Y/n) ' ).lower() doReplace = input( '--> File already exists. Do you want to replace it? (Y/n) ' ).lower()
if ( doReplace == 'y' or doReplace == '' ): if ( doReplace == 'y' or doReplace == '' ):
os.remove( output ); os.remove( output );
@@ -54,7 +54,7 @@ def performChecks ( args, ap ):
try: try:
engineInfo[ args.engine.lower() ] engineInfo[ args.engine.lower() ]
except KeyError: except KeyError:
print( '\n==> ERROR: Engine not available. Ensure you have specified a valid engine. Possible engines: ' ) print( '\n==> ERROR: Engine ' + args.engine.lower() + ' not available. Ensure you have specified a valid engine. Possible engines: ' )
for entry in engineList: for entry in engineList:
print( ' --> ' + entry ) print( ' --> ' + entry )
return False return False
@@ -72,7 +72,7 @@ def performChecks ( args, ap ):
# Check sharpening argument and also verify that engine supports it # Check sharpening argument and also verify that engine supports it
if ( args.sharpening != None and args.sharpening != 0 ): if ( args.sharpening != None and args.sharpening != 0 ):
if ( float( args.sharpening ) >= 1.0 or float( args.sharpening ) <= 0.0 ): if ( float( args.sharpening ) >= 1.0 or float( args.sharpening ) <= 0.0 ):
print( '\n==> ERROR: Invalid value for sharpening. Value has to be between 0 and 1' ) print( '\n==> ERROR: Invalid value (' + args.sharpening + ') for sharpening. Value has to be between 0 and 1' )
return False return False
else: else:
if ( not 'sharpening' in engineInfo[ args.engine ][ 'supports' ] ): if ( not 'sharpening' in engineInfo[ args.engine ][ 'supports' ] ):
@@ -133,6 +133,7 @@ if __name__ == '__main__':
ap.add_argument( '-M', '--mode', help='Specify a special mode for a specific engine. Might not be available in every engine. Use the -d option to find out more' ) ap.add_argument( '-M', '--mode', help='Specify a special mode for a specific engine. Might not be available in every engine. Use the -d option to find out more' )
ap.add_argument( '-F', '--filetype', help='Change the file type of the temporary image files. Supports png, jpg. Video quality: png > jpg. PNG is default, if not specified.' ) ap.add_argument( '-F', '--filetype', help='Change the file type of the temporary image files. Supports png, jpg. Video quality: png > jpg. PNG is default, if not specified.' )
ap.add_argument( '-d', '--details', help='Get details on usage of a particular engine and exit. Reads the config.json file of that engine and displays it in a HR manner' ) ap.add_argument( '-d', '--details', help='Get details on usage of a particular engine and exit. Reads the config.json file of that engine and displays it in a HR manner' )
ap.add_argument( '-y', '--overwrite', help='Always overwrite output path and do not ask', action='store_true' )
ap.add_argument( '-p', '--printengines', help='Print all engines and exit', action='store_true' ) ap.add_argument( '-p', '--printengines', help='Print all engines and exit', action='store_true' )
ap.add_argument( '-v', '--version', help='Print version and exit', action='store_true' ) ap.add_argument( '-v', '--version', help='Print version and exit', action='store_true' )
ap.set_defaults( scalefactor = 0, sharpening = 0, threads = 4, engine = 'ffc', filetype = 'png' ) ap.set_defaults( scalefactor = 0, sharpening = 0, threads = 4, engine = 'ffc', filetype = 'png' )
@@ -155,5 +156,8 @@ if __name__ == '__main__':
if ( engineInfo[ args.engine ][ 'cliModeOptions' ][ option ][ 'default' ] ): if ( engineInfo[ args.engine ][ 'cliModeOptions' ][ option ][ 'default' ] ):
mode = option mode = option
break break
if ( handler.handler( args.inputfile, args.scalefactor, output, args.sharpening, args.filetype, args.engine, mode, args.threads ) ): if ( handler.handler( args.inputfile, args.scalefactor, output, args.sharpening, args.filetype, args.engine, mode, args.threads ) ):
print( '\n\n---------------------------------------------------------------------------------\n\nDONE \n\n\n\nSimpleMediaUpscalerLite V1.1.0\n\nCopyright 2023 SimpleMediaUpscalerLite contributors\nThis application comes with absolutely no warranty to the extent permitted by applicable law\n\n\n\nOutput was written to ' + output + '\n\n\n' ) print( '\n\n---------------------------------------------------------------------------------\n\nDONE \n\n\n\nSimpleMediaUpscalerLite V1.1.0\n\nCopyright 2023 SimpleMediaUpscalerLite contributors\nThis application comes with absolutely no warranty to the extent permitted by applicable law\n\n\n\nOutput was written to ' + output + '\n\n\n' )
else:
raise Exception( 'ERRORS in arguments' );