Commit Graph

55 Commits

Author SHA1 Message Date
John Cupitt 976db37f84
Revised threading system (#3105)
* reimplement threadpool

just a set of threads that get recycled

"ninja test" passes and dzsave seems to work, though pytest fails for
some reason

* clean up threading code a bit

move base stuff into thread.c, so we have a simple

	thread -> threadset -> threadpool

layering

* start trying to revert g_threadpool

based on the original commit

* working!

nice low systime again

still need to repply cnages to threadpool.c since 80e0cc3d1

* reapply fixes from master

so threadpool.c is now up to date

* rename VipsThread as VipsWorker

a bit less confusing

* use a semaphore to count workers in a pool

* tidy up

* formatting

* dynamic threadpool sizing

based on counting the number of blocked threads in each pool

it works, but the improvement is not great :(

* add "concurrency" metadata item

so operators can hint threadpool size (dzsave especially)

* don't use thinstrip for small images

* add RGB mode to openslide

since flatten was taking 20% of CPU time for dzsave

* fix up rgb mode

now actually works

* make the tile buffer per thread

in the new openslideload rgb mode

* fix dynamic pool downsize

* mild refactoring

* fix the buffer system

oops, turned it off by mistake

* all done!

* revise changelog

* Update libvips/iofuncs/threadset.c

Co-authored-by: Kleis Auke Wolthuizen <github@kleisauke.nl>

* Update libvips/iofuncs/threadset.c

Co-authored-by: Kleis Auke Wolthuizen <github@kleisauke.nl>

* LSan: add libMagickCore to suppression file

* Revert "Remove mutex lock for VipsThreadStartFn"

This reverts commit 41440491.

* add VIPS_MAX_THREADS

to set a hard limit on the threadset size

* Revert "Revert "Remove mutex lock for VipsThreadStartFn""

This reverts commit 77e8520966ba79194fff3b4e648bbd295cd5c260.

* remove sslock from sink.c

* move fixed threadpool build to init

not first use

* add some doc comments

* revert test suite threshold change

* add a test for MAX_THREADS

and move the test tmp/ area into the builddir

* limit VIPS_MAX_THREADS to sane values

* use tabs rather than spaces

Co-authored-by: Kleis Auke Wolthuizen <github@kleisauke.nl>
2022-10-26 15:25:19 +01:00
John Cupitt 2e5e9fb755 set "magick-format" for IM7 load
see https://github.com/libvips/libvips/discussions/3011
2022-08-26 16:01:15 +01:00
John Cupitt d27dfbe55d revise help text for loaders
Hopefully to make it clearer and more consistent.

See https://github.com/libvips/libvips/discussions/2982
2022-08-10 12:50:53 +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
Kleis Auke Wolthuizen bae0342d95
Update C++ binding and function list (#2851)
* Update C++ binding and function list

Also, start with a capital letter in descriptions whenever possible.

* Ensure `dzsave_target` is generated
2022-06-10 14:43:44 +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 01e3f1fc33
set libvips orientation on magickload (#2535)
Pick up the imagemagick / graphicsmagick orientation field for libvips.

Tested with graphicsmagick, magick6 and magick7.

see https://github.com/libvips/libvips/issues/2528
2021-11-13 14:38:30 +00:00
Kleis Auke Wolthuizen e95e8c5155
Fix typo in `magick7load` (#2512)
Introduced in commit f92069b.
2021-11-02 12:04:19 +00:00
Kleis Auke Wolthuizen f92069b035
Incorporate #2506 also in {webp,magick7}load (#2507) 2021-11-01 18:33:27 +00: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 b5aa045ee9 oops typo in magick7 load 2020-11-20 13:14:57 +00:00
John Cupitt d971c75d6f block 0 width or height images from imagemagick
IM could return 0 width and/or height for some crafted images. Block
these.

Thanks @Koen1999.

See https://github.com/libvips/libvips/issues/1890
2020-11-20 12:17:42 +00:00
Lovell Fuller 20bdc41225 Ensure magick7 buffer+file checks use consistent min length guard
Prevents a zero-length buffer from crashing GetImageMagick
2020-05-05 13:06:57 +01:00
John Cupitt 9ef8b55218 better handling of short files in vips7 compat
the sniffer could read beyond the end of the file sometimes
2020-03-04 17:38:41 +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 bb75535151 much faster ismagick
We used to Ping files to see if IM would load them, but this can be
extremely slow for file formats like ARW.

Instead, use GetImageMagick() ... it just checks the magic number.
2019-06-08 16:47:40 +01:00
John Cupitt 675c6361eb revise page-height rules again
Only set `page-height` if `n` is set as an argument. This means you only
get a multi-page image if you specifically ask for it.
2019-05-29 14:18:46 +01:00
John Cupitt 02bdb8b96c better error message for "unsupported colorspace"
we just printed the enum number before
2019-05-24 17:42:10 +01:00
John Cupitt 931b661d2b fix up and test with im6/im7/gm
seems to work! phew
2019-02-07 18:35:51 +00:00
John Cupitt 90fef08ee0 start adding xmp/icc/exif/etc. for IM
needs to work for im6, im7 and gm, and it's not quite there yet :(
2019-02-06 16:39:14 +00:00
John Cupitt 8d5af9fe8a add xmp/ipct/icc etc. to magickload
ImageMagick supports binary metadata with `ResetImageProfileIterator()`
etc.

Implementing support gives us xmp / ipct / icc support, plus perhaps
some others.
2019-02-04 17:54:57 +00:00
John Cupitt 87062c4a4f Merge branch '8.7' 2019-01-04 09:19:04 +00:00
John Cupitt 1619c8b1a1 fix memleak in magick6load
IM ExceptionInfo were not being freed correctly. This patch
adds a small wrapper function and uses it to allocate and free all IM
exception objects.

Tested with im 6.9 and gm 1.3.

See:

https://github.com/libvips/lua-vips/issues/24

https://github.com/libvips/libvips/issues/1203
2019-01-04 08:38:58 +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 e89dac20bb add sniffing framework to magickload
though it only spots ICO for now

see https://github.com/jcupitt/pyvips/issues/39
2018-07-24 17:38:36 +01:00
John Cupitt 72f589764a remove the @format param to magickload 2018-07-24 17:03:38 +01:00
John Cupitt c349b31c5f magicksave polishing
- make better use of the magick.c wrappers in magickload
- disable magicksave if ImportImagePixels() is not found, fixing build
  against GM
2018-05-18 17:40:29 +01:00
John Cupitt 9714dcdee3 test depth as well in magickload
We were testing width / height / bands when verifying that it was OK to
load a toilet-roll image ... of course we should test depth as well.
2018-04-26 13:57:33 +01:00
John Cupitt 3a9d322574 magick7 tests for all frames equal before load
it used to crash if pages changed in size
2018-04-26 13:45:50 +01:00
John Cupitt 05fd7d9301 oop typo 2018-04-26 11:49:47 +01:00
John Cupitt da6f4fd043 add n-pages metadata item
tiff, magick and pdf load now attach an n-pages metadata item recording
the number of pages in the orginal file

see https://github.com/jcupitt/libvips/issues/953
2018-04-26 08:55:31 +01:00
John Cupitt c410dc2db8 add format option to magickload
Some magick coders (eg. ICO) don't sniff the filetype from the data, so
when you try to load from a string, imagemagick is unable to pick the
right decode path.

Add a @format option so callers can hint the filetype.

see https://github.com/jcupitt/pyvips/issues/39
2018-04-24 15:06:52 +01:00
John Cupitt 585469b192 add configure flags for magick load and save
so you can turn load and save on and off independently
2017-12-23 16:57:36 +00:00
Dirk Lemstra 90167902b9 Added define for loading with ImageMagick. 2017-12-22 01:59:56 +01:00
John Cupitt f9f717a843 add VIPS_ONCE and use it everywhere
Lovell's idea: save the function call in the most common case
2017-11-23 08:43:08 +00:00
John Cupitt 6e968d46f2 magick7 now supports page/n 2016-11-25 18:19:36 +00:00
John Cupitt 5df5793457 done!
all tests done, all pass with magick6 and magick7
2016-08-14 18:39:40 +01:00
John Cupitt 20298b0d9a better all_frames on gif sources
some frames can be missing some lines
2016-08-14 17:39:01 +01:00
John Cupitt 8c05a2bbe8 argh all_frames doesn't work for gif 2016-08-04 15:55:06 +01:00
John Cupitt f39538ffc7 don't Ping, always Read
sadly PingImage() cannot give useful results for at least DICOM images,
so we can't use it ... instead, read the image in _header()
2016-08-04 14:13:54 +01:00
John Cupitt cfdfc0d393 tiny 2016-08-02 17:21:44 +01:00
John Cupitt 9535128a93 stuck on dicom now 2016-07-29 13:24:13 +01:00
John Cupitt 422b029602 better gif load via magick7 2016-07-29 12:35:55 +01:00
John Cupitt 6d217f6f68 getting closer
seems we'll need many different paths, perhaps one for each ImageType
2016-07-28 16:12:02 +01:00
John Cupitt a3e09e216c try to read alpha in magick
not quite right
2016-07-27 23:00:01 +01:00
John Cupitt 27da050a24 fix all_pages
tested with pdf, need to test gif
2016-07-25 13:57:50 +01:00
John Cupitt c43757d8da add restrict on unpack loop 2016-07-09 18:24:15 +01:00
John Cupitt 9d7667cbff oop found a problem 2016-07-09 18:01:46 +01:00
John Cupitt a9d1c654e2 fixes 2016-07-09 14:15:28 +01:00