Saturday, April 27, 2024
 Popular · Latest · Hot · Upcoming
9
rated 0 times [  9] [ 0]  / answers: 1 / hits: 4908  / 1 Year ago, fri, january 20, 2023, 6:43:40

Sometimes I crop PDFs in order to have a one-page reading instead of a scanned two pages. However, nautilus keeps an old thumbnail showing the former front page.



I know that I can delete the hidden thumbnails folder, but I'd like to know how can I regenerate only one specific thumbnail. F5 doesn't help.


More From » nautilus

 Answers
0

According to the freedesktop documentation Thumbnail Managing Standard
. You can force nautilus to recreate the thumbnail if the mtime (modification time) in the thumbnail is lower than the mtime in the original file.





  1. Detect Modifications



One important thing is to assure that the thumbnail image displays the
same information than the original, only in a downscaled version. To
make this possible we use the modification time stored in the required
'Thumb::MTime' key and check if it's equal the current modification
time of the original. If not we must recreate the thumbnail.



Example 2. Algorithm to check for modification.



if (file.mtime != thumb.MTime) {
recreate_thumbnail (); }



It is not sufficient to do a file.mtime > thumb.MTime check. If the user moves >another file over the original, where the mtime changes but is in fact lower than >the thumbnail stored mtime, we won't recognize this modification.




In order to achieve this... you can try with a little Nautilus-Script to set the mtime in the original file to the current time with the touch command.



1) Creating the script. Open a Terminal window Ctrl+Alt+T and type:



For Ubuntu 12.04 & 12.10




  • nano ~/.gnome2/nautilus-scripts/Regenerate-Thumbnail



For Ubuntu 13.04 & above




  • nano ~/.local/share/nautilus/scripts/Regenerate-Thumbnail



2) The content of the script.



#!/bin/bash

BAKIFS=$IFS
IFS=$'
'

for FILE in $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS; do
touch -m "$FILE"
done

IFS=$BAKIFS





To save the changes in nano.. Ctrl+O,Enter then Ctrl+X.



3) To make the script executable.



For Ubuntu 12.04 & 12.10




  • chmod +x ~/.gnome2/nautilus-scripts/Regenerate-Thumbnail



For Ubuntu 13.04 & above




  • chmod +x ~/.local/share/nautilus/scripts/Regenerate-Thumbnail



4) To test the script you can open nautilus, select a file(s), right click and go to Scripts > Regenerate-Thumbnail.



enter image description here



enter image description here



enter image description here



enter image description here



Hope this helps.


[#25521] Friday, January 20, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
cocal

Total Points: 236
Total Questions: 111
Total Answers: 123

Location: Belarus
Member since Tue, Mar 14, 2023
1 Year ago
;