Gnome/KDE/Mac/Windows/ thumbnails generator
Any chance we could get a thumbnailer to work using leocad to get file previews going? Better than plain text and doesn't take too long to generate.
you can refer to @tcobbs @pbartfai for further details on implementation for linux desktops - check the qt part of https://github.com/tcobbs/ldview
Thanks
FWIW, LDView ships with ldraw-thumbnailer, which is wrapper script around LDView.
@hfiguiere right, but each application in this capacity should be able to render thumbnails when and if available.
rationale: I was using ldview for renders up until I switched all of my ldraw workflow to leocad because it could handle it.
I my specific case, I use the arm64 build which is barebones.
if @leozide was to release a thumbnailer that wraps around and leverages leocad's rendering capacity, I'd load that too and use it.
just a very good nice to have IMHO considering the latest amount of progress we've seen.
The LDView linux script seems to be pretty simple, I remember looking at how Windows handles thumbnails a few years ago and it was somewhat complicated and I have no idea about mac
FWIW, Windows and Mac thumbnail generation are both a pain. Mac is probably the worse of the two due to horrible documentation of QuickLook. (Thumbnails on MacOS are generated by a quicklook plugin baked into the app wrapper.) Creating a COM DLL for Explorer to load is also a pain, but much better documented. LDView does support thumbnails on all three OSes, and in all three cases the thumbnail integration generates a command line that executes the main LDView executable. (Of course, LDView has supported command line image generation for a very long time.)
FWIW, Windows and Mac thumbnail generation are both a pain. Mac is probably the worse of the two due to horrible documentation of QuickLook. (Thumbnails on MacOS are generated by a quicklook plugin baked into the app wrapper.) Creating a COM DLL for Explorer to load is also a pain, but much better documented. LDView does support thumbnails on all three OSes, and in all three cases the thumbnail integration generates a command line that executes the main LDView executable. (Of course, LDView has supported command line image generation for a very long time.)
Well @leozide has done a great job of integrating cli rendering and I've been using it for quite some time now, I'm sure it can serve as a start to implement a thumbnailer at least on linux-based systems for the time being?
@tcobbs wouldn't the mechanism be downright the same/similar ass to how ldraw-thumbnailer already functions and what it outputs?
@nathaneltitane Since LeoCAD has command line rendering support, I would expect that he could simply copy LDView's script and modify it to produce an appropriate LeoCAD command line. I didn't create the script, though, @pbartfai did. For that matter, copying and modifying the LDViewThumbs Windows DLL project and the LDViewQuickLook project project might be possible as well.
One of the issue that should be noted is that for MPD files LeoCAD and LDView use different mime types.
LeoCAD uses application/x-multi-part-ldraw
LDView uses application/x-multipart-ldraw
According to the archived LDraw spec:
https://web.archive.org/web/20150922071809/http://www.ldraw.org/reference/specs/mimetypes.shtml
it is application/x-multi-part-ldraw
(sadly the current spec doesn't even mention it).
Either or, the inconsistency is the problem (it can be worked around)
One of the issue that should be noted is that for MPD files LeoCAD and LDView use different mime types.
LeoCAD uses
application/x-multi-part-ldrawLDView usesapplication/x-multipart-ldrawAccording to the archived LDraw spec: https://web.archive.org/web/20150922071809/http://www.ldraw.org/reference/specs/mimetypes.shtml it is
application/x-multi-part-ldraw(sadly the current spec doesn't even mention it).
Either or, the inconsistency is the problem (it can be worked around)
would that have anything to do with the ldraw spec mentioned so many times around tickets that have to do with file extensions, saving, creating and mimetypes?
maybe @tcobbs can help us elucidate this problem once and for all?
As for official documentation, and proper wording, here is what I have so far:
The only canonical information I find is on the internet archive (in an older version of the LDraw website) as the information is no longer in the official spec pages (linked above)
And I found a post that say "use LDview's": https://forums.ldraw.org/thread-17067.html
I think this is a bug in the Qt LDView code. LDView for Mac uses application/x-multi-part-ldraw, and has since 2008 (which is admittedly after Qt LDView had already used x-multipart-ldraw). @pbartfai would changing this cause problems?
ref @tcobbs @pbartfai ^ - last we spoke about the mimetypes and issues...
Sample leocad thumbnailer taken from @pbartfai and ldview - does it require a library to function or just the app itself though?
#!/bin/bash
input=${1}
uri=${1}
input=$(printf '%b' "${input//%/\\x}")
input=${input/file:\/\/}
output=${2}
size=${3}
if [ ${size} -le 128 ]
then
directory=normal
elif [ ${size} -le 256 ]
then
directory=large
fi
if [ -f /tmp/ldraw-thumbnailer.log ]
then
echo ${input} ${output} ${size} ${directory} >> /tmp/ldraw-thumbnailer.log
fi
extension="png"
latitude="30"
longitude="30"
shading="full"
line_width="1"
antialias_samples="8"
/usr/bin/leocad \
--height "${size}" \
--width "${size}" \
--camera-angles "${latitude}" "${longitude}" \
--shading "${shading}" \
--line-width "${line_width}" \
--aa-samples "${antialias_samples}" \
--image "${output}" \
"${uri}"
if [ -f ${output} ]
then
chmod 600 ${output}
# mogrify -set Thumb::URI $uri $output
# mogrify -set Thumb::MTime `stat -c %Y $input` $output
# mogrify -set Thumb::Size `stat -c %s $input` $output
# mogrify -set Thumb::Mimetype `xdg-mime query filetype $input` $output
if [[ ${output} != /tmp/gnome-desktop-thumbnailer.png && ! ( ${output} =~ /.cache/thumbnails/ ) && ! ( ${output} =~ /.thumbnails/ ) ]]
then
thumbnail=$(echo -n ${uri} | md5sum | cut -f1 -d '\')
test -d ~/.cache/thumbnails/${directory}/ || mkdirectory -p ~/.cache/thumbnails/${directory}/
cp -f ${output} ~/.cache/thumbnails/${directory}/${thumbnail}.${extension}
fi
fi
exit 0
n.b.: mimetypes do require to be specified as:
MimeType=application/x-ldraw;application/x-multipart-ldraw;application/x-multi-part-ldraw;
for complete coverage of all ldr/mpd specs