summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/scripts/bitmap2eps
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2013-04-07 18:42:53 +0000
committerKarl Berry <karl@freefriends.org>2013-04-07 18:42:53 +0000
commitedb2136c619d2c59bcb6dfd431c4c7636ff8913d (patch)
tree8aa04dd27bee1b2f2f9b3fd45dab41cf7771f82e /Master/texmf-dist/scripts/bitmap2eps
parentb3efa3bb4509e7bd53d737fb729d0d92a76f1f98 (diff)
texmf -> texmf-dist: scripts
git-svn-id: svn://tug.org/texlive/trunk@29719 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/scripts/bitmap2eps')
-rw-r--r--Master/texmf-dist/scripts/bitmap2eps/bitmap2eps.vbs108
1 files changed, 108 insertions, 0 deletions
diff --git a/Master/texmf-dist/scripts/bitmap2eps/bitmap2eps.vbs b/Master/texmf-dist/scripts/bitmap2eps/bitmap2eps.vbs
new file mode 100644
index 00000000000..fbfc850e851
--- /dev/null
+++ b/Master/texmf-dist/scripts/bitmap2eps/bitmap2eps.vbs
@@ -0,0 +1,108 @@
+option explicit
+On Error Resume next
+
+dim oWsh, oArgs, oFS, oDia, oTS, infile, outfile, f, c, result
+
+set oWsh = createobject( "wscript.Shell" )
+Set oFS = CreateObject("Scripting.FileSystemObject")
+Set oArgs = wscript.arguments
+
+' assume sam2p and bmeps on searchpath
+If oArgs.count = 0 Then
+ ' This appears to fail on win7: 'No file to convert' messagebox
+ Set oDia = CreateObject("UserAccounts.CommonDialog")
+ 'oDia.InitialDir = oWsh.SpecialFolders("MyDocuments")
+ oDia.filter = _
+ "Bitmaps|*.bmp;*.png;*.gif;*.bmp;*.jpg;*.jpeg;*.tif;*.tiff|All files|*.*"
+ oDia.filterindex = 1
+ oDia.flags = 1
+ If oDia.ShowOpen = False then
+ msgBox "No file to convert"
+ wscript.quit
+ End If
+ infile = oDia.filename
+ ' MsgBox "infile: " & infile
+Else
+ ' may have to flip slashes if the file was on a network drive !!!
+ infile = replace(oArgs(0), "/", "\")
+ infile = ofs.getabsolutepathname(infile)
+End If
+
+' name of output file
+outfile = ofs.buildpath(ofs.getparentfoldername(infile), _
+ ofs.getbasename(infile) & ".eps")
+
+If ofs.fileexists(outfile) Then
+ result = MsgBox(outfile & vbcrlf & "exists; overwrite?", _
+ vbyesno+vbquestion)
+ If result <> vbyes Then
+ wscript.quit
+ Else
+ oFS.deletefile(outfile)
+ Err.clear
+ If ofs.fileexists(outfile) Then
+ MsgBox "Unable to remove old " & outfile, vbcritical
+ wscript.quit
+ End If
+ End If
+End If
+
+' MsgBox "trying sam2p"
+owsh.run "sam2p """ & infile & """ EPS: """ & outfile & """", 0
+If Err Then
+ ' This is a failure of this script to start sam2p,
+ ' not just a failure of sam2p to do its job
+ MsgBox "Unspecified failure", vbcritical
+ wscript.quit
+End If
+wscript.sleep(1000)
+
+If ofs.fileexists(outfile) Then
+ MsgBox ofs.getbasename(infile) & "." & ofs.getextensionname(infile) & _
+ " successfully converted", vbInformation
+Else
+ Err.clear
+ ' clear sam2p temp files
+ For Each f in ofs.getfolder(ofs.getparentfoldername(infile)).files
+ If InStr(f.Name, "tmp__sam2p") = 1 Then
+ f.delete
+ Err.clear
+ End If
+ Next
+ ' MsgBox "trying bmeps"
+ owsh.run "bmeps -c """ & infile & """ """ & outfile & """", 0
+ If Err Then
+ MsgBox "Unspecified failure", vbcritical
+ wscript.quit
+ End If
+ wscript.sleep(1000)
+ If ofs.fileexists(outfile) Then
+ result = True
+ ' check the eps file; it may contain just an error mesage from bmeps
+ Set oTS = ofs.opentextfile (outfile, 1)
+ If Err Then
+ result = False
+ Err.clear
+ Else
+ c = oTS.read(2)
+ If Err Then
+ result = false
+ Err.clear
+ Else
+ If c <> "%!" Then
+ result = False
+ End If
+ End If
+ oTS.close
+ End If
+ If result then
+ MsgBox ofs.getbasename(infile) & "." & ofs.getextensionname(infile) & _
+ " successfully converted with bmeps", vbInformation
+ Else
+ 'ofs.deletefile(outfile)
+ MsgBox "Conversion failed", vbCritical
+ End If
+ Else
+ MsgBox "Conversion failed", vbCritical
+ End If
+End If