You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
By default, only the video files or the image files that are recognized by GdkPixbuf can have a thumbnail. I added thumbnails for CR3 files to my local version of spacefm, using exiv2. Here I share my ugly hacks, maybe someone will find it useful or have some comments.
The relevant parts are:
In src/vfs/vfs-thumbnail-loader.c, the function _vfs_thumbnail_load (line 354).
The files src/desktop/desktop-window.c and src/ptk/ptk-file-list.c.
The idea is very lazy: when we want to create a thumbnail for a CR3 file, we extract the jpg with exiv2, and we hijack the existing code to create a thumbnail for this file instead. The diff of src/vfs/vfs-thumbnail-loader.c can be found below. You need to create a folder ~/.thumbnails/cr3. My CR3 files always have 2 embedded jpeg files, a small one and a larger one. I hardcoded below the extraction the second jpeg, which is the largest.
@@ -387,8 +387,9 @@
}
#endif
+ int cr3_file = !strcmp( vfs_mime_type_get_type( mimetype ), "image/x-canon-cr3" );- if ( file_is_video == FALSE )+ if ( file_is_video == FALSE && !cr3_file )
{
if ( !gdk_pixbuf_get_file_info( file_path, &w, &h ) )
return NULL; /* image format cannot be recognized */
@@ -441,6 +442,12 @@
w = gdk_pixbuf_get_width( thumbnail );
h = gdk_pixbuf_get_height( thumbnail );
}
+ else if ( cr3_file )+ {+ w = -1;+ h = -1;+ }+
if ( !thumbnail || ( w < size && h < size ) ||
!( thumb_mtime = gdk_pixbuf_get_option( thumbnail,
"tEXt::Thumb::MTime" ) ) ||
@@ -449,10 +456,21 @@
if( thumbnail )
g_object_unref( thumbnail );
/* create new thumbnail */
++ if ( cr3_file )+ {+ symlink(file_path, "/home/user/.thumbnails/cr3/temp.CR3");+ system("exiv2 -f -e p2 /home/user/.thumbnails/cr3/temp.CR3");+ unlink("/home/user/.thumbnails/cr3/temp.CR3");+ file_path = "/home/user/.thumbnails/cr3/temp-preview2.jpg";+ }+
if ( file_is_video == FALSE )
{
thumbnail = gdk_pixbuf_new_from_file_at_size( file_path,
create_size, create_size, NULL );
+ if ( cr3_file )+ system("rm /home/user/.thumbnails/cr3/temp-preview2.jpg");
if ( thumbnail )
{
// Note: gdk_pixbuf_apply_embedded_orientation returns a new
The problem is that the size of CR3 files often exceeds the hard limit of 32768 KB for thumbnails to show. There are two options. The easiest one is to increase that limit in the file data/ui/prefdlg2.ui. The second option is to modify the files src/desktop/desktop-window.c and src/ptk/ptk-file-list.c to bypass the size limit when the file is a CR3 file. This is not a problem, since exiv2 just extracts a small jpeg from the potentially huge CR3 file. There is a lot of code duplication and I'm too lazy to refactor, so for each call of vfs_file_info_is_video in these files, I added another condition to test if the file is a CR3 file. For instance,
By default, only the video files or the image files that are recognized by GdkPixbuf can have a thumbnail. I added thumbnails for CR3 files to my local version of spacefm, using exiv2. Here I share my ugly hacks, maybe someone will find it useful or have some comments.
The relevant parts are:
src/vfs/vfs-thumbnail-loader.c
, the function_vfs_thumbnail_load
(line 354).src/desktop/desktop-window.c
andsrc/ptk/ptk-file-list.c
.The idea is very lazy: when we want to create a thumbnail for a CR3 file, we extract the jpg with exiv2, and we hijack the existing code to create a thumbnail for this file instead. The diff of
src/vfs/vfs-thumbnail-loader.c
can be found below. You need to create a folder~/.thumbnails/cr3
. My CR3 files always have 2 embedded jpeg files, a small one and a larger one. I hardcoded below the extraction the second jpeg, which is the largest.The problem is that the size of CR3 files often exceeds the hard limit of 32768 KB for thumbnails to show. There are two options. The easiest one is to increase that limit in the file
data/ui/prefdlg2.ui
. The second option is to modify the filessrc/desktop/desktop-window.c
andsrc/ptk/ptk-file-list.c
to bypass the size limit when the file is a CR3 file. This is not a problem, since exiv2 just extracts a small jpeg from the potentially huge CR3 file. There is a lot of code duplication and I'm too lazy to refactor, so for each call ofvfs_file_info_is_video
in these files, I added another condition to test if the file is a CR3 file. For instance,becomes
The text was updated successfully, but these errors were encountered: