I am now getting correct results so it may of been what you suspected. Via Naviserver /tmp/myImage.png: Sat May 09 11:59:29 BST 2020 865982 /tmp/myImage.png.ixz Mon May 11 09:44:41 BST 2020 1159064
Via tclsh /tmp/myImage.png: Sat May 09 11:59:29 BST 2020 865982 /tmp/myImage.png.ixz Mon May 11 09:46:33 BST 2020 1159064 Thank you for the second pair of eyes, really appreciated. Fox From: "Gustaf Neumann" <neum...@wu.ac.at> To: "naviserver-devel" <naviserver-devel@lists.sourceforge.net> Sent: Monday, May 11, 2020 9:25:32 AM Subject: Re: [naviserver-devel] File compress larger within naviserver then standalone Dear Fox, There is absolutely no reason that the Tcl-builtin function zlib returns different results in tclsh and naviserver. I could not reproduce different results in these two environments, also when modifying the compression level (see comments below). I slightly modified your script my making sure that the resulting file is binary and contains no extra newline at the end. While correcting this, i noticed that the size of the file differed in the range as you reported when writing the file binary or not (as in your case). So, my suspicion is that you compared the result of binary result writing in tclsh with non-binary result writing in NaviServer. Can you report the different results with the modified script? -g ================================== 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 stderr [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 [ mailto:naviserver-devel@lists.sourceforge.net | naviserver-devel@lists.sourceforge.net ] [ https://lists.sourceforge.net/lists/listinfo/naviserver-devel | https://lists.sourceforge.net/lists/listinfo/naviserver-devel ] _______________________________________________ naviserver-devel mailing list naviserver-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/naviserver-devel
_______________________________________________ naviserver-devel mailing list naviserver-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/naviserver-devel