From 0d7cc2d9361ce66f38d5ef06216bc1e7f6e741d6 Mon Sep 17 00:00:00 2001 From: j-james Date: Mon, 20 Dec 2021 13:45:20 -0800 Subject: Process STL thumbnails using OpenSCAD --- .SRCINFO | 15 +++++++++++++++ LICENSE | 7 +++++++ PKGBUILD | 18 ++++++++++++++++++ stl-thumbnailer.sh | 20 ++++++++++++++++++++ stl.thumbnailer | 7 +++++++ 5 files changed, 67 insertions(+) create mode 100644 .SRCINFO create mode 100644 LICENSE create mode 100644 PKGBUILD create mode 100644 stl-thumbnailer.sh create mode 100644 stl.thumbnailer diff --git a/.SRCINFO b/.SRCINFO new file mode 100644 index 0000000..185ce18 --- /dev/null +++ b/.SRCINFO @@ -0,0 +1,15 @@ +pkgbase = tumbler-stl-thumbnailer + pkgdesc = Custom STL thumbnails for Tumbler + pkgver = 1 + pkgrel = 1 + url = https://github.com/j-james/thunar-stl-thumbnails + arch = any + license = BSD + depends = tumbler + depends = openscad + source = stl.thumbnailer + source = stl-thumbnailer.sh + sha256sums = fd4a8c44e4a35418e894241a3e6fefcab83279570b5e91296dde1f1179b0a0cc + sha256sums = 0b6a39b7facae2c7d036a0017010a86f6a3ebcb2a572312174d7d4cff1af8325 + +pkgname = tumbler-stl-thumbnailer diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..48b75fe --- /dev/null +++ b/LICENSE @@ -0,0 +1,7 @@ +BSD Zero Clause License + +Copyright (C) 2021 j-james + +Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 0000000..ad2c40e --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,18 @@ +# Maintainer: j-james +pkgname=tumbler-stl-thumbnailer +pkgver=1 +pkgrel=1 +pkgdesc="Custom STL thumbnails for Tumbler" +arch=('any') +url="https://github.com/j-james/thunar-stl-thumbnails" +license=('BSD') +depends=('tumbler' 'openscad') +source=('stl.thumbnailer' + 'stl-thumbnailer.sh') +sha256sums=('fd4a8c44e4a35418e894241a3e6fefcab83279570b5e91296dde1f1179b0a0cc' + '0b6a39b7facae2c7d036a0017010a86f6a3ebcb2a572312174d7d4cff1af8325') + +package() { + install -Dvm644 "stl.thumbnailer" "$pkgdir/usr/share/thumbnailers/stl.thumbnailer" + install -Dvm755 "stl-thumbnailer.sh" "$pkgdir/usr/bin/stl-thumbnailer" +} diff --git a/stl-thumbnailer.sh b/stl-thumbnailer.sh new file mode 100644 index 0000000..7338979 --- /dev/null +++ b/stl-thumbnailer.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +if [[ $# -lt 3 ]]; then + echo "$0: input_file_name output_file_name size" + exit 255 +fi + +INPUT_FILE=$1 +OUTPUT_FILE=$2 +SIZE=$3 + +TEMP="$(mktemp --directory --tmpdir tumbler-stl-XXXXXXX)" +cp "$INPUT_FILE" "$TEMP/source.stl" + +echo "import(\"source.stl\", convexity=10);" > "$TEMP/thumbnail.scad" +openscad --imgsize "500,500" -o "$TEMP/thumbnail.png" "$TEMP/thumbnail.scad" 2>/dev/null + +convert -thumbnail "$SIZE" "$TEMP/thumbnail.png" "$OUTPUT_FILE" 1>/dev/null 2>&1 + +rm -rf $TEMP diff --git a/stl.thumbnailer b/stl.thumbnailer new file mode 100644 index 0000000..1de2d21 --- /dev/null +++ b/stl.thumbnailer @@ -0,0 +1,7 @@ +[Thumbnailer Entry] +Version=1.0 +Encoding=UTF-8 +Type=X-Thumbnailer +Name=STL Thumbnailer +MimeType=model/stl; +Exec=/usr/bin/stl-thumbnailer %i %o %s -- cgit v1.2.3-70-g09d2