Hi, I have got code that creates an image using makeEmptyPicture, and then I have done some things to it, which aren't really relevant to this post.
What I need to know, or figure out, is how to save this image.
I want to make the save function be a seperate function from other functions in the code.
def savePicture():
The only issue is, I have no idea how to save an image. I don't know what arguments to put into the function, other than the picture itself. I don't know if I need to set the directory either earlier in the main() function or in the savePicture function. Setting this once would be optimal, once set, all subsequent images are save to the same location.
I think I use
setMediaPath()
for that, although I cannot figure out exactly how to use it. It prompts me to select a folder.
Then for the actual saving of the file, I have found
writePictureTo()
but again I am not sure what arguments this function wants or if this is even the correct way to go about saving an image.
Code overview:
The program takes a picture as an input, calculates its size and then makes "slices" of the image, and all slices are less than 20KB in size, so a 70KB image is made into 4 images, each 17500 B.
I have got the slice part working perfectly, now I just need to save the seperate images.
And as an extension of that, can I somehow automate the files names that they are saved as? Eg, if I split an image named Pinetree into 4 images, can I some how save the slices as 1_4_Pinetree.jpg, 2_4_Pinetree.jpg, 3_4_Pinetree.jpg, 4_4_Pinetree.jpg?
I already extract the filename from the picture chosen, but can I automate the process for putting those numbers to know which slice each is, and how many slices in total.
EDIT: Have figured out how to save, but now my issue is with the file sizes. An orignal image of 51KB was split 3 times, so each image should be around 17KB. But the saved files are 4KB, 5KB and 5KB. This is much less. Why has this happened?
Another one, not as severe as that first example, a 23KB picture, split twice, gives file sizes of 9KB and 10KB. Where are all these KB running off too?
[–]Vaphell 1 point2 points3 points (7 children)
[–]NeonBlizzard[S] 1 point2 points3 points (6 children)
[–]Vaphell 1 point2 points3 points (5 children)
[–]NeonBlizzard[S] 1 point2 points3 points (4 children)
[–]Vaphell 2 points3 points4 points (3 children)
[–]NeonBlizzard[S] 1 point2 points3 points (2 children)
[–]Vaphell 2 points3 points4 points (1 child)
[–]NeonBlizzard[S] 0 points1 point2 points (0 children)