Commit Graph

206 Commits

Author SHA1 Message Date
Kleis Auke Wolthuizen 4176ab2106
tiff2vips: avoid `g_assert_not_reached` in the default clause (#3064)
Since that could terminate the application in debug builds. Also,
add the missing case clause for `PHOTOMETRIC_MINISWHITE`.

Resolves: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=51013.
2022-09-24 13:36:02 +01:00
Lovell Fuller c9de7b2b15
tiff2vips: ensure stdint.h in included for uint32_t (#3040) 2022-09-11 13:41:30 +01:00
John Cupitt a7e754162a
move tiff decompress outside lock (#2969)
* move tiff decompress outside lock

Most time in TIFF read is spent in decompression. If we move this
outside the lock, we can get a useful speedup.

This commit adds the machinery to move the lock to before decompress, so
jp2k decompression is now threaded.

Before:

```
$ vips copy wtc.jpg x.tif[tile,compression=jp2k]
$ time vips avg x.tif
117.249845
real	0m15.085s
user	0m16.155s
sys	0m0.109s
```

After:

```
$ time vips avg x.tif
117.249845
real	0m1.207s
user	0m18.384s
sys	0m0.369s
```

* start moving jpg decode outside the lock

* move jpeg decompress outside the lock

seems to work

* add some more tile size checks

double-check jpeg tile size before decode

* fix tiffload demand hinting

We were not setting the hint correctly in header load, and we were not
hinting smalltile for tiled TIFFs.
2022-09-03 13:10:58 +01:00
John Cupitt 6eae6fcf4b stop strip tiff read using tiny tiles
Strip TIFFs with rowperstrip of 1 used to use 1-pixel high cache tiles.
This could slow reading. This patch sets a minimum tile height near 16
but a multiple of the strip size.
2022-04-09 16:38:47 +01:00
Kleis Auke Wolthuizen 0337c09700
Cleanup gettext handling (#2695)
Use GLib's i18n support instead of copying and pasting that
logic into its own header. This deprecates the vips/intl.h
header in favour of glib/gi18n.h.
2022-02-27 15:27:28 +00:00
John Cupitt 0c70f3dc7d
add fail-on : better control over loader error handling (#2360)
Instead of a simple fail/don't-fail boolean switch, add fail-on, an enum which sets the sensitivity of loaders to errors. 

There's a new sensitivity level which tries to detect truncated images, but ignores other types of error.
2021-10-31 14:13:18 +00:00
John Cupitt 1192d87acf remove old libtiff numeric defines
use the glib ones instead rather than depending on stdint etc.
2021-10-01 17:29:43 +01:00
John Cupitt 08742ec304 fix tiff load of tiled packed formats
we were not checking if formats needed repacking for tiled load
2021-09-30 09:48:25 +01:00
John Cupitt 3d77c6abaa tiny layout fix 2021-08-05 11:24:29 +01:00
John Cupitt a8c45be816 fix arg type for TIFFTAG_SUBIFD
We were passing int* when TIFFGetField wanted unit16, so subifd counts
could sometimes be wrong.
2021-06-28 16:43:55 +01:00
John Cupitt 0d7dd3be7c limit jxlload image size
We were not checking the reported image size against VIPS_MAX_COORD,
leading to some glib out-of-range errors downstream.
2021-05-08 15:25:53 +01:00
John Cupitt edcdf8af70 rebase add-jp2ktiff on master 2021-04-26 15:16:20 +01:00
John Cupitt 91d9610a55 fix out of bounds read in tiffload
libtiff can change the value of some fields while scanning a corrupt
TIFF file and this could trigger an out of bounds read.

This patch makes tiffload more cautious about rescanning a TIFF
directory before reading out header fields.
2020-11-03 11:48:21 +00:00
Kleis Auke Wolthuizen 9246094033 Fix function pointer cast issues
It is undefined behavior in C and C++ to cast a function pointer
to another type and call it that way. This does work in most native
platforms, however, despite it being UB, but in WASM it can fail.

See:
https://emscripten.org/docs/porting/guidelines/function_pointer_issues.html
2020-06-30 13:35:41 +02:00
John Cupitt e129dfc27a fix TIFFReadScanline() call
We were passing in 0 instead of -1, which could trigger an assert in
libtiff with some logluv images.

Also, fix logluv decode. We were not always resetting the decode format.
2020-06-21 12:17:05 +01:00
John Cupitt 19077b53ac revise tiff2vips 1/2/4 bit load
simpler, faster, smaller
2020-06-17 13:59:02 +01:00
John Cupitt 8b469b4516 adjust formatting of 2, 4 bit tiff load/save
To make it libvipsey. Small fixes as well.
2020-06-16 18:58:27 +01:00
Florian Heinrich 00bd91a3c4 Fixed issues with bitdepth 2020-06-16 16:21:52 +02:00
Florian Heinrich 035e0bc756 Added read and write functionality for 2 and 4 bit greyscale TIF images 2020-06-09 11:23:28 +02:00
John Cupitt 981d5c4b16 revise autorot system
- deprecate vips_autorot_get_angle() since orientation is no longer a
simple rotate
- add vips_image_get_orientation() and vips_image_get_orientation_swap()
- revise tiff and jpeg loader autorotate to just call vips_autorot(),
but only if necessary
- revise thumbnail autorotate too
2020-06-06 17:25:46 +01:00
John Cupitt c82be3d30e read tiff metadata more carefully
we were not always fetching the root metadata
2020-06-04 05:07:34 +01:00
John Cupitt 6e1fd6136d safer directory set in tiff load 2020-06-03 16:41:29 +01:00
John Cupitt 6d5a371147 add some tests for subifd pyramids
fix a problem with jpg-compressed tiffs too
2020-06-02 18:08:34 +01:00
John Cupitt d74fe71764 better thumbnail behaviour for subifd pyramids 2020-06-02 14:23:14 +01:00
John Cupitt 460e1d0bf5 set n-subifds for tiff files
says how many subifds in the first page
2020-06-01 17:22:10 +01:00
John Cupitt d16f1e67dd fix tile clipping in toilet roll images
we were not clipping unaligned tiled correctly
2020-06-01 13:22:51 +01:00
John Cupitt 0bdd2290a0 fix tiff directory mixup
we were not always selecting the correct read directory
2020-06-01 00:39:15 +01:00
John Cupitt f0d4b36d7d better tiled tiff detection
for tiffs with mixed strip and tile images
2020-05-29 18:30:49 +01:00
John Cupitt dc29f8dde6 add subifd select to tiff load 2020-05-28 12:40:31 +01:00
John Cupitt 86bfadd101 better handling of unaligned tiff tile reads
We were not checking for alignment correctly in multi-page tiff reads.

Thanks petoor.

See: https://github.com/libvips/pyvips/issues/172
2020-04-11 14:36:44 +01:00
John Cupitt 81fa983121 oop, dropped an "else" 2020-01-29 18:12:37 +00:00
John Cupitt a158b15b97 add LOGLUV TIFF support
libvips XYZ images load and save as libtiff LOGLUV

see https://github.com/libvips/libvips/issues/1506
2020-01-29 17:47:08 +00:00
John Cupitt 8752a76e66 fix a race in tiled tiffload and pdfload
We weer minimising sources in the ::minimise handler, but this is called
outside the lock that protects _generate. This patch removes minimise in
this case.

See https://github.com/kleisauke/net-vips/issues/53
2020-01-14 18:06:12 +00:00
John Cupitt 1338def535 fix some autorot issues
and a problem with vipsthumbnail of tif

see https://github.com/libvips/libvips/issues/1515
2020-01-07 09:00:14 +00:00
John Cupitt 252996e3ff make check passes after stream -> source rename 2019-12-30 12:48:20 +00:00
John Cupitt 4c5873809f experiment with renaming stream
rename as VipsConnection, VipsSource, VipsTarget etc.

see https://github.com/libvips/libvips/issues/1494#issuecomment-569498619

renamed with this script:

```

set -e

edit() {
        sed -i -E "$1" rename
}

for i in $*; do
        cp $i rename

        edit s/VIPS_STREAMOU/VIPS_TARGET_CUSTOM/g
        edit s/VIPS_STREAMO/VIPS_TARGET/g
        edit s/VIPS_STREAMIU/VIPS_SOURCE_CUSTOM/g
        edit s/VIPS_STREAMI/VIPS_SOURCE/g
        edit s/VIPS_STREAM/VIPS_CONNECTION/g

        edit s/vips_streamou/vips_target_custom/g
        edit s/vips_streamo/vips_target/g
        edit s/vips_streamiu/vips_source_custom/g
        edit s/vips_streami/vips_source/g
        edit s/vips_stream/vips_connection/g

        edit s/VipsStreamou/VipsTargetCustom/g
        edit s/VipsStreamo/VipsTarget/g
        edit s/VipsStreamiu/VipsSourceCustom/g
        edit s/VipsStreami/VipsSource/g
        edit s/VipsStream/VipsConnection/g

        # eg. VIPS_TYPE_STREAM or VIPS_IS_STREAM
        edit "s/VIPS_([A-Z]+)_STREAMOU/VIPS_\1_TARGET_CUSTOM/g"
        edit "s/VIPS_([A-Z]+)_STREAMO/VIPS_\1_TARGET/g"
        edit "s/VIPS_([A-Z]+)_STREAMIU/VIPS_\1_SOURCE_CUSTOM/g"
        edit "s/VIPS_([A-Z]+)_STREAMI/VIPS_\1_SOURCE/g"
        edit "s/VIPS_([A-Z]+)_STREAM/VIPS_\1_CONNECTION/g"

        edit s/streamou/target_custom/g
        edit s/streamo/target/g
        edit s/streamiu/source_custom/g
        edit s/streami/source/g

        # various identifiers which also change
        edit s/is_a_stream/is_a_source/g
        edit s/find_load_stream/find_load_source/g
        edit s/find_save_stream/find_save_target/g
        edit s/new_from_stream/new_from_source/g
        edit s/write_to_stream/write_to_target/g
        edit s/vips_thumbnail_stream/vips_thumbnail_source/g

        # eg. vips_webpload_stream
        edit "s/vips_([a-z]+)load_stream/vips_\1load_source/g"

        # eg. vips_webpsave_stream
        edit "s/vips_([a-z]+)save_stream/vips_\1save_target/g"

        mv rename $i
done
```
2019-12-29 21:40:21 +00:00
John Cupitt 8f95b08218 put seq access back in to tilecache
We removed seq mode from tilecache a few months ago as part of a
simplification, but it turns out it's needed for vips_sequential().

see https://github.com/libvips/libvips/issues/1494#issuecomment-565099645
2019-12-17 16:58:31 +00:00
John Cupitt 112dc9101a remove early shutdown from tiff reader
since streams do this automatically now
2019-12-13 14:19:09 +00:00
John Cupitt 40bffa8cc6 small reformats
plus remove save multiband as separated multiink
2019-12-07 17:41:53 +00:00
Angel Sánchez c85454f56c Merge branch 'refs/heads/master' into improve-file-formats
# Conflicts:
#	libvips/conversion/switch.c
2019-12-04 11:49:18 +01:00
John Cupitt 486b95eb7b
Merge branch 'master' into add-stream-object 2019-11-19 17:08:03 +00:00
John Cupitt 712157cd16 better support for TIFFs with many alphas
The premultiplied alpha can be in any position, and it checks if there
is more than one ASSOCALPHA.

See https://github.com/libvips/libvips/issues/1471
2019-11-18 16:48:34 +00:00
Angel Sánchez fa0514a4d4 enable separated/multiband load and save for tiff format 2019-11-13 16:16:22 +01:00
Angel Sánchez 6df26bfc9b load lab 8bit with alpha to labS 2019-11-12 18:02:52 +00:00
Angel Sánchez c7b286ff8e Revert "improve labpack processing"
This reverts commit c4dd47aa99ea32acacc55fa793d7a5764b3a4aa8.
2019-11-12 17:35:16 +00:00
Angel Sánchez 4b7bd0810b Revert "correctly parse labQ with extra channels"
This reverts commit a817b3874e695bacc2f38d351d93e917373631e5.
2019-11-12 17:35:16 +00:00
Angel Sánchez 4ba6373357 correctly parse labQ with extra channels 2019-11-12 17:35:16 +00:00
Angel Sánchez 415af7a10c improve labpack processing 2019-11-12 17:35:16 +00:00
John Cupitt f5a4f41edf rename VipsStream* variables
The convention is now:

	VipStreami *streami;

We had `input` in many places, a left-over from the old VipStreamInput
name.
2019-11-11 09:09:34 +00:00
John Cupitt ba0100eb13 revise decode/unminimise use 2019-10-28 05:04:04 +00:00