webp is a nice alternative to gif, especially when animated. I noticed up to 10x smaller files and it has more than 254 colors. (no dithering)
I wrote a script using python 3 + PIL to combine exported Images from grasshopper into one webp file.
Everything works so far, but there is a Problem with the export of the images: I used animation controller by @fraguada to generate the images but, during saving the image counter seems to reset and because this value is used to drive the gh animation nothing happens.
Has anyone an idea why this might be?
hm, I am really confused by this. See this screen capture. All grasshopper geometry is drawn in the rhino viewport, the data recorder shows no abnormalities but it doesn’t show up in the exported images.
even more strange when I set a static value to control the GH geometry it does show up, meaning it’s not a viewmode problem:
Yes, that’s the same result that I got yesterday. I recon there’s something wrong with the C# script. Either it used some kind of “exploit” to make this work that was fixed/updated, or something in the API changed and it thus doesn’t work anymore. It could be a minor detail, that doesn’t cause an error.
Yes, that’s what I gathered. To be honest, I don’t know enough about the “display pipeline” to even imagine how this works (and the C# editor is a nightmare to work with on macOS).
On line 46, var bitmap = capture.CaptureToBitmap(view); captures a bitmap from view. view is defined as the active Rhino viewport on line 33, and capture as Rhino view capture on line 34.
On line 54, bitmap is finally saved.
Maybe you could translate it to Python and debug it line-by-line in order to find the bug? I could help you with that, if you have specific questions.
Or simply wait for the author or another C-Cool wiz to turn up and save the day!
Currently the c# component doesn’t capture the grasshopper geometry properly.
It fails to progress the animation for some reason.
WebPmaker_simplified_v2.gh was indented for discourse.mcneel since it doesen’t requre the use of external python and the PIL library. The output of WebPmaker_simplified_v2.gh are X number of .pngs. These Pngs will be combined by "webpmaker.py" externally into one animated image. In the end this will hopefully be a one-click operation where you set the all the parameters in GH and only hit “toggleRun” once to start the process.
( my bad: the name _simplifed implies it has the same functionality as the one from post 1 but actually it contains a part of the original definition; for better testing )
The trick was to separate the c# script into two: one for advancing the animation and one for saving the images.
To use you’ll have to install python, PIL and download the new, attached webPmaker.py.
I would consider this script WIP, there might be bugs.
EDIT: I just realized that discourse doesn’t allow for webp images to be used Well, I hope this is useful for someone nevertheless. In comparison to loading all images into PS layers and exporting as a animated gif this is much quicker, gives nicer results and smaller filesizes ( 170kb vs 2mb)
I think I figured this out – the problem was that Grasshopper computes the viewtoBitmap command before the preview geometry is displayed. To fix it send it to the top of the stack by selecting the cluster and pressing crtl +F (or under edit > arrange> put to front)
Credit goes to @DavidRutten, who answered it a while ago here.
Since discourse.mcneel will not allow for .webp images until there is support for it for every platform I added the option to export traditional .gif files as well.
I tried to run this today and everything seems to work except the final stage of converting the PNGs to a video file. I’ve tried to trace it back and get this error in the sorting routine.
>>> print(sorted(pngfiles,key=lambda x: int(os.path.splitext(x).split("_"))))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 1, in <lambda>
ValueError: invalid literal for int() with base 10: 'Files\\Grasshopper'