Commit Graph

311 Commits

Author SHA1 Message Date
Kleis Auke Wolthuizen fc92290bb9
Try the new target API first in `VImage::write_to_buffer` (#2511)
Needed after PR #2499.
2021-11-02 13:36:27 +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 af61d375bc
experiment with removing shutdown from atexit (#2439)
remove shutdown from atexit

Because atexit() can be called at almost any point during process termination,
including after worker threads have been force-quit, we can't use it for
cleanup.

New policy: use vips_shutdown() explicitly if you need to clean up,
though it's optional. Only use atexit() for leak checking.
2021-09-17 19:02:53 +01:00
John Cupitt eca400e953 don't set g_set_prgname()
this should be set in the app layer, not by libraries
2021-06-01 10:29:54 +01:00
Kleis Auke Wolthuizen 2735b71292 Simplify preprocessor directives 2021-04-22 12:04:05 +02:00
Kleis Auke Wolthuizen 3ed50e0427 Cleanup configure.ac and #ifdef's 2021-03-06 15:47:07 +01:00
John Cupitt 8d95f9db2b tiny fixes 2021-02-05 16:56:44 +00:00
John Cupitt 1ca20dbddd make vips format detection a little more robust 2021-01-02 19:07:00 +00:00
John Cupitt df3b80fa40 add vipssave_target() 2021-01-02 15:49:32 +00:00
John Cupitt f6d7af46b8 Merge branch '8.10' 2020-11-24 11:15:45 +00:00
Kleis Auke Wolthuizen 9bb86119e3 Ensure vipsload only byte swaps if necessary
Prior to this commit, MSB-ordered vips images were always byte swapped
on both little- and big endian systems. And LSB-ordered vips images
were loaded without a byte swap. This works correctly on little endian
systems, but will not work on big endian systems where the byte swap
must be done vice versa.

This commit ensures that the byte swap only takes place when needed.

See https://github.com/libvips/libvips/issues/1847.
2020-11-23 14:32:36 +01:00
John Cupitt fd0a0905ff note VImage::new_from_memory_steal() in ChangeLog
plus doxy commnets etc., see https://github.com/libvips/libvips/pull/1758/
2020-09-24 10:44:49 +01:00
Kyle Schwarz b372fde637 Add parameter name for unused image 2020-08-02 11:04:10 -04:00
Kyle Schwarz 292dc9da4b Remove redundant part of comment 2020-08-02 10:20:44 -04:00
Kyle Schwarz 81920963b1 Remove cast in free() call 2020-08-02 10:19:47 -04:00
Kyle Schwarz fe815ff587 Add C++ bindings for new_from_memory_steal()
new_from_memory_steal() will create a new image with the input
buffer and will "move" the data into the image. The buffer is then
managed by the image, and will be freed when it goes out of scope.
2020-08-01 21:58:14 -04:00
Kleis Auke Wolthuizen fb61f0fa44 Define ENABLE_DEPRECATED in config.h
Do not check for VIPS_ENABLE_DEPRECATED as it could
come from an earlier version of libvips.
2020-07-07 12:16:43 +02: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
Kleis Auke Wolthuizen 230d2acfea Disable IM_* environment variables when --disable-deprecated 2020-06-18 14:15:37 +02:00
John Cupitt 9ea91810bb revise docs for _inplace
We call vips_image_inplace() automatically now, so there's no need for
clients to use this.

see https://github.com/libvips/libvips/issues/1610
2020-04-16 12:09:07 +01:00
John Cupitt 51fc2ff64e don't use new source API for new_from_file etc.
We were attempting to load images in new_from_file using the new source
API first, then only falling back to the file loaders if that failed.

However, this meant that we did not respect the priority ordering on
loaders, so openslide iamges (for example) were being loaded by the tiff
loader.
2020-01-09 14:47:14 +00:00
John Cupitt 63d54e5df2 final code cleanups after stream -> source rename 2019-12-30 14:23:51 +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 32d3ba2a50 fix vips__ftruncate
We'd forgotton to update this for the new vips__seek return.

See https://github.com/libvips/libvips/issues/1494#issuecomment-569413267
2019-12-28 12:47:50 +00:00
John Cupitt 0c217efdf3 fix compiler warning 2019-12-22 15:04:07 +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 7906c128cd better error messages on save
The stream savers were polluting the error log.
2019-12-18 17:50:19 +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 e236f19f97 add fallbacks to new_from_stream
If the stream-based loaders fail, vips_image_new_from_stream() now falls
back to the old file and buffer loaders.

The file and buffer loaders already try the stream loaders first.
2019-12-10 17:19:12 +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 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 7aec350f1c old load/save funcs now use stream API
new_from_file / new_from_buffer and write_to_file / write_to_buffer
use the stream API if they can.
2019-11-13 16:39:47 +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 a9a0dfee0f mostly works now
but

	cat k2.jpg | vips copy stdin x.jpg

still fails
2019-10-23 13:01:09 +01:00
John Cupitt 60ce52512c builds
now needs testing
2019-10-22 17:37:05 +01:00
John Cupitt f6d247627f incorporate revision comments from @kleisauke
Thanks!
2019-10-14 12:18:40 +01:00
John Cupitt 4d3f66fe33 add stdout write
this now works:

	$ vips invert k2.jpg .jpg | vips invert stdin x.jpg

"stdin" means read from stdin, ".jpg" means write to stdout in JPG
format
2019-10-12 14:12:01 +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 98f3bf78a5 fix doc spelling of "optimise" 2019-08-06 14:46:43 +01:00
John Cupitt 0e5447e537 final cleanup 2019-07-28 17:15:54 +01:00
John Cupitt 01a82646a1 experiment with minimise in insert
try minimising sub after we've passed it
2019-07-27 13:40:18 +01:00
John Cupitt 65c41ef7a5 fix a couple of clang compiler warnings 2019-06-15 17:35:46 +01:00
John Cupitt 91d0e7e3d0 move kill mechanism to public API
the vips_image_set_kill() system was internal. Move it to the public
API.

See eg.:

https://github.com/kleisauke/net-vips/issues/31
2019-04-06 16:53:42 +01:00
John Cupitt 640994b64a fix a possible segv writing images to buffers
if write failed, vips_image_write_to_buffer() could segv

thanks @dbouron !

see https://github.com/libvips/libvips/issues/1248
2019-03-20 17:32:44 +00:00
John Cupitt 33d90b5e26 only enable sanity checks in debug mode
We had a couple of sanity checks always on. As a result, libvips could
get slow for large pipelines.

Move them into g_assert().
2019-03-01 13:01:08 +00:00
John Cupitt 10290c3dd6 fix function name error on old glibs
see https://github.com/libvips/libvips/pull/1211#discussion_r248280743
2019-01-16 13:37:50 +00:00
John Cupitt 00982f6297 add changelog notes
and small formatting issues
2019-01-15 09:36:31 +00:00
Leonard Hecker ab6126d55d Addressed review comments 2019-01-14 21:54:50 +01:00
Leonard Hecker 3dd4ddddc8 vips_image_temp_name: Fixed race condition / heap-buffer-overflow
vips_image_temp_name can be called concurrently and thus
the usage of the static "name" array is not thread safe.
-fsanitize=address complains about heap-buffer-overflow due to this.
2019-01-14 19:38:18 +01:00
John Cupitt 89c6d29079 add comments re. temp file open bug 2018-11-05 10:38:15 +00:00