Comments (8)
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.
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.
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.
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.
(and thanks again for reporting this dumb thing!)
from libvips.
Thank you.
from libvips.
John thanks for responding / fixing this so quickly.. and your definition of dumb is not exactly the universe's definition of dumb.. :-)
from libvips.
You're right, the JCS_RGB
flag probably shouldn't be set for non-RGB images. Nice!
from libvips.
Related Issues (20)
- Conversion to PFM gives incorrect output HOT 2
- Improve `tilecache` performance
- JXL Support in Libvips Web Build HOT 3
- vips: unknown action "dzsave", vips-8.15.1 on Gentoo HOT 1
- Row sums from vips_project do not necessarily give the same value like summing img(i,j) along i HOT 2
- Looks like 8.15.2 tag is wrong? HOT 1
- vips 8.15.2 failed to build with latest xcode HOT 11
- HDR AVIF to HEIC (hdr) HOT 4
- Feature request: Support SDR→HDR via RTX HDR (upmapping / inverse tone mapping)
- AVIF with bitdepth 10 or 12 crashes
- Add nclx->icc colour management to heifload HOT 24
- Segmentation fault when performing very large number of operations HOT 1
- Subsample mode not working with jpegli HOT 4
- Add target write to `rawsave` HOT 2
- Cannot link to proper libraries on Windows 11 Pro. HOT 1
- Thumbnail/Resize removes color on Alpine HOT 1
- Add support for fractional tiff values (eg. 10 or 12 bits per pixel) HOT 6
- Include JXL as Foreign TIFF Compression HOT 3
- The position of "#include <vips/vips8>" matters. HOT 2
- distance transform HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from libvips.