With the help of the ImageMagick /1/ the KDE icons can be made from the piles of polaroids.

The context menu desktop part - $HOME/.local/share/kservices5/ServiceMenus/magickpile.desktop:
Code:
[Desktop Entry] Type=Service Icon=view-list-icons X-KDE-ServiceTypes=KonqPopupMenu/Plugin MimeType=all/allfiles; Actions=magickPile; Encoding=UTF-8 [Desktop Action magickPile] Name=Magick pile of icons Icon=view-list-icons Exec=magickpile.pl "%F"

The thumbnail polaroids are scooped from the thumbnail cache and piled with a short Perl script - magickpile.pl:
Code:
#!/usr/bin/perl
# usage: magickpile.pl filelist
use strict;
use warnings;
# modules
use Image::Magick;
use File::Spec;
use URI::Escape;
use Digest::MD5 qw(md5_hex);
my $angle;
my @newIcon;
my $i = 0;
my $iconResolution = '256x256';
my $cachePath = $ENV{XDG_CACHE_HOME} || ("$ENV{HOME}/.cache");
my $thumbPath = "$cachePath/thumbnails/large/";
$ARGV[0] =~ s' /' //'g;
my @fileNames = split(' /', $ARGV[0]);
my ($volume,$workDir,$file) = File::Spec->splitpath( $fileNames[0] );
my $iconOut = "$workDir.magickpile.png";
# pile of thumbs
foreach my $name (@fileNames) {
$i++;
my $fullName = "file://" . $name;
my $escapedName = uri_escape("$fullName", "^A-Öa-ö0-9\-\.,_~/:()&!\@\\[\\]'");
$escapedName=~ s'\|'%7C'g;
$escapedName=~ s'%24'$'g;
$escapedName=~ s'\{'%7B'g;
$escapedName=~ s'\}'%7D'g;
my $thumbName = md5_hex("$escapedName") . ".png";
my $angle = int(rand(30))-15;
$newIcon[$i] = Image::Magick->new;
$newIcon[$i]->Read("$thumbPath$thumbName");
$newIcon[$i]->Polaroid(angle => $angle, gravity => 'center', background => 'transparent');
$newIcon[$i] = $newIcon[$i]->Montage(geometry=>$iconResolution, background=>'transparent');
if ($i > 1) {
$newIcon[1]->Composite(image=>$newIcon[$i],compose=>'over', gravity=>'center');
$newIcon[$i]->Set(quality=>100);
}
}
$newIcon[1]->Write("$iconOut");
system ("kwriteconfig5", "--file", "$workDir.directory", "--group", "Desktop Entry", "--key", "Icon", "./.magickpile.png");
Note !
This script is using 'Correctly encode URL of thumbnails' /3/. It won't work with the older KDE Frameworks (<5.46 ?). At here, now, the KF 5.48.0.
It is getting the thumbnails from the thumbnail cache. If the thumbnailer /4/ is not caching then it won't work with this type of thumbnails.
Preview
Direct: https://youtu.be/-JEfOa8gAWQ
Links
1. https://www.imagemagick.org/script/index.php
2. http://www.imagemagick.org/script/perl-magick.php
3. https://cgit.kde.org/kio.git/commit/...499eff3b976162
4. https://api.kde.org/frameworks/kio/h...mbCreator.html






Thanks All!





Leave a comment: