From: Gustaf N. <ne...@wu...> - 2020-05-12 16:26:33
|
Dear Fox, There is absolutely no reason why the Tcl-builtin zlib function returns different sizes in tclsh or NaviServer. I could not reproduce any differences in these two environments. (i modified you script slightly, and made sure, that the resulting compressed files is (a) binary and (b) does not contain a newline at the end of the file). all are the same for ===================================== set inFile "/tmp/myImage.png" set outFile "/tmp/myImage.png.ixz" set myFile [open $inFile RDONLY] fconfigure $myFile -translation binary set content [read $myFile] close $myFile set binData [encoding convertto utf-8 $content] set hexData [binary encode hex [encoding convertto utf-8 $content]] # level 0 => 2.56 MB # level 6 => 1.13 MB # level not specified 1.13 MB # level 9 => 1.11 MB set fp [open $outFile w] fconfigure $fp -translation binary puts -nonewline $fp [zlib compress $hexData] close $fp puts [subst { /tmp/myImage.png: [clock format [file mtime /tmp/myImage.png]] [file size /tmp/myImage.png] /tmp/myImage.png.ixz [clock format [file mtime /tmp/myImage.png.ixz]] [file size /tmp/myImage.png.ixz] }] ===================================== On 10.05.20 15:59, D.Fox wrote: > Hi, I am trying to compress a image (.png) using hexadecimal and ZLIB. > When running the below code within naviserver the created file is > larger then if I run standalone shell. > > The sample code is as follows: > ######### > set file "/bench/myImage.png" > set filePath "/bench/" > > set myFile [open $file RDONLY] > fconfigure $ myFile -translation binary > set content [read $myFile] > set binData [encoding convertto utf-8 $content] > set hexData [binary encode hex [encoding convertto utf-8 $content]] > close $myFile > > set fp [open "$filePath/myCompressedHexBlobFile.ixz" w] > puts $fp [zlib compress $hexData] > close $fp > ######### > Outputs: > 846K - myImage.png > 1.7M - myCompressedHexBlobFile.ixz - Executed within Naviserver > 1.1M - myCompressedHexBlobFile.ixz - Executed from shell with TCLSH > ######### > Is Navi using a different zlib compression level, why is this happening? > If I set the compression level to nine, the created file is still at > 1.7mb. This is kind of a game changer, even if I source the > compression script the file size is still larger then if I run it via > terminal. > > Thanks > Fox > > > > > > > _______________________________________________ > naviserver-devel mailing list > nav...@li... > https://lists.sourceforge.net/lists/listinfo/naviserver-devel |