• Become a Power user Intro to AutoHotkey Intermediate AutoHotkey Intermediate Objects GUIs are Easy w/AutoHotkey Painlessly switch from V1 to V2

Work with images but not have image files- Base64 to the rescue!

Here are the files for to work with images but not have image files

How to work with images but no image files
How to work with images but no image files

The key idea of the video is to demonstrate how to encode and decode images using base64, allowing for the storage of images as plain text within a script instead of separate files.

  • 00:00 Learn how to encode and decode images using base64, allowing you to store them as plain text within your script instead of separate files.
    • Learn how to encode and decode images using base64, allowing you to store them as plain text within your script instead of separate files.
    • The speaker discusses a base64 function that can be used to convert an image file into a text variable, which can then be displayed in the debug window or a message box.
    • The speaker demonstrates how to convert image files into alphanumeric encoding using base64, and questions why the encoding often ends with equals equals.
    • Comment out and borrow code, then move it up to get downloads for all the stuff from the URL.
  • 03:42 The video explains how to encode and store an image file using the “encode write read” function, and demonstrates how to read and write to a text file to work with images.
    • The speaker explains how to use a function called “encode write read” to encode and store an image file, and then read it back.
    • The video demonstrates how to easily set up reading and writing to a text file to work with images.
    • xmas equals right because the extension and full path were removed, and the base64 is now displayed wider.
  • 06:39 Convert images to base64 text and store them as variables to work with images without actual image files.
    • You can store images as text files or variables in your script, allowing you to work with images without actually having image files.
    • Convert image to base64 text and store it as a variable.
    • Pass the base64 text to the basics for function to store the value, then pass it to my image and run it to see the result.
  • 09:34 The speaker shows how to work with images by generating code for customization, breaking down base64 strings, and working with image files obtained from a forum post.
    • The speaker demonstrates how to work with images by generating a code that can be copied and pasted into a script, allowing for customization of the image size.
    • The speaker explains how to break down a base64 encoded string into smaller parts and store it as a variable in an autohotkey script, and also mentions that in the next part of the video they will discuss two approaches to displaying a base64 encoded text as a picture.
    • The speaker demonstrates how to work with an image file that was obtained from a forum post, specifically focusing on the image labeled “ro1” and mentioning the presence of text and shapes.
  • 13:08 The speaker shows how to work with images using the gdi library, without saving them as files.
    • The speaker demonstrates how to work with images using the gdi library, initializing it with the startup function and utilizing two other functions.
    • The speaker demonstrates how to display images without saving them as files using a gdi library.
  • 15:14 The speaker explains a fix for errors in using the fix ie function by storing the variable ver and reverting back to the original version after activation, and also mentions the convenience of using the browser to decode base64 encoding, while emphasizing the importance of using vwb to tie together wb and make working with gooeys easier.
    • The speaker explains a fix for errors in using the fix ie function, which involves storing the variable ver and reverting back to the original version after activation, and also mentions the convenience of using the browser to decode base64 encoding.
    • The vwb is used to tie together the wb and if it is not used, working with gooeys would be more difficult as the v is stored as a variable for later use.
  • 17:03 Adjust image size using HTML and GUI, and display content without saving as a file using base64 encoding and libraries like gti or ie activex window gui.
    • Control the size and width of an image using HTML and GUI, and adjust the dimensions by setting either the height or width.
    • You can display content without saving it as a file using base64 encoding and either the gti library or the ie activex window gui.
  • 19:26 You can ask questions if you need help with the topic, as the speaker has some experience with it and would like to hear your thoughts and alternative approaches.


hey it’s joe lyons from the automator and in this video i’m going to show you about base64 encoding pictures both how to encode them and how to decode them and so first off why in the world would you care about this well one thing is often we want to share files you know we’ll write a script we want to share files with people we don’t want to have have to have them download pictures and this is one way to take your picture and encode it in a way that becomes text uh it’s an alpha i’d say it’s readable
but it’s of course not really readable to humans but we’ll see here in a minute what i mean by that but it makes it where you can store it in a file that’s plain text in that way it could be inside your script or you can there’s a lot of other benefits to this but being able to have it as just text allows you to include it in your script instead of having a separate file which i think is pretty awesome let’s start off here let me jump over to my page oh don’t forget to like and comment if you know you
didn’t understand something in this video or you want to see more about this kind of stuff but please like and subscribe it helps me a lot thank you now back into here okay so i initially found let’s look at this this base64 function was written by scan now the thing is i went and looked at this link and my version is slightly different and i can’t remember why i think masteries went in and did some tweaking to it but i honestly don’t remember it was years ago but what happened so so we’re not going
to go into the how it works you can see it it does some stuff with the dll call and looks at it whether it’s if it’s a unicode or not and if it is it does one thing if it’s not it does another this is a little text file i have on my computer and let me show let me let me find that okay i’m going to bring over the whole thing here so this xbox.
gif that’s what this file is look at here oh yeah it’s tiny i’ll zoom in but you get it it’s a tiny little smiley and that’s the file that’s this is the path to it so we’re going to use this base64 function and we give it the path so this is very very simple to use right and i’m going to store it in this text variable and then we’re going to display it in the debug window in site which is down here i could put in a message box but it’d be pretty ugly uh maybe we’ll do that yeah let’s do both but after it
does that we’ll put it up in a message box so we can see both so i’m gonna get my hotkey to launch it now it goes and reads that file this is what it converted it to right so i took that picture file and converted the binary picture into this alphanumeric encoding which is base64 encoded and i just replaced you know everything with a certain character so then it could decode it later often and i don’t understand why maybe make sure that someone could explain to me or maybe someone here can comment on
the video as to why in the world it has the equals equals at the end often it doesn’t always but often it ends in equals equals uh so let’s hit okay here but let me show you here if we move this over you can see it a bit better so here’s that text right the same text it’s just you can get an idea of how long of a string is which is a little problematic i’ll explain why in the second part of this video but i wanted to first demonstrate just how easy it is to pass a file to it and here i’m using a picture but i think
you can pass a pdf or something else and it would probably work just as well because it’s encoding that file and um the next thing we’re going to do is i’m going to comment this out and that out and now i’m going to borrow because i have this down here and i’ll um you know when you go to that url you’ll get the downloads for all this stuff here let me let me move this i’m going to cut it and move it up here i just didn’t want to distract you at the beginning part so here we’re going to use the second function
now this is a function i wrote called encode write read and we pass it the here i’m using taking advantage of the local path so i should really pass this full path but here still we’re in that folder anyway so it’s going to use the same file we’re passing it to it and here’s what it does so it says okay let’s use this encoder read function which is this one it jumps in here now the file name if you notice right here i’m splitting i use split path command to get the file name and i’m sorry that’s the the input
variable this is what we passed to it the o name i’m saying o is out out name the um and then here is the out name known extension right so i’m storing these two as variables that i can later use and so this out name no extension comes in very handy so right here i use the any right and so this any right it’s gonna uh first i call that base64 function with the file name right so that gets passed through from the beginning uh it i just gave a generic uh this is the oh sorry that’s the name of the file to
store it in this is the section if you’ve worked with any files i have a video on that somewhere but they’re they’re really cool and then we’re passing this the name no extension so it’s just going to store it as xmas uh inside there and then after we write it i’m reading it now that i wouldn’t use this clearly i wouldn’t i wouldn’t probably use this this way in the script i just want to demonstrate how easily you could set this up to read and write to a text file so let’s go back to here’s this
let’s get rid of that text file because i believe that is uh what we’re reading and writing to yeah images.txt so i’m going to save this we launch it now i’m going to hit my hotkey and now what’s going to happen is it’s going to generate that text file and then after it writes it it’s going to read from it it’s going to read the content and we’re going to see it in the output window again so theoretically this output should be the same so i’m going to hit my hotkey here’s my images.txt
and here we see that output which is what we had seen before now let’s go into here and open this file up oh other screen of course and notice there’s one file notice it says xmas equals right because that’s what we took we got rid of the extension and and the full path it’s just xmas equals and then this is the base64 now notice how wide this is right it’s super wide in the site i could uh i think turn up the options to uh let’s wrap it and now we can see it kind of looks more like it does in
the other window right but this is the way that we could easily store this to a text file unfortunately without a hotkey if i dumped this into an auto hockey script because this one actually i think might be okay but things over 16 000 characters can’t handle it because uh you need a continuation section so for that i have a different solution and let’s go ahead and jump into that one but hopefully you get this idea of let me go back to studio here we are calling the function so this calls the function with xmas
dot gif as the diameter we’re passing right so if i had a different image in that folder i could just change this and it would rip off the extension and then it would store it in the txt images.txt file as the this front part name so that would be the name of it and then i go and read it and so this would again allow you to have images that you’re using in your script but not actually have them stored as files which i think is really cool now in this example here we’d be having them as a text file
so maybe you don’t want to do that and that’s where the other example i’ll show you here in a second where we could actually save it as a variable and it’ll break it if it goes over 16 000 characters because if if this one goes over 16 000 characters uh it wouldn’t i wouldn’t be able to write it straight to an autohotkey script right so now we’re going to open this convert image to base64 text break into sections so i’m just going to drag this in the studio and here we’re working with this same
file so this is still the same path and we’re going to pass it to the base64 encoding function now here in this example of that sorry that’s still the same one that we used in the in the other example right but then i take the results of that which here is this long text and we’re going to pass that to break for storage as var right this is what i wrote the default is sixteen thousand uh but of course this is where i’m calling the function down here is where i have the default set of sixteen thousand uh the the variable name the
default name will be image because we got to give it something to store it as and then here’s just nothing as far as uh that’s the text you’re going to be passing to it right the the base64 value so starting from here we read it back into here we get the base64 text right so sorry this is the file path pass that to the basics for function this is going to store this value here then we take this and we’re going to pass it and we need this my image and here it’ll be easier to show you by example right
of what it’s doing so if we start off with 16 000 i run this now notice there’s no line breaks in here right so there’s just the one my image now let’s first off let’s start here let’s say let’s call this i save and we launch it and notice it’s just i colon equals that right so at the end of this we would have a we can copy this and i think actually in my function let’s take a look if we scroll down here yeah at the clipboard the end of this i dump into the clipboard that value which
you could then paste into your script so it would have that as a way to to already on your clipboard to paste into your script but let’s say um this will be let’s say xmas that’s fine so here we gotta run it xmas equals that now what if for some reason let’s say we didn’t want to have a really really wide script we wanted to paste something in the form let’s say we wanted it like 160 characters instead of 16 000 right so let me relaunch this and run it now notice here in our output let me see if i can scroll out something
here notice there’s a bunch of these and these are going to you know be like a continuation section so when you dump this into your autohotkey script it’s going to uh you know append to each one and and build up over time so let’s make it more like a 100 maybe there we go that’s just a lot easier to read right so you now i think you can easily see how at the end of this if we were to copy this and we’re gonna paste it right here all right paste and then do a message box of xmas and let run it now this time this is
where i’m running it just up here right so it it takes all of that and shoves it into one thing which was the original uh base64 encoded string value right so this is a nice convenient way that you can easily break it down uh let’s get rid of this so we don’t mess up our script so we can break it down to depending on how many characters you want to break on and it just you know parses it for you breaks it up and then you can dump it into your script and again this is a nice way where you can store this inside your
autohotkey files now that’s why i also mean this as a variable because you might do this several times and have different images you know stored in your auto hockey script and this makes it simple because otherwise you would have uh let me relaunch it run it we would have to replace the xmas here on every one of these 15 times right so that’s why do putting this here makes that a little simpler now in the next part of this video we’re going to finish this up with two approaches how to display a base64
encoded text as a picture which i think is really cool so let’s jump into that okay now for this last part we’re going to bring in this file show image without saving so this is i think is pretty cool i got this first one from swag he posted on the forum i’m not making that name up anyway sorry this cracks me up and uh you can see here we have the image this is the that same ro1 we still have it below here from the xmas one right r01 blah blah blah it looks like almost ro and god and then to the far right here it ends in that
qqao w equals qqaow equals right so we’re going to first demonstrate on this one now this is where i was reading from the image file and let’s see i don’t know if i have images text shapes oh i had a different one here in this example but we’ll we’ll play this in a second now this does require the gdi library and i think i think that’s the short code for it i’ll just make sure the gdip for gdi plus is where you can get the gdi library and you’ll download that make sure you put it i would put in your library because
it’s a it’s a great library to have access to and we’re going to first initialize the gdip library by this startup and then we’re going to use these two functions now actually i have borrowed this from somewhere but i could now that i remember here in his in swag facts thing these were in two separate calls i think i i realized hey why have this on two lines i’ll just shove it all into one command and this creates this hbm i’m not sure if that’s an h bit map oh well here it says h bitmap so i guess that’s
what it is and it’s going to display the picture so let me save this and run it and there’s the picture right now what’s really cool about this you got to think about this right that picture is not stored somewhere i mean you know it is right now though it’s pulling it from here or let’s say let me go back and get i had this here this is that if we had this let’s say if it was too wide instead of that one i’m going to say xmas so this is just taking it here this is where if it was over 16 000 characters right and uh this
what does changes to be xmus and reload and run and there it is so hopefully you get that idea how cool that is so you could have this stored inside your active script and show pictures but i think is pretty cool now that’s the first first way that we can display images without saving them as files it requires a gdi library which is not a big deal let me get rid of all that just because it took up a lot of a lot of space there we go okay now i’m going to comment all this out and we’re going to scroll down a bit
here’s the second approach now may striath taught me this this fix ie i have a download for that let me let me take a look at what that one is okay so that the you can get the fix ie function here at the automaton.com fix ie i’m very original in my naming conventions and basically this is if you’re getting errors you know you can apply this now i’ve commented this out and it works fine however matrix was saying you know what it’s better to have it in there and notice here also where we first store
this into a variable called ver and after we activate it we restore fixed id we restore it back to its original version right so if you’re not using this line you don’t need this line but if you are using this line then make sure you have this line because uh otherwise it would change it and not revert back because the activex by default is like version seven and so things can break because you know version seven of ie was wow pretty pretty low and what’s really cool about this is that you’re using your browser to decode
that base64 encoding which i think is just also really cool because it takes the the work out of our hotkey and just lets the browser do it for you and so uh what you do here is we’re saying let’s say uh add an activex window and here um i’m passing it to the vwb which later i think yeah this is where the wb comes from right this vwb you know let me uppercase these two to help help it tie it together that’s these wb here right and if we didn’t have that it would uh if you’re new to gooeys and i don’t even
work with gooeys a lot but it would be very this this whole thing the v it says stored as a variable for later use so you take you when you go to use it you drop the v so i know that’s weird but you do um anyway and we’re controlling the size and width and the fix then we navigate to basically create a new window so we can pop it open now i also commented this out for fun uh we’ll demonstrate all the stuff here in a second now here’s where the magic sauce is right we’re going to you need this tag this whole html entire
jpeg bar and image that’s the variable uh that’s what we’re going to be displaying which actually we do need to re-enable that so i’m going to save that that’s what’s getting used here and you know here i said the width of 20 um this you can adjust this is h the here through here you can see it’s html right and then the gui is going to show it so let me save this and run it i have my hotkey and here it is right so that’s displaying it now let’s say we wanted a width of let’s say
50 reload run notice now it got bigger right uh not a shocker uh and i think if you just set one it’ll do both but if you you could set height and width and then you could make it kind of squishy but if you just set one it’ll automatically adjust the other if you don’t mention the other one and let’s see what else we did now as i mentioned i’m going to comment out that and [Music] that and save and reload and run so see that on my computer right now that still worked fine and then also i’m going to comment out these
two so i’m going to comment out that and that so save reload run and it still displayed it now that one and and i got to think make sure it knows the stuff that’s there for a good reason but every time i tested it it came up just fine so i don’t know if you have to always you know wait for it to be displayed before you populate it maybe it happens so maybe i have a i do have a very fast computer with a m2 drive uh so it’s it’s a very fast drive and it’s stored in ram and there you know everything
so maybe that’s why it works without those but i just want to demonstrate these are two ways you can display the content without saving it as a file and so you could have this base64 encoding and either use the gti library or the ie activex window gui and it’ll render for you so i think that’s pretty awesome hope you enjoyed that and let me know if you have any questions on the stuff it a lot of this is kind of outside my wheelhouse but you know i played with it enough to have a decent idea now but i’d love to hear
your thoughts and let me know if you have a different approach hope it helps cheers

Comments are closed.