Commit Graph

151 Commits

Author SHA1 Message Date
John Cupitt e081ae2d99 experiment with app14 decode 2019-04-15 10:50:42 +01:00
John Cupitt 37613c196d fix jpeg xmp read/write
it was not removing/reattaching the magic XMP URL

see https://github.com/libvips/libvips/issues/1229
2019-02-11 18:16:20 +00:00
John Cupitt cff4af34ca add vips_image_set_blob_copy()
and use it where we can
2018-11-23 16:27:39 +00:00
John Cupitt 0b4cef06b7 close early for tiffload 2018-08-16 16:00:14 +01:00
John Cupitt b836749b75 close jpeg read early
The current behaviour (close input handles on unref) works for languages
like C / C++ / Python / Rust / etc. where things get unreffed automatically
when they go out of scope.

On languages like Ruby / C# / node / etc. where things are unreffed on GC,
files can stay open for a long time after you've finished with them. This
interacts in an unfortunate way with the Windows default of refusing to
remove open files.

This change closes file handles as soon as the scan of the input file
finishes, and therefore produces something closer to expected behaviour
for GCd languages on Windows.

see https://github.com/kleisauke/net-vips/issues/12
2018-08-16 15:47:48 +01: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 5b55dd8ed4 Merge branch '8.6' 2018-04-11 09:38:59 +01:00
John Cupitt 24b146790f oop reorder crop to come after cache
or we'll write beyond the buffer end
2018-04-10 15:39:51 +01:00
John Cupitt d1dd41a21f strict round down on jpeg shrink
libjpeg rounds up on shrink-on-load. In some cases this can leave a dark
line along the right and bottom edge, since it only contains (for
example) 1/4 of a pixel of data.

This change adds a crop after jpeg load so that only complete pixels are
output.

See https://github.com/lovell/sharp/issues/1185
2018-04-10 15:18:18 +01:00
John Cupitt 15abbbe986 set "interlaced" for jpg and png
set "interlaced" for interlaced png and jpg images
2018-04-09 17:14:38 +01:00
John Cupitt 5176b4a17e better header sniffing for small files
vips__get_bytes() used to fail if the file was too small for the
allocated buffer, which was a problem for svg, since files can be extremely
small.

This change makes vips__get_bytes() return the number of bytes read, so
the is_a testers can work on files smaller than the max header size.
2018-03-22 12:08:39 +00:00
John Cupitt 6f2861df5b move META_SEQ support into foreign load
simplifies loaders a bit
2018-01-01 11:14:27 +00:00
John Cupitt 83e36880da more compat for older IPCT code
add IPTC data under the name "ipct-data" as well
2017-12-31 10:38:35 +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 9c8790b40a setting EXIF data blocks sets other tags too
calling vips_image_set() to set the EXIF data block VIPS_META_EXIF_NAME
will automaticaly set other tags, like orientation etc.
2017-11-27 15:15:21 +00:00
John Cupitt 2b70348d23 Merge branch '8.5' 2017-08-29 10:33:45 +01:00
John Cupitt e2c83fe4bd fix jpegload fail
we were only failing on libjpeg errors, but libjpeg treats very serious
things thaht we want to be able to catch (like truncated files) as warnings
... we must therefore error out if fail is set and libjpeg issues a warning

see https://github.com/lovell/sharp/issues/793
2017-08-29 09:49:38 +01:00
John Cupitt 10003f3f3c revise libjpeg new from buffer
in line with latest libjpeg recommendations

this fixes a segv with corrupt input found by libFuzzer and asan
2017-08-25 12:51:06 +01:00
John Cupitt 0ef01e9ca5 fix jpegload from empty buffer
could try to read a couple of non-existent bytes before failing ... now we
inject an EOI marker
2017-08-24 17:28:07 +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 dd5a108854 fix up new seq mode stuff
seems to work
2017-03-05 21:59:53 +00:00
John Cupitt 96b1aba1a7 Revert "experiment with removal of seq stall"
This reverts commit c6eb9ee0f2.
2017-02-27 10:26:59 +00:00
John Cupitt e6b20cbd0f Revert "remove stalling"
This reverts commit 959f412380.
2017-02-27 10:26:32 +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 959f412380 remove stalling 2017-02-21 15:03:15 +00:00
John Cupitt c6eb9ee0f2 experiment with removal of seq stall 2017-02-21 09:44:21 +00:00
John Cupitt 0231b512b4 fits isn't quite working still 2017-01-17 14:53:40 +00:00
John Cupitt c464503510 Merge branch 'master' into invalidate-on-load-error 2017-01-17 13:47:14 +00:00
John Cupitt 5d61bd4982 Merge branch 'master' into add-webp-metadata 2017-01-04 16:13:39 +00:00
John Cupitt 262d5a10f7 Merge branch 'master' into glib-logging 2017-01-04 10:13:06 +00:00
John Cupitt 3a48ff9cc1 don't warn for missing exif res
don't warn for missing exif res (even though it should be there) since
we fall back to jfif

cs3 seems to avoid the exif res fields and just uses jfif

see https://github.com/lovell/sharp/issues/657
2017-01-04 09:22:32 +00:00
John Cupitt 2be0b97dce switch to g_warning()_/g_info()
we had vips_warn() and vips_info(), but they are a bit crappy ... switch
to g_warning() and g_info() instead

see https://github.com/jcupitt/libvips/issues/544
2017-01-03 15:52:27 +00:00
John Cupitt 47222bc1f5 move exif handling out to exif.c
now used by webpload as well
2016-11-07 12:20:56 +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 b43c171e79 set resunit as well when fixing exif res 2016-09-07 20:03:53 +01:00
Ulysse Manceron af4282e0e2 Now assigning the jpeg resolution inside the exif header, if the exif header isnt set properly 2016-09-07 14:07:29 +02:00
Ulysse Manceron 4451f4d839 Don't use the exif resolution if not fully set 2016-09-07 12:56:58 +02:00
John Cupitt d8381c73da more improvements to error handling during eval
we were dropping the error buffer in tilecache, thanks David
2016-07-28 09:46:10 +01:00
John Cupitt 828b36dfe5 fix --fail option to jpegload
getting --fail on jpegload working means tilecache must terminate on tile
calc error

make openslideload not report tile calc errors, it might need a --fail
option too

see https://github.com/jcupitt/libvips/issues/474
2016-07-11 10:07:41 +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 094470c9c1 done, just a few things left
- tif->jpg copy seems to loose tag

- add tests
2016-05-27 09:48:08 +01:00
John Cupitt 1fbae62cf8 seems to work for jpg anyway
try some tests next
2016-05-05 20:07:17 +01:00
John Cupitt 1f701a61ea try signalling invalidate on load error
to knock load ops out of cache
2016-05-05 15:00:40 +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 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 01025328da fix some cppcheck warnings
try:

$ cppcheck -f --enable=warning,performance,portability -j4 . 2> err.txt

there are still some left, see:

see https://github.com/jcupitt/libvips/issues/331
2015-09-28 22:01:15 +01:00
John Cupitt c2e8406ca0 check for unknown exif tags
exif_tag_get_name() can return NULL for unknown tags, check
2015-07-23 15:01:44 +01:00
John Cupitt fbe321eebf change exif names argh
change exif names again: we were storing under @title, but that's both
subject to i18n, and unlookupable in libexif

we now use @name, which is not subject to i18n and can be searched for
... this will break most code which expects certain exif tag names

also, when we update exif, allow any tag, not just updates to existing
tags, see:

https://github.com/lovell/sharp/issues/189
2015-07-15 13:27:47 +01:00
John Cupitt fc5a4a917a make file format readers close fds early
we were using two fds per open image, now we just use one

jpg, magick, tiff, png
2015-02-26 14:09:01 +00:00
John Cupitt 6ff1d5320b don't call jpeg_finish_decompress()
all it does is verify the trailing bytes in the file

see https://github.com/lovell/sharp/issues/151
2015-01-20 16:55:35 +00:00
John Cupitt ad86f45cd9 add autorot as an operator as well 2014-10-19 10:35:10 +01:00
John Cupitt 0a51536162 seems to work 2014-10-17 13:17:44 +01:00
John Cupitt 14d7ce1e91 first try, not very good 2014-10-16 19:16:45 +01:00
John Cupitt 158237254d fix jfif resunit read
see https://github.com/jcupitt/libvips/issues/170

the previous fix just did exif resolution "none", we need jfif "none" as
well
2014-09-09 16:46:16 +01:00
John Cupitt 6269c852cc support exif res unit "none"
well why would you want that, but it seems some images use it
2014-09-09 12:18:21 +01:00
John Cupitt e9ce212b62 make out of order read a fatal error
For png and jpg, out of order must always be a fatal error, since you
can't read from a specific y position.

This was a g_assert() before which meant that this test was missing from
production builds. It's now always a fatal error.
2014-09-02 09:37:08 +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
John Cupitt 9dea549063 oops savers were not setting filename
when we added all the buffer loaders, we cul dno longer set filename in
VipsForeign, it's now the responsibility of each load class
2014-06-10 11:26:09 +01:00
John Cupitt d0f50febbb added vips_foreign_load_buffer() 2014-04-22 16:27:43 +01:00
John Cupitt 499b977043 back out the complex linear stuff
needs cooking for a while longer in a branch
2014-03-04 14:32:43 +00:00
John Cupitt 4d85011a51 disable sequential skipahead
this was causing some problems on very-many-core systems

still need to update operation flags and disable seq mode for
insert/extract/etc.
2014-02-25 11:12:41 +00:00
John Cupitt 0ef0328396 oops 2014-02-24 21:58:07 +00:00
John Cupitt d843521f77 jpeg load from buffer shouldn't modify buffer
fill_input_buffer() could write to the input buffer

see: https://github.com/jcupitt/libvips/pull/107

thanks Lovell
2014-02-24 17:10:07 +00:00
John Cupitt ae6ea3ba87 support many Radiance readers active at once
we had some globals for the Rad reader state, whcih was fine with the
old reader, but with the new sequential one you can have several active
at once
2014-01-23 15:06:37 +00:00
John Cupitt 12454d3225 more jpeg read sanity checking 2014-01-23 14:19:55 +00:00
John Cupitt 63591f6ac1 FATSTRIP for jpeg read 2013-12-16 16:22:44 +00:00
John Cupitt eb3ad6d64f add lots of instrumentation
also svg output
2013-11-26 14:57:56 +00:00
John Cupitt 12cf71a6a9 combin copy_fields and demand_hint
We had two API calls, vips_image_copy_fields() and vips_demand_hint().
They are now combined in the single vips_image_pipeline() call.

All operations are now slightly smaller and simpler.
2013-10-22 09:29:40 +01:00
John Cupitt d89007a8d4 catch jpeg startup errors
thanks mvgulik
2013-10-15 13:47:15 +01:00
John Cupitt 6c0eced22c build fixes for OS X
stupid libjpeg and their stupid bool type argh
2013-10-04 11:54:01 +01:00
John Cupitt 440b800e0e add a new unbuffered seq mode
things like

	vips copy huge.png x.v

now run with only a small line cache
2013-09-29 11:04:11 +01:00
John Cupitt 6167d4d97c Fix three minor memleaks 2013-07-15 22:01:00 +01:00
John Cupitt 02095763c9 null-terminate exif strings
libexif strings are not null-terminated, add a \0 before adding to the
vips image

thanks Mike
2013-07-06 11:51:34 +01:00
John Cupitt 0c6da0c330 fix demand hints for shrink
"vips shrink" was broken due to wonky demand hints, thanks Jan
2013-04-08 13:08:24 +01: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 20ce700e23 jpeg tag read/write cleanups 2012-11-22 09:15:02 +00:00
John Cupitt c3ef2be4ab preserve jpeg ipct data
now copies over ipct data from app13, thanks Gary
2012-11-21 21:33:50 +00:00
John Cupitt 65b4056c84 jpeg read is less fussy about exif data
even read truncated exif
2012-11-21 18:34:20 +00:00
John Cupitt 7025fe4081 more exif read improvements
some jpegs use a signed long to store the resolution unit (??), remove
the checks on tag format for res unit
2012-11-16 19:53:59 +00:00
John Cupitt 74f545fc6f keep exif rationals as a/b
we went via double before, which caused awful problems trying to
generate nice rationals again on save

keep everything as a/b as long as we can
2012-11-16 13:50:49 +00:00
John Cupitt fcc33020bd better exif handling
- track ifd numbers for each item of exif
- be more careful about which ones we update
- don't update xres/yres in vips_shrink()
2012-11-16 10:03:31 +00:00
John Cupitt 2048ec2356 jpeg read oops 2012-11-05 14:41:31 +00:00
John Cupitt 8e0de67f65 sync 2012-10-30 17:16:55 +00:00
John Cupitt 89065b391a sequential needs a strip size param
strip tiff can only read in strip-sized chunks
2012-08-24 16:06:29 +01:00
John Cupitt 39b05f5172 tuning, sort out demand hints
and disable extract_area seq mode
2012-08-24 12:46:10 +01:00
John Cupitt 8653b23810 better handling of jpeg warnings 2012-08-23 21:44:14 +01:00
John Cupitt f5f0dda551 experiment with thread stalling 2012-08-21 16:18:25 +01:00
John Cupitt 463058c149 note and use res unit on jpg load/save
previously, jpeg save always used pixels/inch and jpeg load converted to
vips pixels/mm

now on jpg load the image's res unit is recorded in
VIPS_META_RESOLUTION_UNIT, and on jpg save the res unit is set from
VIPS_META_RESOLUTION_UNIT (or defaults to inches).

you can now copy a cm-preferring tiff to a jpg and the unit is preserved
2012-08-07 14:10:19 +01:00
John Cupitt 3694a2edc5 add sequential mode to vips7
the tiff and jpg readers let you give :seq as well
2012-06-24 09:44:50 +01:00
John Cupitt 2f897315ad fix a crash with corrupted jpg files
three was a double-free crash with a scrambled jpg file, thanks Grigoriy
2012-06-19 08:52:06 +01:00
John Cupitt 8c6e3738dd fix up ordering issues in seq mode
read order should be guaranteed now, hopefully
2012-02-20 15:03:29 +00:00
John Cupitt 8af5522a96 sequential support for the jpg reader 2012-02-19 22:17:20 +00:00
John Cupitt bbadb8d681 jpeg2vips now keeps a load struct about
so we are ready to add lazy read
2012-02-19 10:54:41 +00:00
John Cupitt 774e2fe495 read jfif resolution
read jfif, if available, before we read exif resolution
2012-01-09 10:34:47 +00:00
John Cupitt 0983b50905 Merge remote-tracking branch 'origin/gobject-introspection' into goi-merge
Conflicts:
	TODO
	libvips/arithmetic/im_recomb.c
	libvips/arithmetic/im_stats.c
	libvips/deprecated/im_measure.c
	libvips/include/vips/header.h
	libvips/include/vips/image.h
	libvips/include/vips/object.h
	libvips/iofuncs/header.c
	libvips/iofuncs/image.c
	libvips/iofuncs/object.c
2011-12-24 17:36:55 +00:00
John Cupitt a62f5f8832 remove wio_output 2011-12-21 12:08:29 +00:00
John Cupitt 05fbb6b3bc fix up openslideload
there was a problem with the tile cache ... plus some small tidies
2011-12-12 11:34:28 +00:00
John Cupitt 935c713e71 sort out jpegload 2011-11-29 12:11:33 +00:00