PDA

View Full Version : Embedding images in html



HankFay
2013-11-06, 12:02
When distributing your app, one suggestion from Barry has been to embed images in your webviews.

Reading directions on the web is one thing; seeing an actual example is another, and often better (at least for me).

Here's a site ( http://webcodertools.com/imagetobase64converter/Create ) where you can upload an image and get it done for you, so you can see what it would look like. Moving from there to what you want to do in your webview .rsp will depend on your needs, but at least you'll have a working example from which to start.

What I would suggest is that you create a parser that looks for img tags, and then does the transformation for you. That way, you can develop with non-embedded images and when ready to distribute, can embed them. Oh, don't forget to contact the LianjaX administrators to get your code up on LianjaX. <s>

enjoy,

Hank

HankFay
2013-12-11, 20:12
PS: you should also try out base64_encode_file(). it's not in the Wiki yet, but was mentioned in a post here: http://www.lianja.com/community/showthread.php?753-Generating-HTML5-inline-images-with-Lianja&highlight=base64_encode_file.

You will find that it outputs text directly: because it's made to be used in an .rsp page, where that would be handy.

If you want to output the text to a file (handy for embedding in an enhanced helpfile editor, for example), you will want to use SET ALTERNATE, which unless you were doing Fox programming in the early to mid-90's you might not remember (because you won't have had occasion to use it).

SET ALTERNATE TO myfile.txt
SET ALTERNATE ON
=base64_encode_file("mypathedfile.png","png")
SET ALTERNATE OFF
SET ALTERNATE TO && doesn't write it out, although the file is already created, until you do this

Now, you will have one little issue here: the command also returns a value, which appears to be the number of bytes in the file. This gets stuck at the end of your file.

lcImage = getwordnum(filetostr("myfile.txt"),1,">") + ">"
=strtofile(lcImage,"myfile.h")

hth,

Hank

barrymavin
2013-12-11, 20:31
In Lianja you don't need to say:

=base64_encode_file("mypathedfile.png","png")

Just omit the =

base64_encode_file("mypathedfile.png","png")

HankFay
2013-12-11, 22:14
Yes, I'm aware of that; similarly in VFP. It's a reminder to me that there is a return value, in case I really should be doing something with it.

thanks,

Hank