GithubHelp home page GithubHelp logo

Comments (8)

kleisauke avatar kleisauke commented on May 26, 2024 1

IIUC, I think the first part of the patch mentioned in comment #3808 (comment) is still needed.

@@ -684,7 +684,7 @@ wtiff_compress_jpeg_header(Wtiff *wtiff,
        jpeg_set_defaults(cinfo);

        // use RGB mode (no chroma subsample) for high Q
-       if (wtiff->Q >= 90)
+       if (wtiff->Q >= 90 && image->Bands == 3)
                jpeg_set_colorspace(cinfo, JCS_RGB);

        /* Set compression quality. Must be called after setting params above.

(perhaps wtiff->Q >= 90 && space == JCS_RGB is clearer?)

from libvips.

manthey avatar manthey commented on May 26, 2024

A fix might be this diff

diff --git a/libvips/foreign/vips2tiff.c b/libvips/foreign/vips2tiff.c
index 3d8ccc06e..b6ad200b8 100644
--- a/libvips/foreign/vips2tiff.c
+++ b/libvips/foreign/vips2tiff.c
@@ -684,7 +684,7 @@ wtiff_compress_jpeg_header(Wtiff *wtiff,
        jpeg_set_defaults(cinfo);

        // use RGB mode (no chroma subsample) for high Q
-       if (wtiff->Q >= 90)
+       if (wtiff->Q >= 90 && image->Bands == 3)
                jpeg_set_colorspace(cinfo, JCS_RGB);

        /* Set compression quality. Must be called after setting params above.
@@ -2335,6 +2335,11 @@ wtiff_copy_tiff(Wtiff *wtiff, TIFF *out, TIFF *in)
         * we copy raw tiles.
         */

+       if ((wtiff->compression == COMPRESSION_ADOBE_DEFLATE ||
+                       wtiff->compression == COMPRESSION_LZW) &&
+               wtiff->predictor != VIPS_FOREIGN_TIFF_PREDICTOR_NONE)
+               TIFFSetField(out, TIFFTAG_PREDICTOR, wtiff->predictor);
+
        /* We can't copy profiles or xmp :( Set again from wtiff.
         */
        if (wtiff_embed_xmp(wtiff, out) ||

But I'm not understanding why writing the prediction tag was removed for the webp and zstd compression formats, so don't know if that should be changed back, too.

from libvips.

jcupitt avatar jcupitt commented on May 26, 2024

Hi @manthey,

Thanks for reporting this. I think I thought those were pseudotags rather than real tags, so they were no longer necessary now we copy compressed tiles. You're right, they should go back.

I'll add a test for this case as well.

from libvips.

jcupitt avatar jcupitt commented on May 26, 2024

It seems TIFFTAG_PREDICTOR is the only non-pseudotag there, so we can just add a CopyField() for it. The other tags (webp, zstd) are pseudotags and cannot be copied (and don't need to be).

This will be in 8.15.2. I credited you in the changelog, I hope that's OK.

from libvips.

jcupitt avatar jcupitt commented on May 26, 2024

(and thanks again for reporting this dumb thing!)

from libvips.

manthey avatar manthey commented on May 26, 2024

Thank you.

from libvips.

dgutman avatar dgutman commented on May 26, 2024

John thanks for responding / fixing this so quickly.. and your definition of dumb is not exactly the universe's definition of dumb.. :-)

from libvips.

jcupitt avatar jcupitt commented on May 26, 2024

You're right, the JCS_RGB flag probably shouldn't be set for non-RGB images. Nice!

from libvips.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.