Home   Archive   Permalink



nowrap

Hello,
    
I am new to rebol and want to convert a jpg image to base64 and save the result without wrap.
    
I have achieved part of this with the following code :
    system/options/binary-base: 64
    img: read/binary %picture.jpg
    save %picture64.txt img
    
I then tried to remove the line wrap (result in 1 line only) and have tried the following code :
    system/options/binary-base: 64
    system/standard/face/para/wrap?: false
    img: read/binary %picture.jpg
    save %picture64.txt img
    
Unfortunately the result continue to be saved with line wrap.
I have searched without success a clue to my issue, so hope that some expert can help me here.
Regards,


posted by:   malko       10-Jan-2014/10:56:20-8:00



Depending on what you're trying to do, one of these should give you what you need:
    
    
     system/options/binary-base: 64
     img: read/binary %a.jpg
     write %picture64a.txt replace/all mold img newline ""
     write %picture64b.txt second parse replace/all mold img newline "" "{}"

posted by:   Nick       10-Jan-2014/13:56:15-8:00



'mold converts the data to a string, 'replace/all replaces all the line endings with nothings, 'parse split out the content from the header.

posted by:   Nick       10-Jan-2014/14:00:49-8:00



Thank you Nick!
I gave a quick try to both of them. The second one will have my preference actually.
    
Allow me to congratulate you for the great tutorial you have written (http://musiclessonz.com/rebol_tutorial.html). I will try to give an in deep reading.

posted by:   malko       11-Jan-2014/17:29:39-8:00



Malko,
    
The text at http://business-programming.com is slightly newer (mostly the same, but I prefer it to the one at re-bol.com). Also, the new text at http://re-bol.com/starting_computer_programming_with_rebol.html#section-7.8 has a really quick run through of lots of Rebol example code.

posted by:   Nick       12-Jan-2014/5:32:05-8:00



A while back, I wrote this script to convert images into a format that could be used in NS Basic:
    
R E B O L [title: "NS Basic Image Encoder"]
title-text: "NS Basic Image Encoder"
image-name: request-text/title/default
     "ID property of image widget:" "Image1"
system/options/binary-base: 64
x: at (form read/binary to-file my-file: request-file/only) 4
y: parse form x "^/"
z: rejoin [{myimage="data:Image/} (at form suffix? my-file 2) {;base64,"}]
len: length? y
for i 2 (len - 1) 1 [
     append z rejoin [
         newline {myimage=myimage & "} (pick y i) {"}
     ]
]
append z rejoin [{^/^/} image-name {.innerHTML="<img src='" & myimage & "'/>"}]
editor z

posted by:   Nick       12-Jan-2014/8:44:57-8:00



Thanks for the links. :)
    
PS: I really like your generic captcha idea.

posted by:   Malko       12-Jan-2014/15:32:59-8:00