! Please note that this is a snapshot of our old Bugzilla server, which is read only since May 29, 2020. Please go to gitlab.xfce.org for our new server !
JPEG thumbnails created by the jpegthumbnailer are huge
Status:
RESOLVED: FIXED
Product:
Tumbler
Component:
General

Comments

Description Stephan Arts editbugs 2011-10-07 13:41:06 CEST
Created attachment 3888 
size-calculation

The JPEG thumbnailer generates huge thumbnails.

libjpeg only supports scaling from 1/1, 1/2, 1/4, 1/8 and 1/16.

--------
unsigned int scale_num, scale_denom
   Scale the image by the fraction scale_num/scale_denom.  Default is
   1/1, or no scaling.  Currently, the supported scaling ratios are
   M/N with all N from 1 to 16, where M is the destination DCT size,
   which is 8 by default (see block_size parameter above).
   (The library design allows for arbitrary scaling ratios but this
   is not likely to be implemented any time soon.)
--------

For some images, this is not enough and the thumbnail should be something like 1/72th or even more.

The current implementation takes this limitation into account by creating a thumbnail as small as possible as is allowed by libjpeg. However, this can still cause thumbnails of 238x4650 pixels to be created.

When this behaviour is changed via the attached patch[0], the following behaviour occurs.

The scale is set to 1/72, this causes libjpeg to fallback to the default scale of 1/8.

I propose to not use the libjpeg to do the scaling, but only use it for extracting the thumbnail. When there is no thumbnail available, fallback on gdk for the scaling of the original image.
Comment 1 Nick Schermer editbugs 2011-10-26 21:37:30 CEST
No idea if this affects other thumbnailers too, we this can be fixed in the xdg-cache plugin or in the jpeg thumbnailer by adding something like exo_gdk_pixbuf_scale_down does.
Comment 2 Nick Schermer editbugs 2011-10-27 19:53:02 CEST
Created attachment 3921 
Resize jpeg thumbnails before storing them

Would be nice to share this function in libtumbler, because it's used in a number of places, but this should do the trick.
Comment 3 Jannis Pohlmann editbugs 2011-10-27 20:02:00 CEST
(In reply to comment #2)
> Created attachment 3921 
> Resize jpeg thumbnails before storing them

Looks fine to me. 

> Would be nice to share this function in libtumbler, because it's used in a
> number of places, but this should do the trick.

libtumbler and tumbler are supposed to be toolkit-agnostic (otherwise tumbler wouldn't have been adopted on the N9), hence no dependency on gdk-pixbuf. We could add a separate utility library for gdk-pixbuf-based thumbnailer plugins. That way tumbler would only load gdk-pixbuf if such a thumbnailer plugin is installed.

I too dislike the code replication related to scaling.
Comment 4 Nick Schermer editbugs 2011-10-27 20:07:16 CEST
We can also do this in xdg-cache for all plugins..
Comment 5 Nick Schermer editbugs 2011-10-27 22:34:21 CEST
Pushed the fix, worked nice here. Dups are not that nice, but not problematic too, because the function is straightforward.

Pushed in d929d61.

Bug #8020

Reported by:
Stephan Arts
Reported on: 2011-10-07
Last modified on: 2011-10-27

People

Assignee:
Jannis Pohlmann
CC List:
3 users

Version

Version:
0.1.22

Attachments

size-calculation (570 bytes, patch)
2011-10-07 13:41 CEST , Stephan Arts
no flags
Resize jpeg thumbnails before storing them (2.29 KB, patch)
2011-10-27 19:53 CEST , Nick Schermer
no flags

Additional information