After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 755041 - How to avoid to scale down thumbnail image file?
How to avoid to scale down thumbnail image file?
Status: RESOLVED NOTABUG
Product: gnome-desktop
Classification: Core
Component: Thumbnail
git master
Other Linux
: Normal enhancement
: ---
Assigned To: gnome-font-viewer-maint
gnome-font-viewer-maint
Depends on:
Blocks: 752005
 
 
Reported: 2015-09-15 07:46 UTC by Peng Wu
Modified: 2015-10-14 09:21 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
the tiled thumbnail image file (5.74 KB, image/png)
2015-09-15 09:05 UTC, Peng Wu
  Details
Proposed patch to avoid to scale down the thumbnail image (1.87 KB, patch)
2015-09-28 08:31 UTC, Peng Wu
rejected Details | Review

Description Peng Wu 2015-09-15 07:46:14 UTC
Currently we are fixing a bug in gnome-font-viewer.

As TrueType Collection file (.ttc file) contains several font face,
we generated a tiled thumbnail image file, but it is scaled down.

In the gnome-font-viewer UI, the preview of the font face becomes blur.

how to avoid to scale down thumbnail image file?

URL: https://bugzilla.gnome.org/show_bug.cgi?id=752005
Comment 1 Bastien Nocera 2015-09-15 08:35:39 UTC
I don't understand what you need here. Please attach a test case, and the reason why you think this is a bug.

In the future, you should use mailing-lists or IRC to discuss this sort of not too well defined problem.
Comment 2 Peng Wu 2015-09-15 09:05:35 UTC
Created attachment 311335 [details]
the tiled thumbnail image file

We used the following command to generate the file:
$./gnome-thumbnail-font /usr/share/fonts/wqy-zenhei/wqy-zenhei.ttc zenhei.png

But as the width is two times larger than default thumbnail width, the final image is scaled down, when use the image in gnome-font-viewer, the preview icon becomes blur.
Comment 3 Peng Wu 2015-09-28 08:31:52 UTC
Created attachment 312268 [details] [review]
Proposed patch to avoid to scale down the thumbnail image

Please review the patch, thanks.
Comment 4 Bastien Nocera 2015-09-28 11:55:56 UTC
(In reply to Peng Wu from comment #0)
> Currently we are fixing a bug in gnome-font-viewer.
> 
> As TrueType Collection file (.ttc file) contains several font face,
> we generated a tiled thumbnail image file, but it is scaled down.
> 
> In the gnome-font-viewer UI, the preview of the font face becomes blur.
> 
> how to avoid to scale down thumbnail image file?

Generate it yourself, and fix gnome-thumbnail-font to not resize.
Comment 5 Peng Wu 2015-09-29 04:53:52 UTC
But the scale down happens in gnome-desktop:
https://git.gnome.org/browse/gnome-desktop/tree/libgnome-desktop/gnome-desktop-thumbnail.c#n1443

With the above patch, we can avoid to scale down the image.
Just need to add the following line to gnome-font-viewer.thumbnailer:
[Thumbnailer Entry]
NoScale=true
Comment 6 Bastien Nocera 2015-09-30 08:17:22 UTC
(In reply to Peng Wu from comment #5)
> But the scale down happens in gnome-desktop:
> https://git.gnome.org/browse/gnome-desktop/tree/libgnome-desktop/gnome-
> desktop-thumbnail.c#n1443
> 
> With the above patch, we can avoid to scale down the image.
> Just need to add the following line to gnome-font-viewer.thumbnailer:
> [Thumbnailer Entry]
> NoScale=true

Right. This is an API change then.
Comment 7 Bastien Nocera 2015-09-30 08:19:06 UTC
Review of attachment 312268 [details] [review]:

Whether or not to resize cannot be a function of the thumbnailer. The API documentation says that thumbnails will be resized, and, if we wanted to have a way to not resize, it would need to be handled through a new command-line argument for thumbnailers, and new API.
Comment 8 Daiki Ueno 2015-10-09 08:35:41 UTC
The original problem (bug 752005) is that the thumbnailing API doesn't support multiple thumbnail images per file.  To work around that, it was suggested to compose multiple images into a single image, but then it turned out to involve this scaling problem, since the composed image can be too large.

So, if there is a cleaner way to handle multiple thumbnail images per file, there shouldn't be a problem.  Any suggestions?

A humble idea is to let thumbnailers generate multiple images with different suffixes:

<...>.png
<...>.1.png
<...>.2.png

Let's call <...>.png "primary" and others "secondary".  The number of secondary files is stored in a "tEXt" key of the primary file.    

gnome_desktop_thumbnail_factory_generate_thumbnail() loads the primary file and secondary files if any, and attach the secondary pixbufs to the primary pixbuf, say using g_object_set_data_full().
Comment 9 Bastien Nocera 2015-10-09 09:37:05 UTC
(In reply to Daiki Ueno from comment #8)
> The original problem (bug 752005) is that the thumbnailing API doesn't
> support multiple thumbnail images per file.  To work around that, it was
> suggested to compose multiple images into a single image, but then it turned
> out to involve this scaling problem, since the composed image can be too
> large.

But *why* do you want to do that? Isn't it easier to add whatever it is you need in the thumbnailer you're calling, and simply bypass the thumbnailing API?

This is what totem does to create galleries:
https://git.gnome.org/browse/totem/tree/src/plugins/screenshot
Comment 10 Daiki Ueno 2015-10-13 08:17:47 UTC
(In reply to Bastien Nocera from comment #9)
> But *why* do you want to do that? Isn't it easier to add whatever it is you
> need in the thumbnailer you're calling, and simply bypass the thumbnailing
> API?
> 
> This is what totem does to create galleries:
> https://git.gnome.org/browse/totem/tree/src/plugins/screenshot

Thanks for the suggestion and the example.  It sounds indeed easier and looks straightforward for the gallery image creation.

For our case, the application would need to take care of caching by itself, but it might not be a big deal.  Peng, what do you think?
Comment 11 Peng Wu 2015-10-14 09:09:20 UTC
Does gnome-desktop thumbnail support the following URI?

file:///usr/share/fonts/wqy-zenhei/wqy-zenhei.ttc#0
file:///usr/share/fonts/wqy-zenhei/wqy-zenhei.ttc#1
...
file:///usr/share/fonts/wqy-zenhei/wqy-zenhei.ttc#n

If so, maybe we can use "#num" for each font face.
Comment 12 Bastien Nocera 2015-10-14 09:11:33 UTC
(In reply to Peng Wu from comment #11)
> Does gnome-desktop thumbnail support the following URI?

No, because gnome-desktop doesn't modify URIs, it just passes them to the thumbnailer.
Comment 13 Peng Wu 2015-10-14 09:18:44 UTC
I mean gnome-font-viewer will request the thumbnail images of the following URI from gnome-desktop:

file:///usr/share/fonts/wqy-zenhei/wqy-zenhei.ttc
file:///usr/share/fonts/wqy-zenhei/wqy-zenhei.ttc#1
...
file:///usr/share/fonts/wqy-zenhei/wqy-zenhei.ttc#n

gnome-font-viewer thumbnailer will handle the new URI in code.
Comment 14 Bastien Nocera 2015-10-14 09:21:20 UTC
I don't think there's anything left to discuss in this bug. Please carry on the discussion about gnome-font-viewer in a gnome-font-viewer bug.