1
00:00:01,790 --> 00:00:10,760
OK, so we're getting closer to saving our image here, we've picked the file extension, we can grab

2
00:00:10,760 --> 00:00:13,580
the file name using this file dialogue box thing.

3
00:00:13,940 --> 00:00:17,690
We can make sure it ends in PNG even if we didn't type in PNG.

4
00:00:17,990 --> 00:00:19,450
Now we need to actually save it.

5
00:00:19,460 --> 00:00:22,800
And this is kind of tricky, right?

6
00:00:22,990 --> 00:00:29,270
A, it's a little difficult to save canvas images as image files.

7
00:00:29,480 --> 00:00:32,240
There's a lot of different convoluted ways to do it and doing it.

8
00:00:32,250 --> 00:00:34,170
We're going to use something actually pretty easy.

9
00:00:34,310 --> 00:00:38,270
What we're going to do is take a snapshot of our entire program.

10
00:00:38,280 --> 00:00:45,380
So if we come over here and run this guy again, we're going to take a snapshot of the entire thing

11
00:00:45,890 --> 00:00:52,400
and then we're going to subtract out the width of the actual program versus the width and the height

12
00:00:52,580 --> 00:00:54,080
of the actual canvas.

13
00:00:54,260 --> 00:01:00,620
So we're going to say take a screenshot of everything, but just sort of this area.

14
00:01:01,220 --> 00:01:05,540
And we can do that by, like I said, just taking the width and the height of the program, subtracting

15
00:01:05,540 --> 00:01:07,330
out the width in the height of our canvas.

16
00:01:07,490 --> 00:01:12,920
And that's how we'll know what to take a screenshot of and then we'll just save that screenshot image.

17
00:01:13,130 --> 00:01:13,490
Right.

18
00:01:13,700 --> 00:01:16,240
So to do that, we need a graphic library.

19
00:01:16,400 --> 00:01:19,280
And the one I like to use is something called Pelo.

20
00:01:19,460 --> 00:01:28,190
Now, hello, is P l, but PILT has been sort of discontinued and they've re continued it as a different

21
00:01:28,190 --> 00:01:32,170
version called Pelo and we have to actually pip install that to use it.

22
00:01:32,180 --> 00:01:33,760
So that's we're going to do in this video.

23
00:01:33,770 --> 00:01:40,520
Let's close this out, head back over to our terminal and to do this we just go pip install Pelo and

24
00:01:40,520 --> 00:01:42,100
this is a capital P, right.

25
00:01:42,440 --> 00:01:43,550
So I've already installed it.

26
00:01:43,550 --> 00:01:49,780
So it's saying you've already got it, you're good, but you will download and install.

27
00:01:49,790 --> 00:01:51,710
Now some people have trouble with Pelo.

28
00:01:51,830 --> 00:01:53,840
If you're on a Mac or Linux, you may have trouble.

29
00:01:54,110 --> 00:01:56,660
And when you try and run this, you might get an error.

30
00:01:56,840 --> 00:02:00,470
You're just going to have to Google the error or you can contact me and I'll try and walk you through

31
00:02:00,470 --> 00:02:01,640
it, too, and we'll try to figure it out.

32
00:02:01,640 --> 00:02:05,390
Every computer is a little different and pillow's a little finicky on some computer.

33
00:02:05,390 --> 00:02:07,670
So some people just have problems with this.

34
00:02:07,920 --> 00:02:08,870
Hopefully you won't.

35
00:02:09,020 --> 00:02:11,440
But like I said, if you do, contact me and we'll figure it out.

36
00:02:11,600 --> 00:02:16,190
So now we've got this thing we need to import it into our program.

37
00:02:16,190 --> 00:02:18,200
Now, there's a couple of ways to do this.

38
00:02:18,650 --> 00:02:22,220
I would just first go port p l all capitals.

39
00:02:22,550 --> 00:02:22,910
Right.

40
00:02:23,420 --> 00:02:25,700
But we also need a few things from here.

41
00:02:25,700 --> 00:02:29,690
So we're going to go from P l import.

42
00:02:30,560 --> 00:02:34,130
Image, karma, image, draw.

43
00:02:34,980 --> 00:02:37,260
And image grab.

44
00:02:39,170 --> 00:02:43,130
And I don't know if we're actually going to need it, but for good measure, I'm also going to import

45
00:02:43,130 --> 00:02:43,940
image.

46
00:02:46,320 --> 00:02:55,320
T k, capital T. Lowercase K, right, so image grab I and G or capitalize, image, draw I and D or

47
00:02:55,320 --> 00:02:59,030
capitalize and with image just the eye is capitalized.

48
00:02:59,460 --> 00:03:02,880
So OK, I think that will do it.

49
00:03:03,420 --> 00:03:05,190
Or you may or may not need to do this.

50
00:03:05,190 --> 00:03:12,180
But like I said, Pelo is a little finicky, so I'm just going to do that anyway and we'll see if we

51
00:03:12,180 --> 00:03:13,140
actually need it or not.

52
00:03:13,140 --> 00:03:13,410
So.

53
00:03:13,590 --> 00:03:19,380
All right, let's head down here to our save function, and this video is actually getting a little

54
00:03:19,380 --> 00:03:23,760
bit longer already instead of diving into all this code, I think we're going to stop for this video.

55
00:03:23,760 --> 00:03:28,350
And the next video will pick this right up and we'll write the actual code to save our image.
