de en es fr
Let the machine help
Light teasing, exhibition, BDSM, sissyfication, watersports... with sounds and pictures


Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Random images (SOLVED) - UPDATE
PostPosted: Wed Aug 31, 2016 3:16 pm 
Offline
Veteran
For those who would like to get a more clean function here it is:

Code:
def setRandomImage = { folderName, imagePrefix ->
   def folder = new File(System.getProperty("user.dir")+"/images/(Your project name)/"+folderName+"/")
   def fileArray = folder.listFiles()
   def numberOfImages = 0

   for (def i= 0; i < fileArray.length;i++){
      if(fileArray[i].toString().contains(imagePrefix)) numberOfImages++
   }   
   setImage("(Your project name)/"+folderName+"/"+imagePrefix+(getRandom(numberOfImages)+1)+".jpg")
}


To call it simply write:
Code:
setRandomImage("(The folder in your project the images are in)", "(The prefix of the images)")


If you want to find any image in a given folder use this function:

Code:
def setCompletelyRandomImage = { folderName ->
   def folder = new File(System.getProperty("user.dir")+"/images/(Your project name)/"+folderName+"/")
   def fileArray = folder.listFiles()
   setImage(fileArray[getRandom(fileArray.length)].toString())
}


And to call it:
Code:
setCompletelyRandomImage("(Folder from which you want a random image)")



________________________________________


Hello

A similar question has been asked before, but I was curious to know if there is a way to display random images from a folder without knowing how many images are in there. like setImage("folder/image*.jpg") where there might be 2 or 6 images in the folder.


Last edited by cd228 on Tue Sep 06, 2016 11:59 am, edited 4 times in total.

Top
 Profile Send private message 
 
 Re: Random images
PostPosted: Wed Aug 31, 2016 4:19 pm 
Offline
Veteran
Solved it!:D

For others who wants to do the same, this is how I did it.

Code:
def setImageAI ={ name, pic -> //Takes name (of mistress) and pic (the type of prefix)
def folder = new File(System.getProperty("user.dir")+"/images/(YOUR PROJECT NAME)/"+name+"/")
def fileArray = folder.listFiles()
   
def numberOfImages = 0
for (def i= 0; i < fileArray.length;i++){ //Sorts through all the files in the folder
   if(fileArray[i].toString().contains(pic)) numberOfImages++ //if there are files with the prefix in it increase the number
   }   
setImage("(YOUR PRJECT NAME)/"+name+"/"+pic+(getRandom(numberOfImages)+1)+".jpg")
}


and to initiate the function:
Code:
setImageAI("Michaela", "breasts")


This will basically take a folder named Michaela, sort through all the files, and every time it encounters a file which contains the name "breasts", it will increase the variable called numberOfImages.
After that you can simply setImage to a random one containing that prefix.

I just have a folder called Michaela, and the several files called breasts1, breasts2, ass1, ass2, ass3, etc.
No matter how many files you have of one type, the function still chooses a random image from those with that prefix.


Top
 Profile Send private message 
 
 Re: Random images (SOLVED)
PostPosted: Wed Aug 31, 2016 8:22 pm 
Offline
Veteran
User avatar
Cool 8-)

Thanks!


Top
 Profile Send private message 
 
 Re: Random images (SOLVED)
PostPosted: Fri Sep 02, 2016 12:33 pm 
Offline
Veteran
arthurb wrote:
Cool 8-)

Thanks!

No problems.
I think it can be a useful feature in other projects, as you do not always know how many pictures are in a future expansion.
My project farkel was kind of limited by the fact that I needed to match all images of different models. Now I can just add images without worrying about the number:)


Top
 Profile Send private message 
 
 Re: Random images (SOLVED)
PostPosted: Sun Sep 04, 2016 2:56 pm 
Offline
Veteran
User avatar
Well done, mate! I wanted to do this myself several times and had asked before, but nobody else seemed to be able to figure it out and it was marked as "not possible" (i.e. you needed to know how many images). Having a workaround for this is awesome, thanks for sharing!


Top
 Profile Send private message 
 
 Re: Random images (SOLVED) - UPDATE
PostPosted: Tue Sep 06, 2016 1:06 pm 
Offline
Veteran
Check first post for update


Top
 Profile Send private message 
 
 Re: Random images (SOLVED) - UPDATE
PostPosted: Tue Sep 06, 2016 3:07 pm 
Offline
Site Admin
User avatar
This is good and should work.
I think the name of the pictures must be :
Code:
prefix1.jpg
prefix2.jpg
prefix3.jpg
...


So the name starts with 1, no 0 (like 01, 02...), ends with ".jpg" and not ".jpeg"


Top
 Profile Send private message 
 
 Re: Random images (SOLVED) - UPDATE
PostPosted: Wed Sep 07, 2016 6:28 pm 
Offline
Veteran
doti wrote:
This is good and should work.
I think the name of the pictures must be :
[code]
prefix1.jpg
prefix2.jpg
prefix3.jpg
...
[code]

So the name starts with 1, no 0 (like 01, 02...), ends with ".jpg" and not ".jpeg"



Precisely. Except in the second function, where it will pic any random jpg in the folder


Top
 Profile Send private message 
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Maroon Fusion theme created by Oxydo
Software, theme modifications, phpBB modification by Doti 2010 - 2020
This website uses session cookies only.