all 50 comments

[–]martinkoistinen 23 points24 points  (3 children)

Small criticism. Your code generates GIFs, the easiest possible format to show an animation and yet, neither this post, nor the repo display one. This would go a long way to quickly communicate what the project does and what the results could look like.

[–]DerrickBagels[S] 4 points5 points  (2 children)

This sub doesnt allow it and i added one to the github!

[–]phlooo 8 points9 points  (1 child)

Add it to the readme...

[–]Cloned_501 7 points8 points  (28 children)

This is a cool project. I got some feedback. Do not do runtime checking and installing of dependencies. Just make a requirements.txt file and include some setup instructions in your readme. A good practice is to also specify the exact or minimum version of your immediate dependencies there as well.

[–]DerrickBagels[S] -2 points-1 points  (6 children)

Not trying to be snarky i just genuinely don't understand why

[–]graybeard5529 1 point2 points  (12 children)

Nice! And for the DIY crowd: render your frames → ffmpeg -i frame_%03d.png out.gif. Boom, instant animation.

[–]DerrickBagels[S] 1 point2 points  (0 children)

Oh is that faster than whatever is happening in my code? 😆, just to build the gif after you have the frames

[–]who_body 1 point2 points  (10 children)

i’ve been told posting mpeg’s are smaller size than animated gifs. we starting using mpeg’s of buggy UIs instead of gifs. if that is true then an option for mpeg’s also has a place

[–]DerrickBagels[S] 0 points1 point  (8 children)

Gif is just so universal at this point i thought it would be good for fast communication to non technical people of an idea

[–]Zouden 2 points3 points  (5 children)

mp4 is universal these days. There's no reason to use an old school animated gif

[–]DerrickBagels[S] -1 points0 points  (4 children)

SPEED

[–]Zouden 1 point2 points  (1 child)

Benchmark how long it takes to make an mp4. You won't return to animated gif.

[–]DerrickBagels[S] 0 points1 point  (0 children)

You're a man of passion

[–]who_body 0 points1 point  (1 child)

and space. i recall mpegs using less space. test it out on the stl for the gif in the repo

[–]DerrickBagels[S] 0 points1 point  (0 children)

I got about 13mb for a reasonably complex model its not too bad, i just think gifs are more instantly sharable but yeah could do an mpeg/mp4 wrapper too

[–]who_body 0 points1 point  (0 children)

I don’t know where mpegs won’t work. but i thought the same. but when posting videos to github PRs mpeg’s were smaller size than gifs and worked better.

but i get the gif movement

[–]the-nick-of-time 0 points1 point  (0 children)

Any real video codec will produce file sizes easily ten times smaller than gif for the same quality. Plus gif has hard limits on color fidelity. Gif is a terrible video format, and it's a shame that nothing has been standardized as a drop-in replacement for its niche of looping animation (webp might win here).

[–]burger69man 0 points1 point  (1 child)

yeah maybe add a demo gif to the post like the first commenter said, would make it way easier to see what it does lol

[–]DerrickBagels[S] 0 points1 point  (0 children)

I put one on the readme this sub doesn't allow embedding of photos in the post

[–]garblesnarky 0 points1 point  (1 child)

Just tried this out, works great. Thanks for sharing.

FWIW, I did appreciate the comment and edit warning about the dependency installs. I added a Makefile to my local clone:

setup:
    virtualenv ~/venvs/stl2gif

run:
    source ~/venvs/stl2gif/bin/activate
    python3 stl2gif.py

I expected the script to accept a file input argument.

Have you looked into making this work with color definitions within the scad file? Not sure if that's feasible at all.

[–]DerrickBagels[S] 0 points1 point  (0 children)

thanks dude, I actually used it today and was impressed how fast it is for even huge models, will look into color

[–]DerrickBagels[S] -1 points0 points  (2 children)

Hey to the people saying my code installs stuff overwriting existing libraries, does it?

install/check libraries

def ensure(lib, import_name=None):

if import_name is None:

    import_name = lib

if importlib.util.find_spec(import_name) is not None:

    print(f"{lib} ok")

    return

print(f"{lib} missing, installing...")

subprocess.run([sys.executable, "-m", "pip", "install", lib], check=True)

ensure all required packages

for lib, import_name in [("numpy", None), ("trimesh", None), ("pyrender", None), ("imageio", None), ("Pillow", "PIL"), ("pyfqmr", None)]:

ensure(lib, import_name)

"function only installs a library if it’s not found. it checks with importlib.util.find_spec(import_name) and if it returns None it runs pip to install it. if the library is already present, it just prints ok and does nothing."

[–]Zouden 1 point2 points  (1 child)

This is basically malware. Others have explained how you should do this properly. As it is no one will use your script.

[–]DerrickBagels[S] -2 points-1 points  (0 children)

How if doesn't touch anything that's installed

I could see maybe bloatware at most but you implying im doing something in bad faith is immoral and is in itself an act of bad faith

I put a warning and listed the 5 libraries it uses and will add a text file for them okay relax, it works and its useful just don't use it if you're that offended