Commit Graph

64 Commits

Author SHA1 Message Date
John Cupitt 2c4c039056 add "unlimited" to jpegload
To disable DoS limits for JPEG loading. Adding API on a stable branch is
bad, but this fixes a regression, so I think it's necessary,
unfortunately.

See https://github.com/libvips/libvips/issues/2973
2022-08-02 13:50:09 +01:00
Kleis Auke Wolthuizen 1214f942f9
Prefer to use `flags |=` everywhere (#2854)
Use the bitwise OR assignment operator to ensure that derived
classes does not overwrite the flags from the base class. Also,
move the flags from `openslideload_source` to its base class.
2022-06-11 15:40:39 +01:00
John Cupitt 460a19b78e revise arg names
use _ everywhere (we have a few uses of - as a separator)
2022-05-07 14:50:05 +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 cb58d7d960 _source loaders should all be nocache
When we image_new_from_source, the source object has some of the loader
state: it tracks the current read position of the load library. This
means that we mustn't keep source loaders in the operation cache, since
a second call could give a different result because the source object
read position might have changed.

Also: add a rewind to get_flags_source in spngload, and jp2k needs to
tag its load region as having no thread ownership or you'll get assert
fails in the test suite with debug enabled.
2021-11-19 13:55:49 +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 633abe7be8 add missing funcs to public C API
The C API was missing vips_jpegload_source and vips_svgload_source.
Thanks to augustocdias.

See https://github.com/libvips/libvips/issues/1780
2020-08-14 13:36:12 +01:00
John Cupitt 119dd2cb72 pytest passes again after stream -> source/target 2019-12-29 23:08:33 +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 96079202ef rework jpegload class
to match the radload pattern
2019-12-24 09:21:22 +00:00
John Cupitt 561f410f0a rework pngload
To match the new radload pattern.
2019-12-24 07:55:06 +00:00
John Cupitt 562da3e5ab rename new_from_filename as new_from_file
So VipsStreami matches VipsImage. Same for new_to_filename.
2019-11-22 17:13:20 +00:00
John Cupitt b8ea3f8442 update cpp interface for stream variable rename 2019-11-11 09:24: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 ee3270f8e9 more refactoring 2019-10-22 11:08:54 +01:00
John Cupitt 1bdadeed61 add png stream load 2019-10-14 18:03:45 +01:00
John Cupitt f6d247627f incorporate revision comments from @kleisauke
Thanks!
2019-10-14 12:18:40 +01:00
John Cupitt d991b73ac5 jpegsave_stream mostly done
$ vips jpegsave_buffer x.jpg

doesn't work though -- need to rethink how output blobs are made
2019-10-11 18:17:42 +01:00
John Cupitt 20cb0da247 test suite passes
with all jpegload coming via VipsStreamInput
2019-10-11 14:03:10 +01:00
John Cupitt 6c1d7db31b remove old jpeg load stuff
it's just stream now

works on buffer, but seems to fail on

	vipsheader йцук.jpg

curiously
2019-10-11 09:43:12 +01:00
John Cupitt 442720a0a1 add magic "-" stdin filename
this almost works!

$ vips invert - x.jpg < k2.jpg
2019-10-11 05:38:58 +01:00
John Cupitt 3a2bebdffb jpegload_stream registers 2019-10-10 22:02:39 +01:00
John Cupitt 387cafa738 add jpegload_stream 2019-10-10 20:42:39 +01:00
John Cupitt 3d889d9395 docs for heifload autorotate 2019-03-07 08:12:14 +00:00
John Cupitt e106e1d100 add n/page params to webpload
and renumber all optional load args
2018-11-01 20:43:07 +00:00
John Cupitt 4f22e8d1dc add jpeg-chroma-subsample to jpegload
The jpeg loader now sets the field jpeg-chroma-subsample to record
chroma subsample.

See https://github.com/jcupitt/libvips/issues/954
2018-04-25 16:04:20 +01:00
John Cupitt a128149009 Merge branch '8.6' 2017-12-31 10:39:36 +00:00
John Cupitt 77287a938f fix misspelling of IPTC as IPCT
the letters have been accidentally swapped for years

add a compat macro so older code still works
2017-12-31 10:23:27 +00:00
John Cupitt af51114352 remove duplicate jpeg suffs definition 2017-12-23 14:27:56 +00:00
Alistair Thomas 0506c49444 Update GObject introspection annotations for libvips/foreign directory 2017-09-26 23:39:06 +01:00
John Cupitt 942b0446a3 revise fail handling, again
clarify policy on file read errors and warnings:

* if the file format library reports a warning, we log it in vips, but
that's all
* if the file format library reports an error, we log it, but try to
continue
* if the file format library reports an error and fail is set, we log it
and fail

all loaders now implement this
2017-05-12 17:22:49 +01:00
John Cupitt 362c7efdfc argh reapply seq removal 2017-03-06 11:55:38 +00:00
John Cupitt 98f5421c10 Revert "remove readbehind"
This reverts commit cb83918a3f.
2017-02-27 10:24:56 +00:00
John Cupitt cb83918a3f remove readbehind 2017-02-21 17:14:33 +00:00
John Cupitt 756e69cf96 make pngload from buffer set flags
and remove some dead code from jpegload
2017-01-27 11:15:48 +00:00
John Cupitt bb0a6643f9 move @fail from jpegload into the base load class
and add fail support to csv and openslide

see https://github.com/jcupitt/libvips/issues/546
2016-11-12 15:33:35 +00:00
John Cupitt c90b8be0b8 add tiffsave_buffer
add tests

also some cleanups to foreign include files

see https://github.com/jcupitt/libvips/issues/417
2016-10-15 12:29:14 +01:00
John Cupitt 916e5b5589 set filename on file read for more types
the new loaders were missing the line to set the output filename, so
`vipsheader fred.pdf` was not displaying the filename correctly
2016-06-01 09:14:01 +01:00
John Cupitt d51911cda8 fix up orientation docs
document the new orientation system

various tiff/jpeg doc fixups too
2016-05-28 11:17:17 +01:00
John Cupitt 5a9f2c787b compiles
needs testing etc.
2016-05-26 14:58:04 +01:00
John Cupitt 50468a07a2 clean up foreign
various cosmetic changes:

- pngsave_buffer now uses Write, not WriteBuf, same change for
  radsave_buffer

- move C wrappers out to class defs from foreign.c

- use g_free() not vips_free() for buffer free from low-level savers

- fix var names in some comments

- various style changes for radiance.c
2016-05-24 10:57:02 +01:00
John Cupitt 90536d2268 try openslide before jpeg
MRXS images are also JPEG images, so we need to have openslide before
libjpeg in the file test order.

See https://github.com/jcupitt/libvips/issues/406
2016-03-29 17:26:22 +01:00
John Cupitt 01238a0fd5 more progressive jpg changes
- Remove the nocache stuff for prog jpg images. There was no saving in
  practice, since operations downstream could be cached.

  nocache is for objects that can change, not for memory saving

- Call _destroy on the decompress object much earlier, it frees a huge
  amount of memoey for prog jpg images.
2016-02-21 10:57:36 +00:00
John Cupitt 0a4991cbc0 oops, put the flags test on a subclass 2016-02-18 19:12:00 +00:00
John Cupitt 6f94cb5ed4 don't cache progressive jpg images
progressive jpg images need loads of memory, we shouldn't cache them by
default ... our called can hold a ref if they want to keep the image
around

see https://github.com/jcupitt/libvips/issues/387
2016-02-18 19:00:19 +00:00
John Cupitt 6ca9a907b8 reorder load tests
and a slight memory saving on ifthenelse
2016-01-13 20:32:23 +00:00
John Cupitt 2b46b7e889 many more const decls
ruby gobject-introspection is quite fussy about needing a lot of const
declarations ... these changes help vips_image_matrix_from_array()
appear in Ruby
2015-10-23 11:45:11 +01:00
John Cupitt 5b90e36559 notes 2015-02-10 14:44:35 +00:00
John Cupitt 14d7ce1e91 first try, not very good 2014-10-16 19:16:45 +01:00
John Cupitt c85dd26627 oops, better filename set on foreign load
we were setting the filename in the wrong place
2014-06-10 13:46:05 +01:00