I wonder what keywords you used on 'google' when trying to find these scripts? btw the script you used is very short, is it everything what has to be done in Illustrator, run it on an image?
mySelection = activeDocument.selection
if (mySelection.length > 0) {
if (mySelection instanceof Array) {
goal = mySelection[0]
centerPoint = goal.position[0] + (goal.width / 2)
centerPointVert = goal.position[1] - (goal.height / 2)
for(i = 1; i < mySelection.length; i++) {
currItem = mySelection[i]
centerPoint = currItem.position[0] + (currItem.width / 2)
centerPointVert = currItem.position[1] - (currItem.height / 2)
ratio = 100 / (goal.width / currItem.width)
ratioV = 100 / (goal.height / currItem.height)
newItem = goal.duplicate()
newItem.position = Array((centerPoint - (goal.width / 2)), (centerPointVert + (goal.height / 2)))
if (ratio < ratioV) newItem.resize(ratio, ratio, true, true, true, true, ratio)
else newItem.resize(ratioV, ratioV, true, true, true, true, ratioV)
newItem.artworkKnockout = currItem.artworkKnockout
newItem.clipping = currItem.clipping
newItem.isIsolated = currItem.isIsolated
newItem.evenodd = currItem.evenodd
if (currItem.polarity) newItem.polarity = currItem.polarity
newItem.moveBefore(currItem)
currItem.remove()
}
}
}
Oh true it is suprisingly short!
I tried many different keywords. I think something like "illustrator replace shape" got me to this result.
It got me to this thread where both scripts were linked to by other users:
https://community.adobe.com/t5/illustrator-discussions/replace-multiple-objects-in-illustrator/m-p/8572551
Here is everything I did in order. Also for me as a reminder since I don't use Illustrator much:
Preparation:
1. vectorize the image with Properties > Image Trace
2. play with settings to get it more accurate
Using the script:
1. create a circle (every selected shape will be replace with this circle)
2. select all objects that should be replaced
3. then select the circle (the replacement) last
4. go to file > scripts > zamena_size
(available here: http://illustrator.hilfdirselbst.ch/dokuwiki/en/skripte/javascript/zamena_size)
5. done! In my case it took a few minutes due to the thousands of stars.
The other script works the same way.