Commit Graph

165 Commits

Author SHA1 Message Date
Joshua Sager 608a7cee9b
Introduce unlimited flag, enabling unlimited text chunks in PNGs (#2419)
* Introduce unlimited flag, enabling unlimited text chunks

* remove extraneous optional flag causing GLib-GObject-CRITICAL **: 17:10:34.095: validate_and_install_class_property

* Address feedback from @jcupitt

* various compilation error fixes

* Interlace detection uses unlimited=false

* attempt to fix tests

* documentation changes, introduced MAX_PNG_TEXT_CHUNKS and bumped max to 20 (was 10)
2021-08-29 18:06:33 +01:00
John Cupitt 1ce301812d Merge branch '8.11' 2021-08-06 17:00:24 +01:00
John Cupitt fd1a036cd8 limit number of PNG chunks
reduces the threat of PNG decompression bombs
2021-08-06 10:55:08 +01:00
John Cupitt e93a23e0b7 Merge branch '8.11' 2021-08-05 12:29:11 +01:00
John Cupitt 5263686511 limit the number of text chunks in PNGs
very large numbers of text chunks can cause high memory use
2021-08-05 12:28:22 +01:00
Lovell Fuller aabb1555d2
pngsave: expose quantisation effort setting (#2367) 2021-07-30 10:43:42 +01:00
John Cupitt 757d031005 always check the return of vips_image_pipeline()
For consistency. Although I don't think it can meaningfully fail.
2021-06-29 16:12:17 +01:00
John Cupitt 8dc2db9789 add gif background colour as metadata 2021-02-20 04:52:02 +00:00
John Cupitt d6201fc32d note PNG background colour in metadata
see https://github.com/libvips/libvips/issues/2111
2021-02-19 16:51:46 +00:00
John Cupitt 65cab8db7d tiny cleanups for png write 2021-02-07 15:23:46 +00:00
Kleis Auke Wolthuizen 9b9843f698 Exclude libpng load when building with libspng
Similar to ce63fc1, but allowing libpng to be configured with
-DPNG_NO_READ (i.e reading functionally disabled).
2020-12-29 13:34:22 +01:00
John Cupitt 4de9b56725 flush target at end of write
we were missing end-of-write flushes on four save operations

thanks harukizaemon

see https://github.com/libvips/ruby-vips/issues/256
2020-11-04 09:28:25 +00:00
John Cupitt 17cddc196b improve pngload error messages too
see https://github.com/libvips/libvips/issues/1578
2020-07-23 15:41:20 +01:00
John Cupitt 70c0b36d4f better pngsave error message
add a target name to png's "unable to write to target" message

see https://github.com/libvips/libvips/issues/1578
2020-07-23 15:26:11 +01:00
John Cupitt 36ac84ee6f fix spngload default ppm 2020-07-15 10:56:34 +01:00
John Cupitt 4bf27acccb add 1/2/4 bit PNG save
- new @bitdepth param
- deprecate @colours param
2020-06-25 10:40:43 +01:00
John Cupitt b9385b9d35 only warn on png save with a bad profile
Previously we failed. This is very ugly, but it seems to be the only
obvious way to fix this.

See https://github.com/libvips/libvips/issues/1578
2020-05-11 18:00:26 +01:00
John Cupitt 9e6df7e0a6 revise png comments 2020-02-07 17:53:42 +00:00
John Cupitt ecb22cdecc free png write on end of write, not image dispose
We were freeing the PNG write struct on image dispose, not at the end of
write.

Thanks homm. See https://github.com/libvips/pyvips/issues/147
2020-01-02 15:51:42 +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 0429a0080e swap ssize_t for gint64 where possible
Some versions of the Windows headers define ssize_t as unsigned. This
patch removes (where possible) use of ssize_t inside libvips, esp. in
the new stream API.

See https://github.com/libvips/libvips/issues/1494#issuecomment-568254731
2019-12-22 13:45:45 +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 3d344b4b5f add Kleis's patches
and add minimise support to radiance load
2019-11-06 17:04:13 +00:00
John Cupitt ba0100eb13 revise decode/unminimise use 2019-10-28 05:04:04 +00:00
John Cupitt ee3270f8e9 more refactoring 2019-10-22 11:08:54 +01:00
John Cupitt f99f3d3f57 revise seek() behaviour
fuzz tests fail though ... we need to split StreamInput up
2019-10-17 17:18:45 +01:00
John Cupitt 696ff2b24a fix up jpeg load
and revise descriptor test
2019-10-17 13:16:12 +01:00
John Cupitt 88aa1bca86 polish png read 2019-10-15 08:33:48 +01:00
John Cupitt c3e1dd47bf fix test suite
passes now
2019-10-14 21:01:25 +01:00
John Cupitt 55d2ba8a4d start adding png stream save
doesn't pass the test suite yet
2019-10-14 18:32:41 +01:00
John Cupitt 1bdadeed61 add png stream load 2019-10-14 18:03:45 +01:00
John Cupitt c92a71cb98 fix pngload segv on header error 2019-10-07 14:58:49 +01:00
John Cupitt 3510c515f2 oop deleted one png init too many 2019-10-07 13:30:19 +01:00
John Cupitt fef3dae892 Revert "fix up png restart"
This reverts commit 120ba3289c.
2019-10-07 13:15:29 +01:00
John Cupitt 120ba3289c fix up png restart
hopefully ... we needed a png_init_io() as well
2019-10-07 12:11:45 +01:00
John Cupitt 2d374c3114 pngload supports restart after minimise
plus a test
2019-10-07 10:01:15 +01:00
John Cupitt d290c971ab reorganise vipspng a little
so we only set max malloc in one place

see https://github.com/libvips/libvips/pull/1424
2019-09-11 14:56:32 +01:00
Matt Drollette e233698c2b also set png max chunk malloc when reading buffer 2019-09-10 12:31:11 -05:00
John Cupitt c361731693 better support for very long PNG comment names
pngs can have names comments -- improve support for very long comments.
2019-08-02 05:40:40 +01:00
John Cupitt 5ef14db544 put close-on-last-line back for jpg/tif/png
consider something like:

$ vips arrayjoin "$(echo *.jpg)" x.tif --across 10 --vips-progress

close on minimise won't close until the whole pipeline finishes, so
we'll need to keep every input file open

close on last line will shut down inputs as we are done with them, so we
save a lot of file descriptors

this patch puts close-on-last-line back for jpg/tif/png
2019-07-28 11:34:40 +01:00
John Cupitt 28090d614f oops logic mixup
Kleis pointed out a suprious return in png load minimise.

see https://github.com/libvips/libvips/issues/1370#issuecomment-513706480
2019-07-23 12:06:35 +01:00
John Cupitt 7f3174c3e5 Merge branch 'master' into loader-minimise-experiment 2019-07-23 11:45:24 +01:00
John Cupitt 2c654060f9 experiment with a different early-close strategy
We close loaders early in order to save file handles, and on Windows to
make sure that files can be deleted as soon as possible.

Currently loaders do this by watching the Y coordinate of requests and
freeing the fd when the final line of the file is fetched. This is messy
and does not always work, since there are cases when the final line is
not fetched.

Instead, this patch gets loaders to listen for "minimise" on their
output and close on that. This signal is emitted on all upstream images
whenever a threadpool finishes a scan of an image and is usually used to
trim caches after computation.

See https://github.com/libvips/libvips/issues/1370
2019-07-20 16:31:30 +01:00
Oscar Mira f3cdf25923 disable PNG CRC checks in fuzzing mode 2019-07-15 14:02:27 +02:00
Lovell Fuller aff0c4cde5 Ensure png_set_interlace_handling before png_read_update_info 2019-04-26 22:29:16 +01:00
John Cupitt 8fbbfd752f set png chunk limit to 50mb
we did have it unlimited, which could perhaps leave us open to DOS
attacks
2019-04-20 10:29:24 +01:00
John Cupitt ee854d43c4 add configure test for png_set_chunk_malloc_max 2019-04-20 06:07:18 +01:00
John Cupitt 8d7e03237a allow huge png metadata chunks
By default, libpng refuses to open files with a metadata chunk larger than
8mb. Disable this sanity check.

See: https://github.com/lovell/sharp/issues/1664
2019-04-20 05:54:37 +01:00
John Cupitt 57ce5a3343 set interlace flag for interlaced pngs
if libpng is recent enough
2019-03-20 21:50:56 +00:00