Skip to content

Color distortion when using the thumbnail function with a linear parameter #169

Closed
@romanzks

Description

@romanzks

I noticed a strange image color distortion when using the thumbnail function with a linear parameter for image with a color profile.

In the examples below, I don't change the size of the image on purpose, as it makes it easier to see color differences. The bug is reproduced anyway.

input
input.jpg - original image


$image = Vips\Image::thumbnail('input.jpg', 1920, [
    'linear' => true,
]);
$image->writeToFile('output.jpg');

output
output.jpg


Removing the color profile does not solve the issue. The colors are slightly different from the previous version, but still distorted.

$image = Vips\Image::thumbnail('input.jpg', 1920, [
    'export_profile' => Vips\Interpretation::SRGB,
    'linear' => true,
]);
$image->writeToFile('output2.jpg', [
    'strip' => true,
]);

output
output2.jpg


However, if I first remove the color profile, save the image, and apply the linear parameter to a new image, no color distortion occurs. The following example keeps the original colors.

$image = Vips\Image::thumbnail('input.jpg', 1920, [
    'export_profile' => Vips\Interpretation::SRGB,
]);
$image->writeToFile('output3.jpg', [
    'strip' => true,
]);

$image = Vips\Image::thumbnail('output3.jpg', 1920, [
    'linear' => true,
]);
$image->writeToFile('output4.jpg');

Unfortunately this is not an acceptable solution, because I do a double image conversion what affects the quality of the image and the speed of work.


  • Docker with PHP 8.1.12
  • jcupitt/vips 2.1.0
  • libvips/libvips 8.13.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions