Commit Graph

561 Commits

Author SHA1 Message Date
John Cupitt 48a2551957 fix TIFF thumbnail of buffer and source
We had dropped a couple of patches.

see https://github.com/libvips/libvips/issues/1815
2020-09-14 17:26:19 +01:00
John Cupitt cdcf63f8e5 fix regression in thumbnail of pyr tiff
The new subifd pyramid thumbnail code broke the old page-based pyramid
detector.

Thanks tand826

See https://github.com/libvips/libvips/issues/1784
2020-08-17 10:10:23 +01:00
John Cupitt 97eb2e53bd missing copy-memory during thumbnail rotation
see https://github.com/libvips/libvips/issues/1704#issuecomment-655691041
2020-07-09 07:08:49 +01:00
John Cupitt 5540fa97f4 small cleanups for disable deprecated
- move matrixinvert to mosaicing, fix a leak
- add note to changelog
- small fixes

see https://github.com/libvips/libvips/pull/1593
2020-06-28 12:14:13 +01:00
Kleis Auke Wolthuizen f6b9f382ec Avoid using unneeded variables 2020-06-18 14:40:29 +02:00
Kleis Auke Wolthuizen 8abcae3abc Avoid using vips7 symbols 2020-06-18 14:21:43 +02:00
John Cupitt 023f4ca41b fix thumbnail of multi-page TIFF (again)
The addition of subifd handling broke multipage tiff thumbnailing.

See https://github.com/libvips/pyvips/issues/192
2020-06-15 13:13:21 +01:00
John Cupitt 05b0359897 fix regression of multipage tiff thumbnail
the recent subifd addition had broken thumbnail of multipage tiffs,
thanks @petoor

see https://github.com/libvips/pyvips/issues/192
2020-06-15 10:22:01 +01:00
John Cupitt 75632a5641
Merge pull request #1592 from kleisauke/issue-703
Fix the pixel shift within reduce (#703)
2020-06-12 12:36:22 +01:00
John Cupitt 4469afaeb0 better handling of "nearest" in resize
we now use vips_subsample() for this case
2020-06-12 12:03:15 +01:00
John Cupitt 981d5c4b16 revise autorot system
- deprecate vips_autorot_get_angle() since orientation is no longer a
simple rotate
- add vips_image_get_orientation() and vips_image_get_orientation_swap()
- revise tiff and jpeg loader autorotate to just call vips_autorot(),
but only if necessary
- revise thumbnail autorotate too
2020-06-06 17:25:46 +01:00
Kleis Auke Wolthuizen d7a735400a reducev: Fix undefined-behaviour within the vector path
Found by UBSan.
2020-06-06 14:50:32 +02:00
Kleis Auke Wolthuizen ac30bad695 Remove round-to-nearest behaviour
It seems that it generates the same image, with or without this change.

Tested with https://github.com/kleisauke/vips-issue-703.
2020-06-06 14:29:57 +02:00
Kleis Auke Wolthuizen c0ed106079 Formatting and whitespace changes 2020-06-06 14:25:03 +02:00
Kleis Auke Wolthuizen 369b098096 Prefer an immediate calculation where possible
In line with reducev.
2020-06-06 14:21:15 +02:00
Kleis Auke Wolthuizen dfdf899c92 Ensure reducev is THINSTRIP
In line with reduceh.
2020-06-06 14:16:24 +02:00
Kleis Auke Wolthuizen b6e4e9e74b Speed up the mask construction for uchar/ushort images
By not calling vips_vector_to_fixed_point repeatedly.
2020-06-06 14:12:37 +02:00
Kleis Auke Wolthuizen ac358ff4b8 Fix the pixel shift within reduce (#703) 2020-06-06 14:01:34 +02:00
John Cupitt d74fe71764 better thumbnail behaviour for subifd pyramids 2020-06-02 14:23:14 +01:00
John Cupitt cff84f4606 add subifd pyr support to thumbnail
thumbnail can spot subifd pyramids and load lower levels if necessary
2020-06-02 12:53:36 +01:00
John Cupitt aaebb3b346 fix thumbnail of mono image
we were using RGB as the shrink space
2020-05-27 15:24:27 +01:00
John Cupitt ba0dea001d sort out premultiply rules for upsizing
vips_resize() uses vips_affine() for upsizing and vips_reduce() for
downsizing. Affine automaticaly does a vips_premultiply() for images
with an alpha channel, but reduce does not. This meant that we could
sometimes premultiply twice.

This patch adds a "premultiplied" flag for affine which turns automatic
premultiuplication off, vips_resize() uses this to block affine's auto
premul feature, and the resize docs are clarified to stress that the
operation does not do premultiplication for you.

See https://github.com/libvips/libvips/issues/1629
2020-05-19 14:31:34 +01:00
John Cupitt 5549175b5e add docs for option_string arg to thumbnail
We'd forgotten to add docs for option_string, thanks zhaohuxing.
2020-05-12 10:27:48 +01:00
John Cupitt d64385ae99 revise kernel mask calculations
We were seeing small displacements at some shrink factors because of
rounding in the mask size calcualation. This PR takes the rounding into
account when positioning the mask.

See https://github.com/libvips/libvips/pull/1592#issuecomment-626363031
2020-05-10 18:45:27 +01:00
John Cupitt 54bfa23025 warn against thumbnail_image
see https://github.com/libvips/libvips/issues/1637#issuecomment-623094732
2020-05-03 12:31:17 +01:00
John Cupitt 6f0548dc5c thumbnail could fail on HEIC in some modes
in locked UP or DOWN mode, vips_thumbnail() could incorrectly select the
thumbnail from a HEIC image even when it was not large enough to
generate the output image.

Thanks ZorinArsenij

See https://github.com/libvips/libvips/issues/1614
2020-04-21 10:15:02 +01:00
John Cupitt 34fcd1fe69 fix autorot in thumbnail
`vips_thumbnail()` was not taking a private copy of the image before
modifying metadata during auto-rotate.

Thanks janko.

See https://github.com/libvips/libvips/issues/1523
2020-01-12 14:24:23 +00:00
John Cupitt 5b09845bd5 don't set page-height in thumbnail unless we must
We were always setting page-height in thumbnail, even on single-frame
images. This could cause problems if the image height was later
increased by a factor of the height -- non-animated images could
accidentally turn into animated images.

https://github.com/libvips/libvips/issues/1469
2020-01-06 17:04:01 +00:00
John Cupitt 5ee0623182 revise doc comment for resample
We can now do high-quality reduce for any scale factor, though it'll be
slow for very large reductions.

Thanks homm, see https://github.com/libvips/pyvips/issues/148
2020-01-03 08:59:50 +00:00
John Cupitt 3b2c77dd35 free shrinkv resources earlier
Free the shrinkv line buffer and struct at the end of eval, not on image
dispose. This helps keep mem use down in some long-running operations.

Thank you homm, see https://github.com/libvips/pyvips/issues/147
2020-01-02 15:32:43 +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 e1baf66f19 "squash" to tiffsave now does lab as well
The "squash" option to tiffsave now also squashes 32-bit 3-band float
CIELAB images down to 8 bits.

See https://github.com/libvips/libvips/issues/1499
2019-12-18 17:29:34 +00:00
John Cupitt 686829166d fix some more metadata updates
some more minor cases picked up by the test suite
2019-11-30 12:11:23 +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 5f6911d516 add thumbnail_stream
this works:

	$ cat k2.jpg | vips thumbnail_stream [descriptor=0] x.jpg 200
	$ vipsheader x.jpg
	temp-0: 141x200 uchar, 3 bands, srgb, jpegload
2019-10-12 17:37:31 +01:00
John Cupitt a92f0ed504 smarter heif thumbnail selection in `thumbnail`
We were checking for thumbnail width and height > target width and
height, but of course we can have one of target width or height very
large if we are leaving that axis to float in size.

Instead, calculate a shrink from the heif thumbnail size and see if that is
>= 1.0, ie. we can generate output without upsizing.
2019-09-30 14:34:11 +01:00
John Cupitt 3b0d44be51 fix ref leak in thumbnail
we were accidentally reusing a t[] with RAD images
2019-09-14 00:22:36 +01:00
John Cupitt e129d85330 Merge branch '8.8' 2019-08-27 18:05:58 +01:00
John Cupitt 378537121f revise thumbnail preshrink again 2019-08-27 18:00:26 +01:00
John Cupitt 2f6cc1fad9 Merge branch '8.8' 2019-08-27 14:49:42 +01:00
John Cupitt d61a85f6c9 prevent over-pre-shrink in thumbnail
We could pre-shrink so much that an axis went to 0.

See https://github.com/lovell/sharp/issues/1782#issuecomment-525249430
2019-08-27 14:47:36 +01:00
John Cupitt d80ce4bf15 fix a problem with shrinkv tail processing
Tail processing in shrinkv had an implicit assumption of round-down, but of
course we round to nearest. Thanks angelmixu.

see https://github.com/libvips/libvips/issues/1396
2019-08-13 11:21:01 +01:00
John Cupitt 5ddc154a81 prevent int overflow for int pixels in shrinkh
by using double for an accumulator
2019-08-06 17:00:53 +01:00
John Cupitt 6ba34e479e better shrinkv for int32 types
use double as the sum type to prevent int overflow
2019-08-06 16:55:10 +01:00
John Cupitt 2841504fa0 fix a possible int overflow 2019-08-03 21:14:19 +01:00
John Cupitt 3c8a9815ba fix int overflow in shrinkv 2019-08-03 03:31:54 +01:00
John Cupitt 7f08e8fd28 remove stray flag 2019-07-27 16:13: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 4f2f4b4577 add gif, heif, rad, webp early close 2019-07-21 12:29:25 +01:00
John Cupitt 2c654060f9 experiment with a different early-close strategy
We close loaders early in order to save file handles, and on Windows to
make sure that files can be deleted as soon as possible.

Currently loaders do this by watching the Y coordinate of requests and
freeing the fd when the final line of the file is fetched. This is messy
and does not always work, since there are cases when the final line is
not fetched.

Instead, this patch gets loaders to listen for "minimise" on their
output and close on that. This signal is emitted on all upstream images
whenever a threadpool finishes a scan of an image and is usually used to
trim caches after computation.

See https://github.com/libvips/libvips/issues/1370
2019-07-20 16:31:30 +01:00
John Cupitt 7f47acab56 tiny improvement 2019-07-10 17:43:17 +01:00
John Cupitt 5e2d66d14b better early shutdown behaviour in shrinkv
read the tail of the input to force early shutdown in seq readers

does reducev need something similar?

see https://github.com/kleisauke/net-vips/issues/12
2019-07-09 16:58:30 +01:00
John Cupitt f45f0ecef4 limit resize if shrink would drop axis <1px
vips_resize() will break the aspect ratio and limit resize on an axis if
it would result in an image of less than 1px on that axis

see https://github.com/lovell/sharp/issues/1782#issuecomment-508921306
2019-07-07 10:19:33 +01:00
John Cupitt 8a98bea063 fix vipsthumbnail for pyr tiff files
thumbnail was not testing pyramidal tiff images for pyramidness correctly.

see https://github.com/libvips/libvips/issues/1297
2019-06-19 17:56:09 +01:00
John Cupitt da402cee23 faster and more accurate bilinear
go to fixed point earlier in calculation of interpolation coefficients
2019-05-14 13:10:45 +01:00
John Cupitt 29d9673fd8 update comment 2019-05-14 08:20:30 +01:00
John Cupitt 44afdbc314 more accurate bicubic of int16 images
use float path for int16 -- the fixed-point path can miss by a small
amount

see https://github.com/libvips/libvips/issues/1309
2019-05-13 22:05:41 +01:00
John Cupitt c9ba0915c1 more accurate bilinear for int16 pixels
fixed-point interpolation could give small errors

see https://github.com/libvips/libvips/issues/1309

need a similar change for bicubic etc.
2019-05-13 18:32:48 +01:00
John Cupitt 37865e34f8 oop silly webp jpg mixup in last commit 2019-04-30 20:07:08 +01:00
John Cupitt 394f9baa5e deprecate webpload @shrink, use @scale instead
We need a fractional scale for thumbnail on webp to work well. @shrink
still works, but @scale overrides it.
2019-04-30 18:29:16 +01:00
John Cupitt 7326a409c6 reenable webp shrink-on-load in thumbnail
the breakage is in animated webp load with preshrink rather than
thumbnail
2019-04-29 17:30:34 +01:00
John Cupitt 522ddc1430 better thumbnailing of multipage docs
shrink-on-load should now work for multipage PDF thumbnailing

see https://github.com/libvips/libvips/issues/1297
2019-04-29 17:05:19 +01:00
John Cupitt 8482aa3ff1 tiny cleanup
some left-over pyramid detection code in tiff2vips
2019-04-29 12:52:47 +01:00
John Cupitt efadb5dc42 fix thumbnail shrink-on-load
we had the alignment check in the wrong place
2019-04-27 22:33:20 +01:00
John Cupitt 0102a10b49 seems to work 2019-04-24 17:04:31 +01:00
John Cupitt 0df3f0268c Merge branch 'master' into revise-thumbnail 2019-04-24 16:11:25 +01:00
John Cupitt bb22f66453 oop remove git markup 2019-04-24 16:11:08 +01:00
John Cupitt 8b71d0179c Merge branch 'master' into revise-thumbnail 2019-04-23 20:27:30 +01:00
John Cupitt d2a9a20a78 fix thumbnail regression with cmyk in and out
56d98f3ef0 broke cmyk->cymk thumbnails
2019-04-23 17:09:20 +01:00
John Cupitt 56d98f3ef0 thumbnail no longer needs to import cmyk
since colourspace knows about cmyk now
2019-04-23 11:35:13 +01:00
kleisauke f40eb5ec13 Fix thumbnailing of a WebP image 2019-03-13 17:33:07 +01:00
John Cupitt f06a01ccbe better toilet-roll detection 2019-03-04 09:55:53 +00:00
John Cupitt 29d33b2753 start work on toilet-roll thumbnails again 2019-03-02 22:13:55 +00:00
John Cupitt 15ee957ea9 Merge branch 'master' into revise-thumbnail 2019-03-02 22:06:23 +00:00
John Cupitt 64c7165759 fix some clang warnings 2019-03-02 16:23:19 +00:00
John Cupitt b565f2fc68 more accurate bilinear
use double, not float, for coefficient calculation, or we get overshoots
in some cases

see https://github.com/libvips/libvips/issues/1239
2019-02-27 20:33:31 +00:00
John Cupitt cf860b27fa start working over thumbnail to support anim 2019-02-19 17:27:23 +00:00
John Cupitt 1a83605238 Merge branch 'add-heifload' 2019-02-17 17:11:14 +00:00
John Cupitt f23d0fd754 note new option_string param in changelog 2019-02-03 12:27:58 +00:00
kleisauke f40062c495 s/open_args/option_string/g 2019-02-03 12:29:54 +01:00
kleisauke 05c459cc28 vips_thumbnail_buffer: add optional open_args argument (#1147) 2019-02-02 09:26:12 +01:00
John Cupitt 308c85c004 add support for stored heif thumbnails 2019-01-30 16:19:11 +00:00
John Cupitt 9303e382c1 Merge branch '8.7' 2018-12-17 20:31:25 +00:00
John Cupitt 6ba4b3bfdb fix clipping with new mapim cods
we had the clip in the wrong place

see https://github.com/libvips/libvips/issues/1180
2018-12-17 20:29:31 +00:00
John Cupitt 962cab2d0f Merge branch '8.7' 2018-12-17 13:18:58 +00:00
John Cupitt db4fe60405 fix mapim offsets
pixels were not being offset by the stencil origin, so interpolators
like bicubic could fail

thanks @erdmann

https://github.com/libvips/libvips/issues/1180
2018-12-17 12:42:34 +00:00
John Cupitt f5d76b42fc fix centre sampling for non-int nearest upscale
we were not disabling the input offset for NEAREST, whcih is always
centre

thanks edwjusti

see https://github.com/lovell/sharp/issues/1479
2018-12-03 17:13:57 +00:00
John Cupitt 0669cf2a23 Merge branch 'master' into add-webp-animated 2018-11-23 17:41:09 +00:00
John Cupitt 6b9d89b103 add pyr tiff shrink-on-load for thumbnail 2018-11-16 18:00:25 +00:00
John Cupitt d4823489dc switch to libwebpmux for webp write
we had our own horrible thing before
2018-11-01 18:50:10 +00:00
John Cupitt 7303ecbebb typo
thanks @becoded
2018-10-31 14:09:57 +00:00
John Cupitt 22ba9106b5 implement shrink-on-load for openslide thumbs
makes vipsthumbnail much quicker on openslide images, obviously

see https://github.com/libvips/libvips/issues/1149
2018-10-31 14:07:13 +00:00
John Cupitt 0b050f4046 deprecate thumbnail auto_rotate, add no_rotate
the auto_rotate option of thumbnail was default TRUE which made it
useless from the CLI, since GOption only allows --switch, not
--switch=false

deprecate auto_rotate, add no_rotate, but allow either to be used

see https://github.com/libvips/libvips/issues/1146
2018-10-31 12:30:37 +00:00
Yazan Medanat 90f578a05f Change jcupitt references to libvips. 2018-09-21 09:05:47 -07:00
John Cupitt 643e7c0ea2 mapim fix for strange float values
mapim could fail for float index images outside the int range

minor speedup too
2018-08-12 17:10:23 +01:00
John Cupitt 3b1e3e1841 add Mitchell kernel
see https://github.com/jcupitt/libvips/issues/966
2018-06-12 12:55:10 +01:00
John Cupitt 754a1e5419 Merge branch 'master' into add-canny 2018-03-14 14:18:39 +00:00
John Cupitt 08dcf29b10 add vips_rotate()
vips_similarity() was a little hatrd to discover, so add vips_rotate()
as a more obvious name for it
2018-03-10 18:45:39 +00:00