mikeytown2
Active Members-
Posts
211 -
Joined
-
Last visited
About mikeytown2
- Birthday 10/14/1983
Profile Information
-
Location
Seattle, WA
-
WWW
http://forum.doom9.org/member.php?u=75772
Recent Profile Visitors
639 profile views
mikeytown2's Achievements
Polymath (5/7)
4
Reputation
-
Decibel reacted to a post in a topic: GPS Distance Calculations
-
Something I threw together. Uses these exe's http://mozjpeg.codelove.de/binaries.html http://www.sentex.net/~mwandel/jhead/ Will auto rotate the image and keep the original exif data. I use this to compress photos before putting them in email or dropbox. Will use the number of cores your box has for processing the images so it can plow though them fairly quickly. #include <Array.au3> #include <FileConstants.au3> #include <MsgBoxConstants.au3> #include <File.au3> #include <GUIConstantsEx.au3> #include <Crypt.au3> FileInstall('cjpeg.exe', @ScriptDir & '\cjpeg.exe') FileInstall('libjpeg-62.dll', @ScriptDir & '\libjpeg-62.dll') FileInstall('jhead.exe', @ScriptDir & '\jhead.exe') FileInstall('jpegtran.exe', @ScriptDir & '\jpegtran.exe') ;add to array, list of files in a dir Func FileListFromDir($dir, $filetype, ByRef $filelist) ;search for the first file with the correct file extenstion Local $file, $search = FileFindFirstFile($dir & "\" & $filetype) ; Check if the search was successful If $search = -1 Then $searchDIR = FileFindFirstFile($dir & "\*") While 1 $file = FileFindNextFile($searchDIR) If @error Then ExitLoop EndIf If StringInStr(FileGetAttrib($dir & "\" & $file), "D") Then FileListFromDir($dir & "\" & $file, $filetype, $filelist) EndIf WEnd FileClose($searchDIR) ; Close the search handle EndIf ;add found files to array While 1 $file = FileFindNextFile($search) If @error Then ExitLoop EndIf ;Add file to array _ArrayAdd($filelist, $dir & "\" & $file) $filelist[0] += 1 WEnd FileClose($search) ; Close the search handle EndFunc ;==>FileListFromDir ;add from given array to Filelist Func GetListOfFiles() Local $dirbit = 0 Local $filetype = '*.jpg' Local $filelist[1] $filelist[0] = 0 ;Grab EXE Drag-n-Droped files/dir's If $CmdLine[0] > 0 Then For $x = 1 To $CmdLine[0] Step +1 ;run though all files droped and look for dir's If StringInStr(FileGetAttrib($CmdLine[$x]), "D") Then $dirbit += 1 FileListFromDir($CmdLine[$x], $filetype, $filelist) ;parce dir looking for file of that extenstion Else ;add file to list _ArrayAdd($filelist, $CmdLine[$x]) $filelist[0] += 1 EndIf Next EndIf If $filelist[0] <= 0 Then ; Create a constant variable in Local scope of the message to display in FileOpenDialog. Local Const $sMessage = "Hold down Ctrl or Shift to choose multiple files." ; Display an open dialog to select a list of file(s). Local $sFileOpenDialog = FileOpenDialog($sMessage, @WindowsDir & "\", "JPG Files (*.jpg)", $FD_FILEMUSTEXIST + $FD_MULTISELECT) If @error Then ; Display the error message. MsgBox($MB_SYSTEMMODAL, "", "No file(s) were selected.") ; Change the working directory (@WorkingDir) back to the location of the script directory as FileOpenDialog sets it to the last accessed folder. FileChangeDir(@ScriptDir) Else ; Change the working directory (@WorkingDir) back to the location of the script directory as FileOpenDialog sets it to the last accessed folder. FileChangeDir(@ScriptDir) If StringInStr($sFileOpenDialog, '|') Then $templist = StringSplit($sFileOpenDialog, '|') $dir = $templist[1] _ArrayDelete($templist, 1) $templist[0] -= 1 While $templist[0] > 0 $newfile = $dir & '\' & $templist[1] _ArrayDelete($templist, 1) $templist[0] -= 1 _ArrayAdd($filelist, $newfile) $filelist[0] += 1 WEnd Else _ArrayAdd($filelist, $sFileOpenDialog) $filelist[0] += 1 EndIf EndIf EndIf Return $filelist EndFunc ;==>ArrayToFileList Func shrinkjpeg($filename, $pids) ; Get dir and filename info. Local $sDrive = "", $sDir = "", $sFilename = "", $sExtension = "" Local $aPathSplit = _PathSplit($filename, $sDrive, $sDir, $sFilename, $sExtension) Local $sNewDir = $sDrive & $sDir & 'small\' If DirGetSize($sNewDir) == -1 Then DirCreate($sNewDir) EndIf ; Run X number of threads. $cores = EnvGet("NUMBER_OF_PROCESSORS") While $pids[0] > $cores For $x = 1 To $cores Step +1 If _elementExists($pids, $x) And ProcessExists($pids[$x]) == 0 Then _ArrayDelete($pids, $x) $pids[0] -= 1 EndIf Next Sleep(20) WEnd ; Let GUI know what file is being worked on. OutputStatus($sFilename) $newfilename = $sNewDir & $sFilename & '-small.jpg' Local $cmds = '' $cmds &= @ComSpec & ' /c ' ; run mozjpeg. $cmds &= '' & @ScriptDir & '\cjpeg.exe -quality 60,51 -optimize "' & $filename & '" > "' & $newfilename & '"' ; Copy exif data. $cmds &= ' & ' & @ScriptDir & '\jhead.exe -te "' & $filename & '" "' & $newfilename & '"' ; Rotate jpeg. $cmds &= ' & ' & @ScriptDir & '\jhead.exe -autorot "' & $newfilename & '"' ; Run it. Local $iPID = Run($cmds, "", @SW_HIDE) ; Set priority low. ProcessSetPriority($iPID, 0) _ArrayAdd($pids, $iPID) $pids[0] += 1 Return $pids EndFunc Func OutputStatus($sMessage) Local $hWnd = WinGetHandle("") TrayTip('Status:', $sMessage, 30) TraySetToolTip($sMessage) WinActivate($hWnd) EndFunc Func _elementExists($array, $element) If $element > UBound($array)-1 Then Return False ; element is out of the array bounds Return True ; element is in array bounds EndFunc $files = GetListOfFiles() Local $pids[1] $pids[0] = 0 If $files[0] > 0 Then While $files[0] > 0 $pids = shrinkjpeg($files[1], $pids) _ArrayDelete($files, 1) $files[0] -= 1 WEnd $cores = EnvGet("NUMBER_OF_PROCESSORS") If $pids[0] > $cores Then For $x = 1 To $cores Step +1 If _elementExists($pids, $x) Then ProcessWaitClose($pids[$x]) EndIf Next EndIf MsgBox($MB_SYSTEMMODAL, "", "Done") EndIf
-
mLipok reacted to a post in a topic: Base64 Converter
-
Shane0000 reacted to a post in a topic: GPS Distance Calculations
-
avs to m4v script #include <Array.au3> #include <FileConstants.au3> #include <MsgBoxConstants.au3> #include <File.au3> ;add to array, list of files in a dir Func FileListFromDir($dir, $filetype, ByRef $filelist) ;search for the first file with the correct file extenstion Local $file, $search = FileFindFirstFile($dir & "\" & $filetype) ; Check if the search was successful If $search = -1 Then $searchDIR = FileFindFirstFile($dir & "\*") While 1 $file = FileFindNextFile($searchDIR) If @error Then ExitLoop EndIf If StringInStr(FileGetAttrib($dir & "\" & $file), "D") Then FileListFromDir($dir & "\" & $file, $filetype, $filelist) EndIf WEnd FileClose($searchDIR) ; Close the search handle EndIf ;add found files to array While 1 $file = FileFindNextFile($search) If @error Then ExitLoop EndIf ;Add file to array _ArrayAdd($filelist, $dir & "\" & $file) $filelist[0] += 1 WEnd FileClose($search) ; Close the search handle EndFunc ;==>FileListFromDir ;add from given array to Filelist Func GetListOfFiles() Local $dirbit = 0 Local $filetype = '*.avs' Local $filelist[1] $filelist[0] = 0 ;Grab EXE Drag-n-Droped files/dir's If $CmdLine[0] > 0 Then For $x = 1 To $CmdLine[0] Step +1 ;run though all files droped and look for dir's If StringInStr(FileGetAttrib($CmdLine[$x]), "D") Then $dirbit += 1 FileListFromDir($CmdLine[$x], $filetype, $filelist) ;parce dir looking for file of that extenstion Else ;add file to list _ArrayAdd($filelist, $CmdLine[$x]) $filelist[0] += 1 EndIf Next EndIf If $filelist[0] <= 0 Then ; Create a constant variable in Local scope of the message to display in FileOpenDialog. Local Const $sMessage = "Hold down Ctrl or Shift to choose multiple files." ; Display an open dialog to select a list of file(s). Local $sFileOpenDialog = FileOpenDialog($sMessage, @WindowsDir & "\", "AVS Files (*.avs)", $FD_FILEMUSTEXIST + $FD_MULTISELECT) If @error Then ; Display the error message. MsgBox($MB_SYSTEMMODAL, "", "No file(s) were selected.") ; Change the working directory (@WorkingDir) back to the location of the script directory as FileOpenDialog sets it to the last accessed folder. FileChangeDir(@ScriptDir) Else ; Change the working directory (@WorkingDir) back to the location of the script directory as FileOpenDialog sets it to the last accessed folder. FileChangeDir(@ScriptDir) If StringInStr($sFileOpenDialog, '|') Then $templist = StringSplit($sFileOpenDialog, '|') $dir = $templist[1] _ArrayDelete($templist, 1) $templist[0] -= 1 While $templist[0] > 0 $newfile = $dir & '\' & $templist[1] _ArrayDelete($templist, 1) $templist[0] -= 1 _ArrayAdd($filelist, $newfile) $filelist[0] += 1 WEnd Else _ArrayAdd($filelist, $sFileOpenDialog) $filelist[0] += 1 EndIf EndIf EndIf Return $filelist EndFunc ;==>ArrayToFileList Func QueueFile($sFileName) Opt("WinTitleMatchMode", 1) Local $hMeGUI = WinActivate("MeGUI ") BlockInput(1) Send("{CTRLDOWN}o{CTRLUP}") BlockInput(0) Local $hWnd = WinWaitActive("Select your input file") Sleep(500) Opt("SendKeyDelay", 0) BlockInput(1) ControlSend($hWnd, "", "Edit1", $sFileName & "{ENTER}") BlockInput(0) Opt("SendKeyDelay", 5) $hWnd = WinWaitActive("Current position:") Sleep(500) BlockInput(1) ControlSend($hWnd, "", "[NAME:showPAR]", "{SPACE}") BlockInput(0) Sleep(500) BlockInput(1) ControlSend($hWnd, "", "[NAME:dropDownButton]", "{SPACE}") Opt("SendKeyDelay", 50) Send("1{ENTER}") Opt("SendKeyDelay", 5) BlockInput(0) WinClose($hWnd) Sleep(500) WinWaitActive($hMeGUI) Local $aPos = MouseGetPos() Opt("MouseCoordMode", 0) BlockInput(1) MouseClick("left", 30, 50, 1, 0) BlockInput(0) Opt("MouseCoordMode", 1) MouseMove($aPos[0], $aPos[1], 0) Sleep(500) BlockInput(1) ControlClick($hMeGUI, "", "[NAME:autoEncodeButton]", "left", 1) BlockInput(0) Sleep(500) $hWnd = WinWaitActive("MeGUI - Automatic Encoding") Sleep(500) BlockInput(1) ControlClick($hWnd, "", "[NAME:addSubsNChapters]", "left", 1) BlockInput(0) Sleep(500) BlockInput(1) ControlClick($hWnd, "", "[NAME:queueButton]", "left", 1) BlockInput(0) Sleep(5000) EndFunc $files = GetListOfFiles() While $files[0] > 0 QueueFile($files[1]) _ArrayDelete($files, 1) $files[0] -= 1 WEnd MsgBox($MB_SYSTEMMODAL, "", "Done")
-
Needed a way to automate ripping mutiple .iso DVDs and I came up with this. Uses VirtualCloneDrive to mount the iso file. Uses PgcDemux to do the actual ripping. Uses DGIndex to index the m2v. And finally writes a avs file for input into MeGUI. Not perfect but gets the job done #include <Array.au3> #include <FileConstants.au3> #include <MsgBoxConstants.au3> #include <File.au3> #include <GUIConstantsEx.au3> Global $sINI = @ScriptDir & '\iso_to_avs.ini' ;add to array, list of files in a dir Func FileListFromDir($dir, $filetype, ByRef $filelist) ;search for the first file with the correct file extenstion Local $file, $search = FileFindFirstFile($dir & "\" & $filetype) ; Check if the search was successful If $search = -1 Then $searchDIR = FileFindFirstFile($dir & "\*") While 1 $file = FileFindNextFile($searchDIR) If @error Then ExitLoop EndIf If StringInStr(FileGetAttrib($dir & "\" & $file), "D") Then FileListFromDir($dir & "\" & $file, $filetype, $filelist) EndIf WEnd FileClose($searchDIR) ; Close the search handle EndIf ;add found files to array While 1 $file = FileFindNextFile($search) If @error Then ExitLoop EndIf ;Add file to array _ArrayAdd($filelist, $dir & "\" & $file) $filelist[0] += 1 WEnd FileClose($search) ; Close the search handle EndFunc ;==>FileListFromDir ;add from given array to Filelist Func GetListOfFiles() Local $dirbit = 0 Local $filetype = '*.iso' Local $filelist[1] $filelist[0] = 0 ;Grab EXE Drag-n-Droped files/dir's If $CmdLine[0] > 0 Then For $x = 1 To $CmdLine[0] Step +1 ;run though all files droped and look for dir's If StringInStr(FileGetAttrib($CmdLine[$x]), "D") Then $dirbit += 1 FileListFromDir($CmdLine[$x], $filetype, $filelist) ;parce dir looking for file of that extenstion Else ;add file to list _ArrayAdd($filelist, $CmdLine[$x]) $filelist[0] += 1 EndIf Next EndIf If $filelist[0] <= 0 Then ; Create a constant variable in Local scope of the message to display in FileOpenDialog. Local Const $sMessage = "Hold down Ctrl or Shift to choose multiple files." ; Display an open dialog to select a list of file(s). Local $sFileOpenDialog = FileOpenDialog($sMessage, @WindowsDir & "\", "ISO Files (*.iso)", $FD_FILEMUSTEXIST + $FD_MULTISELECT) If @error Then ; Display the error message. MsgBox($MB_SYSTEMMODAL, "", "No file(s) were selected.") ; Change the working directory (@WorkingDir) back to the location of the script directory as FileOpenDialog sets it to the last accessed folder. FileChangeDir(@ScriptDir) Else ; Change the working directory (@WorkingDir) back to the location of the script directory as FileOpenDialog sets it to the last accessed folder. FileChangeDir(@ScriptDir) If StringInStr($sFileOpenDialog, '|') Then $templist = StringSplit($sFileOpenDialog, '|') $dir = $templist[1] _ArrayDelete($templist, 1) $templist[0] -= 1 While $templist[0] > 0 $newfile = $dir & '\' & $templist[1] _ArrayDelete($templist, 1) $templist[0] -= 1 _ArrayAdd($filelist, $newfile) $filelist[0] += 1 WEnd Else _ArrayAdd($filelist, $sFileOpenDialog) $filelist[0] += 1 EndIf EndIf EndIf Return $filelist EndFunc ;==>ArrayToFileList Func LoadISO($filename) Local $cmd = IniRead($sINI, 'FileLocations', 'vcdmount', @ProgramFilesDir & ' (x86)\Elaborate Bytes\VirtualCloneDrive\VCDMount.exe') RunWait(@ComSpec & " /c " & '"' & $cmd & '"' & ' /d=0 /u', "", @SW_HIDE) ShellExecuteWait($cmd, ' /d=0 ' & '"' & $filename & '"') Send("{SHIFTDOWN}") GUISetCursor(15) OutputStatus("Waiting for the DVD to load:" & @CRLF & $filename & @CRLF & "DO NOT PRESS THE SHIFT KEY") WinWait("AutoPlay","", 15) WinClose("AutoPlay") OutputStatus("") Send("{SHIFTUP}") EndFunc Func RipDVD($isoName) Local $sDrive = "", $sDir = "", $sFilename = "", $sExtension = "" Local $aPathSplit = _PathSplit($isoName, $sDrive, $sDir, $sFilename, $sExtension) Local $dest = IniRead($sINI, 'FileLocations', 'destdir', 'D:\Users\admin\Videos\Rips\Auto\') & $sFilename DirCreate($dest) Local $cmd = IniRead($sINI, 'FileLocations', 'pgcdemux', 'D:\Users\admin\Desktop\New folder\PgcDemuxMod.exe') Local $cddrive = IniRead($sINI, 'FileLocations', 'cddrive', 'G:\') Local $filelist[1] $filelist[0] = 0 FileListFromDir($cddrive & 'VIDEO_TS', 'VTS*.IFO', $filelist) Local $counter = 1 While $filelist[0] > 0 $iPreviousFileSize = 0 For $x = 1 To 99 Step +1 OutputStatus('') If Not FileExists($dest & '\' & $counter & '-' & $x & '\VideoFile.m2v') Then DirCreate($dest & '\' & $counter & '-' & $x) Local $iPID = Run(@ComSpec & " /c " & '"' & $cmd & '"' & ' -pgc ' & $x & ' -m2v ' & $filelist[1] & ' ' & $dest & '\' & $counter & '-' & $x & '', "", @SW_HIDE) OutputStatus($counter & '-' & $x & ':m2v') ProcessWaitClose($iPID) Local $sOutput = StdoutRead($iPID) ; Remove dir if an error code was returned. If $sOutput <> 0 Then DirRemove($dest & '\' & $counter & '-' & $x) ExitLoop EndIf ; Remove dir if no video file was made. If Not FileExists($dest & '\' & $counter & '-' & $x & '\VideoFile.m2v') Then DirRemove($dest & '\' & $counter & '-' & $x) ExitLoop EndIf EndIf OutputStatus($counter & '-' & $x & ':checking') ; Remove dir if no audio file was made. If Not FileExists($dest & '\' & $counter & '-' & $x & '\AudioFile_80.ac3') Then DirRemove($dest & '\' & $counter & '-' & $x, 1) EndIf Local $iFileSize = FileGetSize($dest & '\' & $counter & '-' & $x & '\VideoFile.m2v') ; Remove dir if video file is smaller than 5MB. If $iFileSize < 5242880 Then DirRemove($dest & '\' & $counter & '-' & $x, 1) EndIf ; Remove dir if video file is the same as the last one. If $iPreviousFileSize == $iFileSize Then $this = _Crypt_HashFile($dest & '\' & $counter & '-' & $x & '\VideoFile.m2v', $CALG_MD5) $prev = _Crypt_HashFile($dest & '\' & $counter & '-' & ($x-1) & '\VideoFile.m2v', $CALG_MD5) ;MsgBox($MB_SYSTEMMODAL, "", StringCompare($this, $prev) & @CRLF & $this & @CRLF & $prev & @CRLF & $iPreviousFileSize & @CRLF & $iFileSize & @CRLF & $dest & '\' & $counter & '-' & $x & '\VideoFile.m2v' & @CRLF & $dest & '\' & $counter & '-' & ($x-1) & '\VideoFile.m2v') If StringCompare($this, $prev) == 0 Then DirRemove($dest & '\' & $counter & '-' & $x, 1) EndIf EndIf $iPreviousFileSize = $iFileSize IndexVideo($dest & '\' & $counter & '-' & $x, $counter & '-' & $x) MakeAviSynthFile($dest, $counter & '-' & $x) Next OutputStatus('') $counter += 1 _ArrayDelete($filelist, 1) $filelist[0] -= 1 WEnd EndFunc Func IndexVideo($dir, $small_dir) If FileExists($dir & '\VideoFile.m2v') Then If Not FileExists($dir & '\VideoFile.d2v') Then Local $cmd = '"' & IniRead($sINI, 'FileLocations', 'dgindex', @ProgramFilesDir & ' (x86)\AviSynth 2.5\tools\dgmpegdec\DGIndex.exe') & '" -IF=[' & $dir & '\VideoFile.m2v] -OF=[' & $dir & '\VideoFile] -HIDE -EXIT' OutputStatus($small_dir & ':d2v') RunWait(@ComSpec & " /c " & $cmd, "", @SW_HIDE) OutputStatus('') EndIf EndIf EndFunc Func MakeAviSynthFile($dest, $small_dir) $sDestFile = $dest & '\' & $small_dir & '.avs' If Not FileExists($dest & '\' & $small_dir & '\VideoFile.d2v') Then If FileExists($sDestFile) Then FileDelete($sDestFile) EndIf ElseIf Not FileExists($sDestFile) Then Local $sFileContents = '' $sFileContents &= 'v = MPEG2Source("' & $small_dir & '\VideoFile.d2v", cpu=2)' & @CRLF $sFileContents &= 'a = NicAC3Source("' & $small_dir & '\AudioFile_80.ac3", 2)' & @CRLF $sFileContents &= 'audiodubex(v, a)' & @CRLF $sFileContents &= '#QTGMC(Preset="draft", NoisePreset="Slow")' & @CRLF $sFileContents &= 'QTGMC(Preset="Medium", NoisePreset="Slow")' & @CRLF $sFileContents &= 'SelectEven()' & @CRLF $sFileContents &= 'TDecimate()' & @CRLF FileWrite($sDestFile, $sFileContents) EndIf EndFunc Func OutputStatus($sMessage) Local $hWnd = WinGetHandle("") TrayTip('Status:', $sMessage, 30) TraySetToolTip($sMessage) WinActivate($hWnd) EndFunc $files = GetListOfFiles() While $files[0] > 0 LoadISO($files[1]) RipDVD($files[1]) _ArrayDelete($files, 1) $files[0] -= 1 WEnd MsgBox($MB_SYSTEMMODAL, "", "Done") Example INI file
-
Uses the latest (as of May 8th, 2011) version of ImageMagick. Has a slow mode (press no) which then uses this algorithm: smart sharpening in imagemagick #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=blue.ico #AutoIt3Wrapper_Outfile=image.exe #AutoIt3Wrapper_Compression=4 #AutoIt3Wrapper_Res_Language=1033 #AutoIt3Wrapper_Add_Constants=n #AutoIt3Wrapper_Run_Tidy=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.0.0 Author: myName Script Function: Template AutoIt script. #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here #include <Array.au3> ; Basic ImageMagick Vars Global $ret = 0 Global $info Global $msgs Global $elem Global $sMsgs Global Const $ERROR_SUCCESS = 0 ; ImageMagick Error handler ChkImageMagickInstall() Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") Global $img = ObjCreate("ImageMagickObject.MagickImage.1") ;Autoit Variables Global $filelist[1] $filelist[0] = 0 Global $filetype = "*.jpg" Global $OutDir = @DesktopDir & "\" & @YEAR & "-" & @MON Global $mode = 6 ChkCmd() If $filelist[0] > 0 Then $mode = MsgBox(4, "Quality/Speed Selection", "Press Yes for speed, No for High quality mode (over 10 times slower).") ProcessImages() Else MsgBox(0x40000, "Error", "No Picture " & $filetype & " files found") EndIf ; Install Imagemagick Func ChkImageMagickInstall() If DirGetSize(@ProgramFilesDir & "\ImageMagick-6.6.9-Q16") == -1 Then ToolTip("Installing Image Processing Tools") FileInstall("ImageMagick-6.6.9-8-Q16-windows-dll.exe", "install.exe") RunWait("install.exe" & " /VERYSILENT" & ' /COMPONENTS="install_magick_dll"') ToolTip("Tools Installed") Sleep(1000) FileInstall("ImageMagickObject.dll", @ProgramFilesDir & "\ImageMagick-6.6.9-Q16\ImageMagickObject.dll") FileInstall("MagickCMD.exe", @ProgramFilesDir & "\MagickCMD.exe") RunWait(@ComSpec & " /c " & 'Regsvr32 /s "' & @ProgramFilesDir & '\ImageMagick-6.6.9-Q16\ImageMagickObject.dll"', "", @SW_HIDE) Sleep(1000) ToolTip("") EndIf EndFunc ;==>ChkImageMagickInstall ;Grab EXE Drag-n-Droped files/dir's Func ChkCmd() ;Files where dropped onto exe If $CmdLine[0] > 0 Then ArrayToFileList($CmdLine) Else $folder = FileSelectFolder("Choose The Folder That Contains All The Images.", "") If @error Then Return '' EndIf FileListFromDir($folder) EndIf EndFunc ;==>ChkCmd ;add from given array to Filelist Func ArrayToFileList($CmdLine) Local $dirbit = 0 For $x = 1 To $CmdLine[0] Step +1 ;run though all files droped and look for dir's If StringInStr(FileGetAttrib($CmdLine[$x]), "D") Then $dirbit += 1 FileListFromDir($CmdLine[$x]) ;parce dir looking for file of that extenstion Else ;add file to list _ArrayAdd($filelist, $CmdLine[$x]) $filelist[0] += 1 EndIf Next EndFunc ;==>ArrayToFileList ;add to array, list of files in a dir Func FileListFromDir($dir) ;search for the first file with the correct file extenstion Local $file, $search = FileFindFirstFile($dir & "\" & $filetype) ; Check if the search was successful If $search = -1 Then $searchDIR = FileFindFirstFile($dir & "\*") While 1 $file = FileFindNextFile($searchDIR) If @error Then ExitLoop EndIf If StringInStr(FileGetAttrib($dir & "\" & $file), "D") Then FileListFromDir($dir & "\" & $file) EndIf WEnd FileClose($searchDIR) ; Close the search handle EndIf ;add found files to array While 1 $file = FileFindNextFile($search) If @error Then ExitLoop EndIf ;Add file to array _ArrayAdd($filelist, $dir & "\" & $file) $filelist[0] += 1 WEnd FileClose($search) ; Close the search handle EndFunc ;==>FileListFromDir Func ProcessImages() ProgressOn("Image Processor", "Total of " & $filelist[0] & " images loaded for processing", "", "", "", 16) DirCreate($OutDir) While DirGetSize($OutDir) == -1 Sleep(250) WEnd Sleep(250) $step = 100 / $filelist[0] $increment = $step $counter = 0 While $filelist[0] > 0 Local $filein = $filelist[1] Local $fileout = ChangeOutputDir($filelist[1]) ProgressSet($increment, Round($increment) & " percent. " & $counter & " files done.") If $mode == 6 Then $out = _ImageMagick_Quality($filein, "70", $fileout) Else $out = _ImageMagick_Sharpen($filein, $fileout) EndIf ConsoleWrite($out) If @error Then ExitLoop _ArrayDelete($filelist, 1) $filelist[0] -= 1 $increment += $step $counter += 1 WEnd ProgressSet(100, "Done", "Complete") ShellExecute($OutDir) Sleep(500) ProgressOff() EndFunc ;==>ProcessImages ; Error event Func MyErrFunc() $HexNumber = Hex($oMyError.number, 8) MsgBox(0, "ImageMagick Error", "There was an ImageMagick error!" & @CRLF & @CRLF & _ "err.description is: " & @TAB & $oMyError.description & @CRLF & _ "err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _ "err.number is: " & @TAB & $HexNumber & @CRLF & _ "err.lastdllerror is: " & @TAB & $oMyError.lastdllerror & @CRLF & _ "err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF & _ "err.source is: " & @TAB & $oMyError.source & @CRLF & _ "err.helpfile is: " & @TAB & $oMyError.helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $oMyError.helpcontext _ ) SetError(1) ; to check for after this function returns EndFunc ;==>MyErrFunc Func _ImageMagick_Sharpen($sInFile, $sOutFile) $sharp_radius = 5 $sharp_sigma = Sqrt($sharp_radius) $sharp_amount = 1.2 $sharp_threshold = 0.003 $a1 = 0 $b1 = 0 $c1 = 1.2 $d1 = -0.1 $blur_radius = 3 $blur_sigma = Sqrt($blur_radius) $edge_width = 2 $clip_low = "40" ;percentage left totally untouched by the sharpening $clip_high = "1" ;percentage sharpened full strength $img.Convert($sInFile, _ "-auto-orient", _ "-resize", "3145732@\>", _ "-quality", "00", _ $sOutFile & ".png") ;first make the edges $img.Convert($sOutFile & ".png", _ "-edge", $edge_width, " ", _ "-colorspace", "Gray ", _ "-quality", "00", _ $sOutFile & "_inner_edges.png") $img.Convert($sOutFile & ".png", _ "-negate", " ", _ "-edge", $edge_width, " ", _ "-colorspace", "Gray ", _ "-quality", "00", _ $sOutFile & "_outer_edges.png") $img.Composite("-compose", "plus", _ $sOutFile & "_inner_edges.png", _ $sOutFile & "_outer_edges.png", _ "-quality", "00", _ $sOutFile & "_added_edges.png") $img.Convert($sOutFile & "_added_edges.png", _ "-gaussian-blur", $blur_radius & "x" & $blur_sigma, _ "-quality", "00", _ $sOutFile & "_edges_blurred.png") $ret = $img.Convert($sOutFile & "_edges_blurred.png", _ "-linear-stretch", $clip_low & "%x" & $clip_high, _ "-quality", "00", _ $sOutFile & "_edges.png") ;then get the value channel and sharpen it $img.Convert($sOutFile & ".png", _ "-colorspace", "HSB", " ", _ "-channel", "B", " ", _ "-separate", " ", _ "-quality", "00", _ $sOutFile & "_value.png") $img.Convert($sOutFile & "_value.png", _ "-unsharp", $sharp_radius & "x" & $sharp_sigma & "+" & $sharp_amount & "+" & $sharp_threshold, " ", _ "-quality", "00", _ $sOutFile & "_value_8.png") $img.Composite($sOutFile & "_value_8.png", _ $sOutFile & "_value.png", _ $sOutFile & "_edges.png", _ "-quality", "00", _ $sOutFile & "_value_partial_sharp.png") ;then get the hue and saturation channels $img.Convert($sOutFile & ".png", _ "-colorspace", "HSB", " ", _ "-channel", "R", " ", _ "-separate", " ", _ "-quality", "00", _ $sOutFile & "_hue.png") $img.Convert($sOutFile & ".png", _ "-colorspace", "HSB", " ", _ "-channel", "G", " ", _ "-separate", " ", _ "-quality", "00", _ $sOutFile & "_saturation.png") FileDelete($sOutFile & "_inner_edges.png") FileDelete($sOutFile & "_outer_edges.png") FileDelete($sOutFile & "_added_edges.png") FileDelete($sOutFile & "_edges_blurred.png") FileDelete($sOutFile & "_edges.png") FileDelete($sOutFile & "_value.png") FileDelete($sOutFile & "_value_8.png") FileDelete($sOutFile & ".png") ;finally put it all together $img.Convert($sOutFile & "_hue.png", "-colorspace", "HSB", _ $sOutFile & "_hue.png", "-compose", "CopyRed", "-composite", _ $sOutFile & "_saturation.png", "-compose", "CopyGreen", "-composite", _ $sOutFile & "_value_partial_sharp.png", "-compose", "CopyBlue", "-composite", _ "-colorspace", "RGB", _ "-quality", "00", _ $sOutFile & "_smartsharp.png") ;auto level $ret = $img.Convert($sOutFile & "_smartsharp.png", _ "-auto-level", _ "-quality", "00", _ $sOutFile & ".png") ;compress to jpeg $ret = $img.Convert($sOutFile & ".png", _ "-quality", "70", _ "-contrast-stretch", "1.5%x2%", _ $sOutFile) FileDelete($sOutFile & ".png") FileDelete($sOutFile & "_hue.png") FileDelete($sOutFile & "_saturation.png") FileDelete($sOutFile & "_value_partial_sharp.png") FileDelete($sOutFile & "_smartsharp.png") Return $ret EndFunc ;==>_ImageMagick_Sharpen Func _ImageMagick_Quality($sInFile, $sQuality, $sOutFile) $ret = $img.Convert($sInFile, _ "-auto-level", _ "-auto-orient", " ", _ "-contrast-stretch", "1.5%x2%", _ "-resize", "3145732@\>", _ "-quality", $sQuality, _ $sOutFile) Return $ret EndFunc ;==>_ImageMagick_Quality ;change string to output dir right before it goes to HCenc.exe Func ChangeOutputDir($fileout) Local $temp = StringSplit($fileout, "\") $fileout = $OutDir & "\" & $temp[$temp[0]] Return $fileout EndFunc ;==>ChangeOutputDir
-
Got it working again, let me know if you have any more issues
-
Updated the 2nd post with the newest version of POP
-
Gmail's pop server no longer takes the NOOP if your not logged in... I need to rewrite the udf, give me a couple of hrs/days.
-
It's an OpenSSL problem Run the test command from ptrex, and let me know what it says http://www.autoitscript.com/forum/index.ph...st&p=592662
-
As of right now, no.
-
Auto install ImageMagick if it's not there. Auto rotate image baised on EXIF data. Auto brightens dark areas Auto resize shrinks to typical 3MP image Recompresses jpg files to 70% quality for web use. Dumps processed files in a dir on the desktop. Grabed Code From my batch m2v maker http://www.autoitscript.com/forum/index.php?showtopic=58691 and the ImageMagick Object http://www.autoitscript.com/forum/index.php?showtopic=49065 #include <Array.au3> ; Basic ImageMagick Vars Global $ret = 0 Global $info Global $msgs Global $elem Global $sMsgs Global Const $ERROR_SUCCESS = 0 ChkImageMagickInstall() ; ImageMagick Error handler Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") Global $img = ObjCreate("ImageMagickObject.MagickImage.1") ;Autoit Variables Global $filelist[1] $filelist[0] = 0 Global $filetype = "*.jpg" Global $OutDir = @DesktopDir & "\" & @YEAR & "-" & @MON ChkCmd() ProcessImages() ; Install Imagemagick Func ChkImageMagickInstall() If DirGetSize(@ProgramFilesDir & "\ImageMagick-6.4.7-Q16") == -1 Then ToolTip("Installing Image Processing Tools") FileInstall("ImageMagick-6.4.7-6-Q16-windows-dll.exe", "install.exe") RunWait("install.exe" & " /VERYSILENT" & ' /COMPONENTS="install_magick_dll"') ToolTip("Tools Installed") FileInstall("ImageMagickObject.dll", @ProgramFilesDir & "\ImageMagick-6.4.7-Q16\ImageMagickObject.dll") FileInstall("MagickCMD.exe", @ProgramFilesDir & "\MagickCMD.exe") Sleep(1000) RunWait(@ComSpec & " /c " & 'Regsvr32 /s "' & @ProgramFilesDir & '\ImageMagick-6.4.7-Q16\ImageMagickObject.dll"', "", @SW_HIDE) Sleep(1000) ToolTip("") EndIf EndFunc ;Grab EXE Drag-n-Droped files/dir's Func ChkCmd() ;Files where dropped onto exe If $CmdLine[0] > 0 Then ArrayToFileList($CmdLine) EndIf EndFunc ;==>ChkCmd ;add from given array to Filelist Func ArrayToFileList($CmdLine) Local $dirbit = 0 For $x = 1 To $CmdLine[0] Step +1 ;run though all files droped and look for dir's If StringInStr(FileGetAttrib($CmdLine[$x]), "D") Then $dirbit += 1 FileListFromDir($CmdLine[$x]) ;parce dir looking for file of that extenstion Else ;add file to list _ArrayAdd($filelist, $CmdLine[$x]) $filelist[0] += 1 EndIf Next EndFunc ;==>ArrayToFileList ;add to array, list of files in a dir Func FileListFromDir($dir) ;search for the first file with the correct file extenstion Local $file, $search = FileFindFirstFile($dir & "\" & $filetype) ; Check if the search was successful If $search = -1 Then MsgBox(0x40000, "Error", "No Picture " & $filetype & " files found") EndIf ;add found files to array While 1 $file = FileFindNextFile($search) If @error Then ExitLoop EndIf ;Add file to array _ArrayAdd($filelist, $dir & "\" & $file) $filelist[0] += 1 WEnd FileClose($search) ; Close the search handle EndFunc ;==>FileListFromDir Func ProcessImages() ProgressOn("Image Processor", "Total of " & $filelist[0] & " images loaded for processing") DirCreate($OutDir) While DirGetSize($OutDir) == -1 Sleep(250) WEnd Sleep(250) $step = 100 / $filelist[0] $increment = $step While $filelist[0] > 0 Local $filein = $filelist[1] Local $fileout = ChangeOutputDir($filelist[1]) ProgressSet($increment, Round($increment) & " percent") _ImageMagick_Quality($filein, "70", $fileout) If @error Then ExitLoop _ArrayDelete($filelist, 1) $filelist[0] -= 1 $increment += $step WEnd ProgressSet(100 , "Done", "Complete") ShellExecute($OutDir) Sleep(500) ProgressOff() EndFunc ; Error event Func MyErrFunc() $HexNumber=hex($oMyError.number,8) Msgbox(0,"ImageMagick Error", "There was an ImageMagick error!" & @CRLF & @CRLF & _ "err.description is: " & @TAB & $oMyError.description & @CRLF & _ "err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _ "err.number is: " & @TAB & $HexNumber & @CRLF & _ "err.lastdllerror is: " & @TAB & $oMyError.lastdllerror & @CRLF & _ "err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF & _ "err.source is: " & @TAB & $oMyError.source & @CRLF & _ "err.helpfile is: " & @TAB & $oMyError.helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $oMyError.helpcontext _ ) SetError(1) ; to check for after this function returns EndFunc Func _ImageMagick_Quality($sInFile, $sQuality, $sOutFile) $ret = $img.Convert($sInFile, _ "-auto-orient", " ", _ "-quality",$sQuality, _ "-sigmoidal-contrast", "2,0%", _ "-filter","Lagrange", _ "-resize","2048x2048>", _ $sOutFile) Return $ret EndFunc ;change string to output dir right before it goes to HCenc.exe Func ChangeOutputDir($fileout) Local $temp = StringSplit($fileout, "\") $fileout = $OutDir & "\" & $temp[$temp[0]] Return $fileout EndFunc Edit 12-12-2008: Using -sigmoidal-contrast for image brightness Added in Resize
-
ditto, why do they disappear after 3 days? It's a moron move in my opinion. It makes supporting some of the functions that I wrote quite hard.
-
It's because it's marking that email as read. I should probably have a PeekMessage() function. I'll be gone till mid December so if anyone wants to code it, do it, otherwise I'll pick this up in 3-4 weeks. The bank account would best be handled by something like the IE functions. Using OpenSSL to do it, although possible, is kinda nuts.
-
I think a wrapper for these functions would be helpful... here's my untested take on it Func WinHttpWrapper($URL, $Type, $Data = "", $username = "", $password = "", $protocall = "HTTP/1.1") $temp = SplitURL($URL) $Server = $temp[0] $Address = $temp[1] $hw_open = _WinHttpOpen("WinHTTP Example") $hw_connect = _WinHttpConnect($hw_open, $Server) $h_openRequest = _WinHttpOpenRequest($hw_connect, $Type, $Address, $protocall) _WinHttpSetCredentials($h_openRequest, $WINHTTP_AUTH_TARGET_SERVER, $WINHTTP_AUTH_SCHEME_BASIC, $username, $password) _WinHttpSendRequest($h_openRequest) _WinHttpWriteData($h_openRequest, $Data) $Response = _WinHttpReceiveResponse($h_openRequest) _WinHttpCloseHandle($h_openRequest) _WinHttpCloseHandle($hw_connect) _WinHttpCloseHandle($hw_open) Return $Response EndFunc Func SplitURL($URL) Dim $array[2] $split = SplitURLHelper($URL, 3) If $split == 0 Then $split = SplitURLHelper($URL, 2) $URL = StringRight($URL, $split) $array[0] = $URL Return $array EndIf $left = StringLeft($URL, $split) $right = StringRight($URL, $split) $split = SplitURLHelper($left, 2) $left = StringRight($left, $split) $array[0] = $left $array[1] = $right Return $array EndFunc Func SplitURLHelper($String, $pos) $split = StringInStr($String, "/", 0, $pos) If $split == 0 Then $split = StringInStr($String, "\", 0, $pos) EndIf Return $split EndFunc
-
Good to hear I inspired you! Would you mind giving an example? Like sending a POST with these parameters user=admin pass=admin post data: restart=Restart? http://www.autoitscript.com/forum/index.php?showtopic=83971 Or does WinHTTP still need some work in order to accomplish this?
-
yeah I gave the latest version of Tomato a try, but i couldn't get it to connect to my TEW-432BRP. Anyway the DD-WRT wiki is very helpful and answers just about any how to question.