Skip to content

Commit

Permalink
[Pipe RGB to ImageMagick] Remember the last used output format
Browse files Browse the repository at this point in the history
Also use by default the last directory used for images instead of the one
used for scripts.
  • Loading branch information
vdcrim committed Nov 7, 2012
1 parent 3f960f0 commit 2570ab4
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions Pipe RGB to ImageMagick.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@
3) place it on the 'AvsPmod\tools' directory
Date: 2012-11-04
Date: 2012-11-07
Latest version: https://github.com/vdcrim/avsp-macros
Changelog:
- initial release
- remember the last used output format
Copyright (C) 2012 Diego Fernández Gosende <[email protected]>
Expand Down Expand Up @@ -198,6 +198,7 @@ def __del__(self):
im_args = avsp.Options.get('im_args', '')
use_dir = avsp.Options.get('use_dir', False)
use_base = avsp.Options.get('use_base', False)
last_ext = avsp.Options.get('last_ext', '.png')
add_frame_number = avsp.Options.get('add_frame_number', True)
show_progress = avsp.Options.get('show_progress', True)

Expand Down Expand Up @@ -243,19 +244,19 @@ def __del__(self):
if output_path:
dirname, basename = os.path.split(output_path)
elif self.version > '2.3.1':
dirname, basename = os.path.split(avsp.GetScriptFilename(propose='general'))
dirname, basename = os.path.split(avsp.GetScriptFilename(propose='image'))
else:
dirname, basename = (self.options['recentdir'], self.scriptNotebook.GetPageText(
dirname, basename = (self.options['imagesavedir'], self.scriptNotebook.GetPageText(
self.scriptNotebook.GetSelection()).lstrip('* '))
if use_dir:
dirname = avsp.Options.get('dirname', '')
if use_base:
basename = avsp.Options.get('basename', '')
basename2, ext = os.path.splitext(basename)
if ext in ('.avs', '.avsi'):
basename = basename2 + '.png'
elif not ext:
basename = basename + '.png'
basename = basename2 + last_ext
else:
basename = basename + last_ext
output_path = os.path.join(dirname, basename)

# Ask for options
Expand Down Expand Up @@ -293,6 +294,7 @@ def __del__(self):
return

# Save default options
output_path, ext = os.path.splitext(output_path)
avsp.Options['convert_path'] = convert_path
avsp.Options['election'] = election
avsp.Options['frame_step'] = frame_step
Expand All @@ -305,6 +307,7 @@ def __del__(self):
avsp.Options['dirname'] = os.path.dirname(output_path)
if use_base:
avsp.Options['basename'] = os.path.basename(output_path)
avsp.Options['last_ext'] = ext
avsp.Options['add_frame_number'] = add_frame_number
avsp.Options['show_progress'] = show_progress

Expand Down Expand Up @@ -352,7 +355,6 @@ def __del__(self):
# http://bugs.python.org/issue3905
# http://bugs.python.org/issue1124861
encoding = sys.getfilesystemencoding()
output_path, ext = os.path.splitext(output_path)
if add_frame_number:
digits = len(str(frame_list[-1] - 1))
suffix = '-%0{0}d'.format(digits)
Expand Down

0 comments on commit 2570ab4

Please sign in to comment.