Image Converter — File Browser

ImageConverterv1.0 / ImageConverterv1.0 / Converter / Convert.mrc

Convert.mrc — 3.45 KB — Download this file

;Image Converter
;Written by [AFX]
;www.merkFXscript.tk

;This small utility uses nacitars' nScreenShot.dll to convert the pictures. Without him, this utility 
;wouldn't be here. I like using this tool because like myself, some people might not have anything
;to convert their images/screenshots with.

alias convert { $iif(!$dialog(convert),dialog -m convert convert,dialog -v convert) }
alias nscreenshot { dll $shortfn($scriptdirnscreenshot.dll) $$1- }

alias open.pic {
  if ($1-) {
    var %n = $did(convert,3).text, %n2 = $shortfn(%n)
    window -dphB $iif($1- != -t,+d) @picture: $+ $replace($nopath(%n),$chr(32),$chr(160)) 0 0 $iif($1- == -t,$calc($pic(%n2).width + 6),$pic(%n2).width) $iif($1- == -t,$calc($pic(%n2).height + 26),$pic(%n2).height)
    drawpic @picture: $+ $replace($nopath(%n),$chr(32),$chr(160)) 0 0 0 0 $pic(%n2).width $pic(%n2).height %n2
    window -a @picture: $+ $replace($nopath(%n),$chr(32),$chr(160))
  }
}

menu @picture:* {
  mouse:mouse.drag
  sclick:{
    %mouse.x = $mouse.x
    %mouse.y = $mouse.y
    %mouse.stat = 1
  }
  drop:unset %mouse.*
  leave:{
    if ($mouse.key == 1) { mouse.drag }
    elseif (%mouse.stat) { unset %mouse.* }
  }
  close window { close -@ $window($active) }
}

alias mouse.drag { if (%mouse.stat) { window -a $window($active) $calc($window($window($active)).x + $mouse.x - %mouse.x) $calc($window($window($active)).y + $mouse.y - %mouse.y) } }

dialog convert {
  title "Image Converter [/convert]"
  size -1 -1 160 105
  option dbu
  tab "General", 1, 1 3 157 82
  text "File to convert:", 2, 4 25 38 8, tab 1
  edit "", 3, 46 24 110 10, tab 1 autohs
  text "Save to:", 4, 4 37 25 8, tab 1
  text "Convert to:", 6, 4 54 30 8, tab 1
  combo 7, 96 53 60 50, tab 1 size drop
  button "View image", 8, 119 71 37 12, tab 1
  button "Select file...", 9, 4 71 37 12, tab 1
  button "&Done", 11, 122 91 37 12, tab 1 ok
  edit "", 5, 46 36 110 10, read autohs
  button "Set save dir", 10, 44 71 37 12
  button "Convert!", 12, 78 91 37 12
}

on *:dialog:convert:init:0: {
  mdx MarkDialog $dname 
  mdx SetFont $dname 2,3,4,5,6,7,8,9,10,11,12 -11 400 Tahoma
  mdx SetDialog $dname icon
  did -a $dname 7 .PNG
  did -a $dname 7 .JPG
  did -a $dname 7 .BMP
  did -a $dname 7 .TIFF
  did -c $dname 7 1
  did -a $dname 5 %convert_savedir
}

on *:dialog:convert:sclick:8: {
  if ($did($dname,3).text) {
    open.pic $did($dname,3).text
  }
}

on *:dialog:convert:sclick:9: {
  var %s = $sfile(C:,Select an image to convert,Select)
  if (%s) {
    did -ra $dname 3 %s
    did -c $dname 3 1
  }
}

on *:dialog:convert:sclick:10: {
  var %dir = $sdir($iif(%convert_savedir,$ifmatch,C:))
  if (%dir) {
    set %convert_savedir %dir
    did -ra $dname 5 %dir
    did -c $dname 3,1
  }
}

on *:dialog:convert:sclick:12: {
  if ($did($dname,3).text && $did($dname,5).text && $did($dname,7).sel) {
    var %file = $did($dname,3).text
    var %file2 = $nopath($remove(%file,$gettok(%file,-1,46))) $+ $img_type
    var %newfile = %convert_savedir $+ \ $+ %file2
    if (%file && %file2 && %newfile) {
      nscreenshot Convert %file $+ ? $+ %newfile
      if ($isfile(%newfile)) {
        var %ok = $input(Finished converting the image to %newfile $+ ,oi,Completed)
      }
    }
  }
}

alias img_type {
  $iif($did($dname,7).sel = 1,return PNG)
  $iif($did($dname,7).sel = 2,return JPG)
  $iif($did($dname,7).sel = 3,return BMP)
  $iif($did($dname,7).sel = 4,return TIFF)
}