8 posts in this topic
I'm too stupid to see my mistake:
To investigate the internal "dictionary" of TIFF files I'd like to read in the files in binary mode and to check, if there are more than one pages "in" this TIFF.
Notepad++, "View as Hex" is presenting the first bytes as "49 49 2a 20 08 20 20 20 12" for the TIF attached to this posting
The "TIFF Header Format" is easy:
Offset 00h, 2 Byte = Byte Order, "II"=intel, "MM"=motorola. (I = 0x49)
Offset 02h, 2 Byte = Version Nr.
Offset 04h, 4 Byte = pointer to first IFD entry
Description of TIFF header: https://www.awaresystems.be/imaging/tiff/faq.html#q3
Howto read and analyse the binary content correctly? This is my messy, not operational code:
$sampleTiff="H:\daten\tif\11\11\111111.TIF" $h=FileOpen($sampleTiff,16) $content=FileRead($h) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $content = ' & $content & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console FileClose($h) $type=VarGetType($content) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $type = ' & $type & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console $ToString=BinaryToString($content) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $ToString = ' & $ToString & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console ConsoleWrite(@CRLF & @CRLF) $content=StringTrimLeft($content,2) ; cut off the leading "0x" ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $content = ' & $content & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console for $i = 1 to 8 step 8 $next=StringMid($content,$i,2) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $next = ' & $next & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console $Chr=BinaryToString($next) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $Chr = ' & $Chr & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console ConsoleWrite(@CRLF & "---" & @CRLF) Next Regards, Rudi.
It's now possible to see the best compression ratio using LZMA, LZNT and Base64 compressions with differents combinations.
Nothing too complicate, you drag'n drop a file on the picture and script Test all compression types and return the ratios.
( Test duration depends of file size, slowest compression is LZNT, but all decompressions are fast )
Free to you after, to choose the compression(s) you want...
Yes, LZMA needs a dll ( embedded & compressed in script ) but brings a powerfull compression.
It opens scite with your file compressed to an au3 script with or without decompression function as you want.
Hold Left Shift key when clicking button for just copy script to clipboard.
Use the 3 compressions at a time works but doesn't give a good ratio, that's why i don't display it.
Usefull for little files you want include in your scripts !
No externals files needed, they are already in script.
Previous downloads : 1103
Source and Executable
BinaryToAu3Kompressor will be added to the next version of >SciTEHopper
Thanks to Ward for his >Base64.au3 and LZMA.au3, and trancexx for his >LZNT functions and his >Base64Decode function.
Trying to convert a number to binary zeros and ones but I'm getting a result I don't understand and looks more like hex than binary.
Here's my basic code:
$myNum = 11 $myNumBin = Binary($myNum) MsgBox(0, "Binary result", $myNumBin) What I want is "1011", what I get is 0x0B000000.
Here are three stepts that I would like to speed up - if possible:
STEP 1: I am generating an array, containing binary numbers up to a certain amount of digits. My script adds leading zeros, so that each number has equal amount of digits.
Example: 14 digit Binary array:
I am using the code
For $i = 0 to 2^$bit-1 ; $bit amount of digits. for example: 14 $binary = ( Dec2Bin($i) ) ; Check length of binary string $adig = $bit - StringLen($binary) ; Determine how many leading 0 have to be added $zeros = "" For $j = 1 To $adig ; add leading "0"s $zeros = $zeros & "0" Next $BinArray[$i] = $zeros & $binary ;Write binary-number to file, leading "0" Next Func Dec2Bin($D) Return (BitShift($D, 1) ? Dec2Bin(BitShift($D, 1)) : "") & BitAnd($D, 1) EndFunc ;==> Dec2Bin() AutoIt v220.127.116.11 to generate the binary number.
STEP 2: I reduce the array to unique values. In my application, the binary-numbers do not have a start-bit or end-bit. This means, that
are actually the same numbers, and only one of them is to remain in the array. All alterations aren't unique and shall be removed. Here is my code:
For $i = 0 to Ubound($BinArray)-1 ; shift through all rows For $j = 1 to $bit ; shift through all the bits If $i = Ubound($BinArray) Then ; exit before exceeding the arrays boundries ExitLoop 2 EndIf $BinArray[$i] = StringRight ( $BinArray[$i], 1 ) & StringLeft ( $BinArray[$i], $bit-1 ) $BinArray = _ArrayUnique($BinArray, 0, 0, 0, 0, $ARRAYUNIQUE_AUTO) If @error <> 0 Then Msgbox(0, "Error in _ArrayUnique", "The Error Code is " & @error & " Abort.") Exit EndIf Next Next STEP 3: Finally, I write the remaining array into a text-file.
For $i = 0 to Ubound($BinArray)-1 FileWrite($hFileOpen, $i & @TAB & $BinArray[$i] & @CRLF) Next
So my question is: any idea how to speed up this procedure? There certainly is a way to do this smarter. Btw.: Step 2 is optional.
Thanks for helping,
I have a binary string that I want to convert to octal, The string I want to convert is,
The String is read from a .txt file
Once its converted it should read this,
4 2 2 5 0 1 1 6 2 1 6 0 6 4 1 2 0 6 10
which I want written to the .txt file to overwrite the original binary string.
The 10 at the end should be ignored as there are not 3 digits to convert.
I'm thinking it should read the string from left to right to get the next 3 digits before converting them to its oct value. would this be the best way to do this or is there a better way?
If i'm on the right track can anyone give me an example of how to write this script please?
I've looked at the StringLeft function & StringReplace but I'm not sure how to use them the correct way to accomplish what I'm trying to do.