Commit Graph

2049 Commits

Author SHA1 Message Date
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 47383b5bfc
tell buffer and target savers the file format (#2499)
tell buffer and target savers the file format

Currently, buffer and target savers are not told the format they should
write.

This is usually OK (the JPEG saver already knows it should write JPEG),
but some savers can write several formats, and these currently need an
extra parameter.

For example:

```ruby
buf = x.write_to_buffer ".bmp", format: "bmp"
```

The first ".bmp" gets libvips to pick magicksave, the second
`format:` param is necessary to tell magicksave to write BMP.

This patch adds stub subclasses so that the savers know the exact format. It also improves PPM save.
2021-10-28 18:57:24 +01:00
John Cupitt 1f321d366b disable webp shrink-on-load if it will judder
Webp decode can only shrink-on-load to int boundaries. This means that frames
in an animation which only update part of the canvas can get displaced by
up to 0.5 pixels, causing juddering.

see https://github.com/libvips/libvips/issues/2379
2021-10-27 13:25:04 +01:00
John Cupitt ba3bc3099c raise single-chunk limit in jpeg save
It was 65530 for some reason. It's now 65533.

See https://github.com/libvips/libvips/issues/2493
2021-10-21 15:08:48 +01:00
John Cupitt 53ee983b51 oop, debug left enabled by mistake 2021-10-20 14:28:15 +01:00
John Cupitt 96604dba10 turning on subifd enable pyramid mode
see https://github.com/libvips/pyvips/issues/277
2021-10-20 10:40:03 +01:00
John Cupitt cf1228b927 fix page_height arg for tiffsave
it wasn't wired up, thanks @jacopoabramo

see https://github.com/libvips/pyvips/issues/277
2021-10-20 10:18:22 +01:00
John Cupitt 0f3193b7f2
Add iiif3 (#2483)
* add iiif3 support to dzsave

some small things have changed from v2
2021-10-19 14:18:40 +01:00
John Cupitt b2527da531
allow utf-8 header for svg detection (#2481)
* allow utf-8 header for svg detection

We were checking that the first 24 chars of an SVG were plain ASCII,
but that's not always the case, for example:

	<svg id="レイヤー_1のコピー"
		data-name="レイヤー 1のコピー"
		xmlns="http://www.w3.org/2000/svg"
		viewBox="0 0 100 100">
	</svg>

We now test for the string "<svg" being in the first 1000 bytes, and
everything up to that being valid utf-8.

See https://github.com/libvips/libvips/issues/2438

* raise priority of webpload

it was very low priority before, for some reason
2021-10-15 13:21:50 +01:00
John Cupitt 251e1d1d32
cgifsave per frame cmap (#2445)
switch GIF save to frame at a time

And make a new colormap if the frame average changes. This keeps memory use low, even for very large GIFs, though is somewhat slower.

See https://github.com/libvips/libvips/pull/2445
2021-10-14 15:46:52 +01:00
Lovell Fuller b98366fcb1
Switch to memmove as input buffer can overlap (#2476) 2021-10-12 17:24:40 +01:00
John Cupitt bd8fad842a call JxlEncoderInitBasicInfo
new mandatory API for libjxl v0.6
2021-10-12 17:10:55 +01:00
John Cupitt 444a04e94f formatting, another MCU test 2021-10-08 17:58:17 +01:00
David Manthey 46a67cfab9
Add jpeg restart_interval option. (#2468)
* Add jpeg restart_interval option.

This allows saving a jpeg with MCU restarts.

* Fix code style.  Add description of restart_interval.

* Add a basic test based on output length.

* Update main change log.
2021-10-08 17:33:32 +01:00
John Cupitt f6281284a1 fix VipsSource and named pipes
We used to assume (in several places) that any source with a filename was
seekable. This patch adds a is_file test, and makes all the loaders use it.

see https://github.com/libvips/libvips/issues/2467
2021-10-08 12:20:24 +01:00
John Cupitt 60bae63644 updale libnsgif from upstream
seems slightly slower overall
2021-10-07 10:48:12 +01: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 33cca3ecbc fix jxload restart
if the loader was restarted (eg by vipsdisp) it could fail to fetch pixels
2021-10-01 12:36:02 +01:00
John Cupitt 6a53ab47e1 allow container jxl as well
We were not testing the jxl signature for the two types of jxl.

see https://github.com/jcupitt/vipsdisp/issues/5

thanks Fraetor
2021-10-01 06:53:37 +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 5397fe5a4f note tiff change in changelog 2021-09-29 17:49:26 +01:00
John Cupitt be0b0d17b8 better tiff write looping
We were looping over pages, cropping each one out, and saving.

Now there's a single loop for thw whole of the image, so things like
percent reporting work in the obvious way.

See https://github.com/libvips/libvips/issues/2450
2021-09-29 17:45:58 +01:00
John Cupitt 1caad7f228 Merge branch '8.11' 2021-09-13 15:00:21 +01:00
John Cupitt 15416c410d raise the PNG text chunk limit
Raise the PNG text chunk limit to 50, since it seems some real images
have a text chunk per line of exif data.

See https://github.com/libvips/libvips/issues/2433
2021-09-13 14:40:20 +01:00
John Cupitt 7c0ec04b71 fic gtk-doc typenames in cgif 2021-09-12 16:03:32 +01:00
Kleis Auke Wolthuizen 5ab66e16e1
Fix UBSan errors (#1948)
* Ensure UBSan exits with a non-zero code on error

* Avoid misaligned member access in mosaic_fuzzer

* Add missing VIPS_CLIP in scRGB2sRGB/scRGB2BW

* Fix UBSan error in flatten

By using saturated casts for the int types (copied from vips_cast).

* CI: ensure fuzzer log is printed on error

* Avoid UB in heifload

* Revert flatten change

I could no longer reproduce this with clang 12 locally.

* Indentation fixes [skip ci]
2021-09-12 13:14:24 +01:00
Lovell Fuller f7619cf33e
gifsave: expose bitdepth property (#2429)
Provides control over the maximum number of colours in the output
image palette, making the API more closely match that of pngsave.

Lowering the bitdepth to 7 (from the default value of 8), which
halves the maximum number of colours from 255 to 127, typically
reduces encoding time by ~20%.
2021-09-10 08:57:12 +01:00
John Cupitt f2dd4471eb tiny code format changes 2021-09-07 13:54:59 +01:00
Lovell Fuller e16cb5bfe5
quantise: optional thresholding of alpha channel (#2425)
Moving this logic from gifsave to quantise improves
the performance of writing RGBA GIFs by ~15%
2021-09-07 12:23:42 +01:00
Lovell Fuller affc2400ed
heifload: switch demand to thinstrip (#2424)
Ensures decoding errors halt processing
2021-09-05 12:42:55 +01:00
Lovell Fuller 4d079f1691
gifsave: use cgif namespaced API (#2422)
See https://github.com/dloebl/cgif/pull/18
2021-09-03 12:04:28 +01:00
John Cupitt b9230edcbe Merge branch '8.11' 2021-08-29 19:13:12 +01:00
John Cupitt 451cfcd282 small cleanups from "unlimited" option 2021-08-29 19:08:51 +01:00
Joshua Sager bb88490a17 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:41:49 +01:00
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 b0b8e6ee65 small style changes 2021-08-23 01:14:37 +01:00
Lovell Fuller 1f5d6f6bc9
Add gifsave operation, depends on cgif and libimagequant (#2381) 2021-08-22 18:11:41 +01:00
John Cupitt 9d186c9cd4 Merge branch '8.11' 2021-08-14 18:17:11 +01:00
John Cupitt 57d8dd3ece better jp2k save behaviour
- don't enable mct if subsampling is on
- don't make such deep pyramids
2021-08-07 18:46:50 +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
John Cupitt 3d77c6abaa tiny layout fix 2021-08-05 11:24:29 +01:00
John Cupitt 8082063607 rename webp reduction-effort as effort
though effort still works
2021-07-30 11:07:43 +01:00
John Cupitt ff1260df1c rename heifsave "speed" param as "effort"
For consistency with the rest of libvips. "speed" still works.
2021-07-30 10:59:12 +01:00
Lovell Fuller aabb1555d2
pngsave: expose quantisation effort setting (#2367) 2021-07-30 10:43:42 +01:00
John Cupitt 9221fae973 remove some stray dbg code
accidentally committed previously
2021-07-29 13:19:11 +01:00
John Cupitt b4582dbdaa set CFLAGS for magick API detect
since it will try to compile and link code fragments
2021-07-29 13:12:29 +01:00
Lovell Fuller 81009d3e4c heifload: verify page dimensions are non-zero 2021-07-25 21:47:55 +01:00