Page MenuHomePhabricator

Scaling of images should take place in a linear colour space
Open, LowPublic

Description

Dispenser mentioned to me that our image scaling is working on non-linear sRGB colour space, which causes some less than ideal results on dark images

Background on issue:

For image magick, it looks like this can be addressed by just adding some command line flags (which flags unfortunately vary by version). [Except possibly not jpeg as that's shrunk by libjpeg]

Its unclear if something similar can be done in vips well still using the very efficient sequential read and not creating a giant temporary file. There is a -a option to vipsthumbnail that could maybe be used.

(If it can only be on image magick and then not for jpeg, we possibly wouldn't want to do it at all to keep things consistent. Requires more investigation anyhow)


Version: 1.24rc
Severity: normal

Details

Reference
bz66337

Event Timeline

bzimport raised the priority of this task from to Low.
bzimport set Reference to bz66337.
bzimport added a subscriber: Unknown Object (MLST).
Bawolff created this task.Jun 8 2014, 6:20 AM

Its unclear if something similar can be done in vips well still using the
very efficient sequential read and not creating a giant temporary file.
There is a -a option to vipsthumbnail that could maybe be used.

In my test, the -a option slowed things down quite a bit, and increased memory usage to beyond 400mb. :(

jcupitt wrote:

Some benchmarks:

$ time vipsthumbnail -a wtc.jpg --vips-leak
memory: high-water mark 65.98 MB
real 0m4.039s
user 0m4.003s
sys 0m0.038s
$ time vipsthumbnail wtc.jpg --vips-leak
memory: high-water mark 6.22 MB
real 0m0.307s
user 0m0.289s
sys 0m0.020s

wtc.jpg is a 10,000 x 10,000 pixel RGB image.

The main source of the slowdown is that you can't use libjpeg's very fast shrink-on-load feature, since that's calculated in Y, which is not linear. Instead, you have to decode the entire image, convert to a linear space (vipsthumbnail uses XYZ), and then shrink that.

-a is much more competitive if you use a format that doesn't support shrink-on-load, such as vanilla tif:

$ time vipsthumbnail wtc.tif --vips-leak
memory: high-water mark 44.31 MB
real 0m2.662s
user 0m0.513s
sys 0m0.119s
$ time vipsthumbnail -a wtc.tif --vips-leak
memory: high-water mark 66.62 MB
real 0m3.623s
user 0m3.547s
sys 0m0.078s

memuse should not be huge, the whole process can still be streamed.

Jdforrester-WMF moved this task from Untriaged to Backlog on the Multimedia board.Sep 4 2015, 6:10 PM
Restricted Application added subscribers: Steinsplitter, Matanya, Aklapper. · View Herald TranscriptSep 4 2015, 6:10 PM
Restricted Application added a project: Commons. · View Herald TranscriptJan 27 2017, 10:19 PM
Dispenser updated the task description. (Show Details)Jul 18 2017, 11:58 PM