parent
de451c0566
commit
d21ce94703
@ -1,4 +1,10 @@
|
|||||||
window.addEventListener('load', () => {
|
window.addEventListener('load', () => {
|
||||||
document.querySelectorAll(".thread").forEach(x=> x.classList.toggle("hidden"));
|
document.querySelectorAll(".thread").forEach(x=> x.classList.toggle("hidden"));
|
||||||
document.querySelectorAll(".script").forEach(x=> x.style=""); //unhide script-specific elements
|
document.querySelectorAll(".script").forEach(x=> x.style=""); //unhide script-specific elements
|
||||||
|
|
||||||
|
document.querySelectorAll(".expand").forEach(x=> {
|
||||||
|
x.addEventListener("click", ()=> {
|
||||||
|
document.querySelector("[id='"+ x.getAttribute("href").slice(1) +"']").classList.toggle("hidden");
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
@ -0,0 +1,34 @@
|
|||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Tools;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
using ImageMagick;
|
||||||
|
|
||||||
|
namespace ndview
|
||||||
|
{
|
||||||
|
public class ThumbnailGenerator
|
||||||
|
{
|
||||||
|
public readonly int Width,Height;
|
||||||
|
public ThumbnailGenerator(int width) : this(width,0){}
|
||||||
|
public ThumbnailGenerator(int width, int height)
|
||||||
|
{
|
||||||
|
(Width, Height) = (width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task Thumbnail(Stream from, Stream to, CancellationToken token=default)
|
||||||
|
=> Task.Run(()=> {
|
||||||
|
using var image= new MagickImage();
|
||||||
|
image.Read(from);
|
||||||
|
token.ThrowIfCancellationRequested();
|
||||||
|
image.Resize(200, 0);
|
||||||
|
|
||||||
|
token.ThrowIfCancellationRequested();
|
||||||
|
image.Write(to);
|
||||||
|
token.ThrowIfCancellationRequested();
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue