problem of the difference between "photo data" and "base64::encode" - TCL
This is a discussion on problem of the difference between "photo data" and "base64::encode" - TCL ; I wrote "set theIm [image create photo -file "C:/Winter.jpg"]" to
create a photo
and I wrote following codes to get the photo's data by two ways
1.
set imagedatafile [open "C:/imagedata.txt" "w+"]
fconfigure $imagedatafile -translation binary
puts $imagedatafile [$theIm data ...
-
problem of the difference between "photo data" and "base64::encode"
I wrote "set theIm [image create photo -file "C:/Winter.jpg"]" to
create a photo
and I wrote following codes to get the photo's data by two ways
1.
set imagedatafile [open "C:/imagedata.txt" "w+"]
fconfigure $imagedatafile -translation binary
puts $imagedatafile [$theIm data -format jpeg]
close $imagedatafile
2.
set fileName "C:/Winter.jpg"
set fd [open $fileName r]
fconfigure $fd -translation binary
set imagebase64file [open "C:/imagebase64.txt" "w+"]
fconfigure $imagebase64file -translation
binary
puts $imagebase64file [::base64::encode [read $fd]]
close $fd
close $imagebase64file
But I found the C:/imagedata.txt is very different from the C:/
imagebase64.txt
anyone knows why this happen?
thanks
-
Re: problem of the difference between "photo data" and "base64::encode"
sunng wrote:
> But I found the C:/imagedata.txt is very different from the C:/
> imagebase64.txt
The most likely reason is the decoding of the image on load into an
internal representation, and subsequent (re)encoding into JPEG on the
write (as happens in your 1).
With the lossy formats such as JPEG you are also losing image quality,
but even with a lossless format (such BMP), the input and output may be
different, even if the picture will stay the same.
-mi
Similar Threads
-
By Application Development in forum JDBC JAVA
Replies: 0
Last Post: 03-21-2007, 01:26 PM
-
By Application Development in forum Theory
Replies: 2
Last Post: 03-21-2007, 02:36 AM
-
By Application Development in forum DOTNET
Replies: 0
Last Post: 03-12-2006, 03:55 AM
-
By Application Development in forum JDBC JAVA
Replies: 5
Last Post: 11-17-2005, 04:54 PM
-
By Application Development in forum DOTNET
Replies: 0
Last Post: 12-15-2004, 08:35 AM