Topic: previews for animations

Posted under General

I've been using this site for 7 years. Great indexing. We need previews on all animations. Animated ones would be even better. Otter than that. "Tyrone get your s@#t together"

Updated by Tokaido

The Feature Request Thread is probably better place for feature requests.

Anyway, that has been requested before, and iirc it's one of those hard-to-implement things.

Updated by anonymous

Getting thumbnails for each animation on this website would, imaginably, be too difficult to deal with.

Updated by anonymous

Rayzr said:
Getting thumbnails for each animation on this website would, imaginably, be too difficult to deal with.

tldr: gif and webm would probably be easy (technically speaking) but it just hasn't been done yet, flash would be a pain in the ass to deal with whether it was done automatically or manually.

For gifs and webm it would be fairly straightforward at least. I know some other boorus can do it such as derpibooru, but they don't do flash or webm (at least not that I'm aware of). I don't know how they differ programmatically on the "booru genetic line" or if they are even related (they don't seem like they are except in name), but Toni would probably be the one to talk to about that.

As for Flash, that would probably be really hit-or-miss unless it was done manually. There's a technical limitation since it isn't something that could be automated very easily even if it were technically possible (a lot of flash files don't have any loading screens or they are just blank anyways). There could be a manual way to upload preview thumbnails, but it would need to be handled very carefully to both keep it from being abused and keep a consistent quality (i.e., keep it from looking really half-assed).

Updated by anonymous

Implementing thumbnails for animated files would likely be difficult... The best I could think of would be a sub-gallery where a still frame from the animation is uploaded and used as the thumbnail, with a semi-transparent layer thrown over it to say "WEBM" or "SWF," or even just a lower half completely opaque to say it. This would, of course, mean that people would have to not only upload the stillframe from it, but get it approved by a moderator before it even shows up (Otherwise, it continues to show the default thumbnail for animated files).

Updated by anonymous

parasprite said:
tldr: gif and webm would probably be easy (technically speaking) but it just hasn't been done yet, flash would be a pain in the ass to deal with whether it was done automatically or manually.

For gifs and webm it would be fairly straightforward at least. I know some other boorus can do it such as derpibooru, but they don't do flash or webm (at least not that I'm aware of). I don't know how they differ programmatically on the "booru genetic line" or if they are even related (they don't seem like they are except in name), but Toni would probably be the one to talk to about that.

As for Flash, that would probably be really hit-or-miss unless it was done manually. There's a technical limitation since it isn't something that could be automated very easily even if it were technically possible (a lot of flash files don't have any loading screens or they are just blank anyways). There could be a manual way to upload preview thumbnails, but it would need to be handled very carefully to both keep it from being abused and keep a consistent quality (i.e., keep it from looking really half-assed).

Dunno what e621 runs on (I have this vague memory it's something mildly horrifying), but in Linux, here's a shell script handling GIF thumbnailing using gifsicle:

#!/bin/sh
MAXW=150
MAXH=150

FILENAME="$1"
THUMBNAME="$2"
NFRAMES=$(gifsicle -I "#-1" < "$FILENAME" | head -1 |egrep -o '[0-9]+')
CANVASINFO=$(gifsicle -I < "$FILENAME" |fgrep "logical screen" |egrep -o '[0-9]+x[0-9]+')
W=${CANVASINFO%%x*}
H=${CANVASINFO##*x}
WANTRESIZE=0
if [ "$W" -gt "$MAXW" -o "$H" -gt "$MAXH" ]; then
WANTRESIZE=1
fi
# we want 4 frames [....|....|....|....|....]
STEP=$((NFRAMES/5))
if [ "$STEP" -eq 0 ]; then
STEP=1;
fi
MAX=$((STEP*4))
if [ "$MAX" -gt "$NFRAMES" ]; then
MAX="$NFRAMES"
fi
A="#"$STEP
B="#"$((STEP*2))
C="#"$((STEP*3))
D="#$MAX"
# grab just the 4 frames for the thumbnail
if [ "$WANTRESIZE" -eq 1 ]; then
gifsicle --colors=255 < "$FILENAME" | gifsicle --unoptimize -d25 $A $B $C $D --resize-fit "${MAXW}x${MAXH}" --optimize > "$THUMBNAME"
else
gifsicle --colors=255 < "$FILENAME" | gifsicle --unoptimize -d25 $A $B $C $D --optimize > "$THUMBNAME"
fi

It picks four frames evenly spaced throughout the animation and assembles them into an animation, shrinking the image to fit in 150x150 if needed, and setting frame delay to a constant 1/4 of a second.

Webm should be doable using ffmpeg with similar principles to extract PNG files of particular frames and imagemagick to assemble them into a gif.

Updated by anonymous

Rayzr said:
Getting thumbnails for each animation on this website would, imaginably, be too difficult to deal with.

Anything worth doing is hard

Updated by anonymous

savageorange said:
Dunno what e621 runs on (I have this vague memory it's something mildly horrifying), but in Linux, here's a shell script handling GIF thumbnailing using gifsicle:

It picks four frames evenly spaced throughout the animation and assembles them into an animation, shrinking the image to fit in 150x150 if needed, and setting frame delay to a constant 1/4 of a second.

Webm should be doable using ffmpeg with similar principles to extract PNG files of particular frames and imagemagick to assemble them into a gif.

Cool looking code. A step forward

Updated by anonymous

savageorange said:
Dunno what e621 runs on

AFAIK Ruby on Linux

Updated by anonymous

savageorange said:
it's something mildly horrifying

Lizardite said:
AFAIK Linux

I ran Linux for a couple years.

My toaster still can't toast bread properly anymore. Stupid proprietary drivers.

Updated by anonymous

parasprite said:
I ran Linux for a couple years.

My toaster still can't toast bread properly anymore. Stupid proprietary drivers.

>Not using NetBSD

Updated by anonymous

Lizardite said:
AFAIK Ruby on Linux

Oh well, that's not horrifying. For some reason I thought it was PHP, like other boorus.

Edit: Here is a thumbnailer for webms, same deal: 4 frames, 1/4 second delay.
Uses ffmpegthumbnailer (which is a separate package, not part of ffmpeg), imagemagick, and gifsicle.

#!/bin/sh
SIZE=150
FILENAME="$1"
OUTFILE="$2"

ffthumb () {
ffmpegthumbnailer -i "$FILENAME" -s "$SIZE" -t "$1" -o "$2"

}

for V in $(seq 20 20 80); do
ffthumb "${V}%" "/tmp/webmthumb-$PPID-$V.png"
done

INFILES=$(seq --format "/tmp/webmthumb-$PPID-%.0f.png" 20 20 80)
convert -delay 25 -dispose None $INFILES -colors 255 /tmp/webmthumb-$PPID.gif
gifsicle --optimize < /tmp/webmthumb-$PPID.gif > "$OUTFILE"

for V in $(seq 20 20 80); do
rm "/tmp/webmthumb-$PPID-$V.png"
done

Could be sped up by using graphicsmagick instead of imagemagick, if that's available.

Updated by anonymous

I can't read codes, are these going to have something to state they're a SWF, WEBM, GIF, or APNG?

Updated by anonymous

It won't specify the format. They will pull four frames (evenly spaced) out of the webm or gif (I don't believe that either one of those supports APNG or SWF), and then make an animation out of those four frames (showing each frame for a quarter of a second).

It's actually a good solution for gifs and webms. Except in unusually long animations with multiple scenes, four frames will most likely capture some representative frames. A similar solution would also work well for APNG. However, for SWF files, there is a deep problem: flashes are often interactive. This makes an automated method of extracting a representative image (or images) very difficult. Honestly, I'd be happy with just the md5 overlaid on the thumbnail for flashes. It wouldn't help with finding them the first time, but it would be helpful in finding a flash again.

Updated by anonymous

I have no idea what an md5 is and wikipedia's definition is too complex @_@

Updated by anonymous

Furrin_Gok said:
I have no idea what an md5 is and wikipedia's definition is too complex @_@

It's basically a way to turn a file into a short string of characters that are unique to that file. Since it is always calculated the same way, you can use it to verify that a file/image/etc. is exactly the same as another byte-for-byte. Think of it like a unique ID number.

Updated by anonymous

Furrin_Gok said:
I have no idea what an md5 is and wikipedia's definition is too complex @_@

Easily explained, imagine pi, pi is a unique number for all intents and purposes, and for my explanation our file.

And md5 hash is now that you look at the numbers in pi in specific intervals and write them down on a paper, so for example the first digit, second, fourth, eighth, 16th, 32nd, 64th, 128th, 256th, as well as after what digit the decimals start.
In pi these digits are, in order: 3, 1, 1, 6, 3, 5, 2, 6, 8
The place for the decimal point is "1"

Now, the md5 hash is basically that you take these numbers, do some math with them and what you get is a unique number, for this example we take them in order and add the place of the decimal point at the end of it, after a new decimal point.
So fake md5 of pi is: 311635268.1
If you now do the same with any other number, for example e (euler's constant (easy list here, you get a different fake-md5, for e it's 278856754.1.

While this is dumb for numbers and the fake md5 is as unique as a sparkle dog in the furry fandom it's the same principle, you turn a bunch of 0's an 1's into another, unique number, which allows you to compare files with each other and check if they are the same or different, without having to look at the entire file.
Ideal for information transfers (was the file properly received by the other party, was the file tinkered with (virus added)), or general checking against editing.

Updated by anonymous

Yeah, APNG support would require apng-utils, specifically apngdis, which is nowhere near as easy to get installed as gifsicle, imagemagick, and ffmpegthumbnailer+ffmpeg. The distro I'm using has a package for it, but I'd bet most linux distros don't.

@Furrin Gok: The key thing to look up was probably not MD5, but 'hash function' (MD5 is a particular hash function); the first sentence of Wikipedia 'hash function' captures the essential features pretty well:

A hash function is any function that can be used to map digital data of arbitrary size to digital data of fixed size, with slight differences in input data producing very big differences in output data.

No file-type overlay is done, but of course that would be pretty easy to add using imagemagick. Not really sure what value that would add, TBH, though.

The code is less readable than it ought to be because e621 is stripping the whitespace out.

@Snowy: I'd suggest that having the entire md5sum would be pretty obnoxious for no real gain. You could just use a 'shortsum' like git does -- the first 7 characters of the hash are enough to distinguish between 268 million (2**(4*7)) possible files.

With a browser with flash support, and desktop automation tool like xdotool, plus scrot, we could probably do better than the current generic thumbnail, for most files. Taking screenshots of the window at regular time intervals, then terminating the browser after a while. It would be irritatingly CPU and memory intensive, but should manage to get either the loading screen or some frames from the animation.

Updated by anonymous

savageorange said:
@Snowy: I'd suggest that having the entire md5sum would be pretty obnoxious for no real gain. You could just use a 'shortsum' like git does -- the first 7 characters of the hash are enough to distinguish between 268 million (2**(4*7)) possible files.

I didn't realize that that was a thing. That would be even better.

Updated by anonymous

I didn't think it was really a possibility, but if it could be done it would be awesome to get some automated animation previews.

Updated by anonymous

  • 1