Commit Graph

44 Commits

Author SHA1 Message Date
John Cupitt 013cf38547 fix ppmload doc comment
ooops! RapidTransit

see https://github.com/libvips/libvips/discussions/3239
2022-12-23 22:44:12 +00:00
John Cupitt 6a154ac9f2 add ".pnm" save
see https://github.com/libvips/libvips/issues/3016
2022-08-30 12:31:47 +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 eba9ec0dd7
Add a way to disable less well tested operations (#2636)
* quick proposal

warn on startup if untrusted operations might run

use vips_block_untrusted_set() to block untrusted operations, set an env
var or make a file to stop the warning

* mark fits, nifti and svg as untrusted

* remove the annoying "untrusted" warning message

better to warn on the download page

leave vips_block_untrusted_set() since it's obviously useful

* separate UNTRUSTED and BLOCKED

* typos

* add VIPS_BLOCK_UNTRUSTED env var

* move BLOCK_UNTRUSTED after plugin load

obviously, ooops

* add a test, disable *magick

although *magick is fuzzed, it's probably safer to disable it in
untrusted environments

* mark some more operations as untrusted
2022-04-11 11:32:32 +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 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 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 a2e5717e82 Merge branch '8.10' 2021-05-05 17:32:25 +01:00
John Cupitt e19acd5148 fix load of large PPM images from a pipe
large PPM images loaded over pipes could cause a crash, thanks ewelot

see https://github.com/libvips/libvips/issues/2240
2021-05-05 17:29:50 +01:00
John Cupitt 8b791a072e two more small refleaks
introduced recently
2021-02-07 16:09:22 +00:00
John Cupitt 158e9e153a add some more ppm tests 2020-12-26 18:35:11 +00:00
John Cupitt b2fa1f89e8 revise ppmload, fixing a couple of bugs
- ppmload was not setting interpretation, filename, etc. for files read via
  mmap
- files not read via mmap were never byteswapped
- some cleanups

see https://github.com/libvips/libvips/issues/1916
2020-12-26 17:02:07 +00:00
John Cupitt 4c1aeaacd9 add is_a_source to ppmload
ppmload_source was missing an ia_a test

see https://github.com/libvips/libvips/issues/1915
2020-12-02 21:02:05 +00:00
John Cupitt 8e25eef3d0 make ppm load default to msb first
We has lsb first as the default, breaking 16-bit PPM load. Thanks ewelot.

see https://github.com/libvips/libvips/issues/1894
2020-11-22 16:00:34 +00:00
John Cupitt 98641ba153 add read loops to gifload
and check for error in ppnmload.
2020-11-12 13:21:33 +00:00
John Cupitt a09027b2a5 forgot to advance the buffer pointers
thanks kleis

see https://github.com/kleisauke/net-vips/issues/101#issuecomment-726046152
2020-11-12 12:32:51 +00:00
John Cupitt ff450497ff add read loops to heif and ppm as well
We were not looping on vips_source_read() in these loaders, so they
could fail when reading from very slow pipes.

See https://github.com/kleisauke/net-vips/issues/101
2020-11-12 12:11:35 +00:00
John Cupitt d831ad34d5 add ppm load/save to a connection
plus some more tests
2020-06-27 15:23:18 +01:00
John Cupitt eb8ec27c86 fix binary ppm read for some width 2020-06-13 11:40:45 +01:00
John Cupitt bb20556b6d ban ppm max_value < 0
Not allowed by spec, since pixels should be unsigned.
2020-02-02 11:13:41 +00:00
John Cupitt 3847f71c54 rename bufis as well 2019-12-30 16:57:19 +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 e48f45187b make RGB and sRGB synonmous
We had a half-baked idea that RGB could mean generic RGB space and sRGB
would mean strict sRGB interpretation.

Unfortunately, this did not work well in practice. For example,
`icc_transform("srgb")` would tag the result as RGB rather than sRGB
(the converter didn't know it was writing sRGB pixels, it just saw
conversion to RGB with an ICC profile), and then later stages would do
unnecessary icc_imports, or worse, fail.

This patch makes RGB and sRGB strict synonyms. If you want to treat an
RGB image as something other than sRGB, you'll need to do it by hand
with the icc_ functions.

See

https://github.com/libvips/pyvips/issues/144

46212e92b1 (r34904985)

https://github.com/libvips/libvips/issues/1494
2019-12-22 11:40:09 +00:00
John Cupitt 45015b002a stray DEBUG 2019-12-14 05:19:18 +00:00
John Cupitt 1fd3b478e1 always check memory area length
vips_image_new_from_memory() allowed you to use length == 0 to mean
"don't check memory length". This was part of some very old vips7
compatibility.

The ppm loader could pass length == 0 if header size was equal to file
size, bypassing the length check.
2019-12-14 05:13:44 +00:00
John Cupitt dd4b2e9c23 fix some clang warnings 2019-12-08 13:08:38 +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 09325600ee rename VipsStreamib as VipsBufis
The VipsStreamib (stream input buffered) was misleading -- it was
implemented on top of VipsStreami, but was not a subclass.

Rename as VipsBufis (buffered input stream). It's a silly name, but
easy to remember and reflects the purpose better,
2019-11-18 13:09:04 +00:00
John Cupitt 6b5035c160 update changelog 2019-11-15 17:30:31 +00:00
John Cupitt 9a3842919a add mmap ppm input 2019-11-15 15:56:28 +00:00
John Cupitt 5f4b995551 make ppm load sequential
it used to load the entire image, or mmap it
2019-11-15 15:15:25 +00:00
John Cupitt 17b994419b move ppm save into the class
no separate save function now
2019-11-15 10:23:45 +00:00
John Cupitt 7a047f5332 move ppm into ppmload
so we can add a ppm stream loader easily
2019-11-14 18:44:27 +00:00
John Cupitt c1a027c8d7 ppm load uses streams 2019-11-14 12:57:39 +00:00
Alistair Thomas 0506c49444 Update GObject introspection annotations for libvips/foreign directory 2017-09-26 23:39:06 +01: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 6368ab0649 add switches to disable rad, analyze and ppm
vips has built-in support for rad, analyze and ppm ... add configure
switches to disable these readers

useful to reduce the attack surface in some applications
2016-03-12 16:48:27 +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 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
John Cupitt 54dcea8c3d fix some clang warnings 2013-11-21 17:43:28 +00:00
Benjamin Gilbert 8cc76a6ba3 Update address for Free Software Foundation
Also update LGPLv2.1 license text from the copy currently on the GNU
website.
2013-03-07 00:40:19 -05:00
John Cupitt 70bde4a90d move ppm read/write to new-style 2011-12-20 09:37:07 +00:00