Bug 23984 - Local cover 'thumbnail' size is bigger than 'imagefile' size in biblioimages table
Summary: Local cover 'thumbnail' size is bigger than 'imagefile' size in biblioimages ...
Status: NEW
Alias: None
Product: Koha
Classification: Unclassified
Component: Architecture, internals, and plumbing (show other bugs)
Version: Main
Hardware: All All
: P3 normal (vote)
Assignee: Bugs List
QA Contact: Testopia
URL:
Keywords:
Depends on: 22988 21987
Blocks:
  Show dependency treegraph
 
Reported: 2019-11-07 09:27 UTC by Martin Renvoize
Modified: 2023-02-28 15:07 UTC (History)
10 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Renvoize 2019-11-07 09:27:42 UTC
The original resolution to this issue, bug 21987, caused a nasty regression and has since been reverted.  Opening this bug so we may pursue a new route to goal.

+++ This bug was initially created as a clone of Bug #21987 +++

We use local cover images in our setup, and also resize the covers
we scan to a width of 160px before uploading and attaching them to
a Koha bibliographic record (we upload one cover per biblio).

While using phpMyAdmin to view the contents of the 'biblioimages'
table (relevant screenshot here: https://imgur.com/a/cSEVLBI), we
noticed that the size of the BLOBs for the 'thumbnail' column was in
some cases twice as big as that of the 'imagefile' column. In fact,
this happens for more than 50% of uploaded covers as you can see
from the output of the SQL queries below:

mysql> SELECT COUNT( * ) AS count
         FROM biblioimages
        WHERE LENGTH( thumbnail ) > ( LENGTH( imagefile ) * 2 ) ;
+-------+
| count |
+-------+
|  1356 |
+-------+

mysql> SELECT COUNT( * ) AS count,
              SUM( LENGTH( imagefile ) ) AS images_size,
              SUM( LENGTH( thumbnail ) ) AS thumbnails_size
         FROM biblioimages ;
+-------+-------------+-----------------+
| count | images_size | thumbnails_size |
+-------+-------------+-----------------+
|  2347 |    68323933 |       115839686 |
+-------+-------------+-----------------+

It would appear that for each 160px-wide JPG with 24-bit depth that
we have uploaded, the 'imagefile' column has been populated with an
PNG of 8-bit depth with the same dimensions as the uploaded file,
whereas the 'thumbnail' column contains a 24-bit PNG image with a
width reduced to 140 pixels.

I've tracked down the creation of resized 24-bit PNGs to this code:
https://github.com/Koha-Community/Koha/blob/master/C4/Images.pm#L182-L183

Do thumbnails for covers need to be true colour (24-bit) images?

Also, why is it that _scale_image() returns an image of 8-bit depth
if the source image's dimensions are less than 600x800? (i.e. when
no resizing is performed)
Comment 1 Manos PETRIDIS 2023-02-28 15:07:25 UTC
Please also check Bug 31049 - Add tool to set/reduce local cover image size and quality, interactively and in batch.