Skip to content

Commit

Permalink
Update libvips to 8.6, use simplified exif loading.
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan Reinhard committed Jan 22, 2018
1 parent 0ac3fbd commit 08baa17
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 633 deletions.
7 changes: 1 addition & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ find_package(PkgConfig)
pkg_check_modules(AVCODEC libavcodec REQUIRED)
pkg_check_modules(AVUTIL libavutil REQUIRED)
pkg_check_modules(SWSCALE libswscale REQUIRED)
pkg_check_modules(EXIF libexif REQUIRED)
pkg_check_modules(VIPS vips-cpp REQUIRED)

if (STATIC_BUILD)
Expand All @@ -34,15 +33,13 @@ if (STATIC_BUILD)
${AVCODEC_STATIC_LDFLAGS}
${AVUTIL_STATIC_LDFLAGS}
${SWSCALE_STATIC_LDFLAGS}
${EXIF_STATIC_LDFLAGS}
${VIPS_STATIC_LDFLAGS}
${EXPAT_STATIC_LDFLAGS})
else()
set(TIFIG_LDFLAGS
${AVCODEC_LDFLAGS}
${AVUTIL_LDFLAGS}
${SWSCALE_LDFLAGS}
${EXIF_LDFLAGS}
${VIPS_LDFLAGS})
endif()

Expand All @@ -53,8 +50,7 @@ set(SOURCE_FILES
src/imaging.hpp
src/loader.hpp
src/types.hpp
src/main.cpp
src/vips-exif.c)
src/main.cpp)
set(TIFIG tifig)

add_subdirectory(${LIBHEIF_DIR})
Expand All @@ -69,7 +65,6 @@ include_directories(lib/cxxopts/include)
include_directories(${AVCODEC_INCLUDE_DIRS})
include_directories(${AVUTIL_INCLUDE_DIRS})
include_directories(${SWSCALE_INCLUDE_DIRS})
include_directories(${EXIF_INCLUDE_DIRS})
include_directories(${VIPS_INCLUDE_DIRS})

target_link_libraries(${TIFIG} heifreader cxxopts pthread)
Expand Down
47 changes: 37 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,53 @@ Converts HEIF images created on iOS 11 devices as fast as ~~humanly~~ possible

## Build Dependencies

* `libvips` >= 8.5
* `libavcodec` >= 3.1
* `libswscale` >= 3.1
* `libexif` >= 0.6.14

Install the dependencies under a ubuntu based distribution (Should work for xenial, zesty and artful):
* `libvips` >= 8.6
* `libavcodec` >= 3.1 (ffmpeg)
* `libswscale` >= 3.1 (ffmpeg)

#### macOS aka OSX

This one-liner should get you going:

```
# brew install vips ffmpeg
```

#### Linux

First of all, to just try out tifig, the easiest way is to [use one of our static builds](https://github.com/monostream/tifig/releases).

However, if you do want to build from source, verify carefully that the minimally required versions are actually shipped and installed with your distro and release.

For ffmpeg, check the output of:

```
ffmpeg -version
```

Assuming you are using a ubuntu based system, this should help if your versions of 'libavcodec' and 'libswscale' is too old:

```
# sudo add-apt-repository -y ppa:dhor/myway
# sudo add-apt-repository -y ppa:jonathonf/ffmpeg-3
# suod apt-get update
# sudo apt-get install libvips-dev libavcodec-dev libswscale-dev
# sudo apt-get install libavcodec-dev libswscale-dev
```

On Mac OS X:
Since tifig requires quite a modern version of `libvips`, building from source is probably required. [Follow the instructions here](http://jcupitt.github.io/libvips/install.html#building-libvips-from-a-source-tarball) .

Again on ubuntu, something like this should do the trick:

```
# brew install vips ffmpeg
sudo apt-get install build-essential pkg-config libglib2.0-dev libexpat1-dev libjpeg-dev libexif-dev libpng-dev libtiff-dev
wget https://github.com/jcupitt/libvips/releases/download/v8.6.1/vips-8.6.1.tar.gz
tar xzf vips-8.6.1.tar.gz
cd vips-8.6.1
./configure
make
sudo make install
```


## Build

```
Expand Down
14 changes: 2 additions & 12 deletions src/imaging.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,20 @@

#include "types.hpp"

extern "C" {
#include "vips-exif.h"
};

using namespace std;
using namespace vips;

/**
* Parse exif data and set image fields
* Add Exif metadata to image
* @param exifData
* @return
*/
void parseExif(DataVector &exifData, VImage &image)
void addExifMetadata(DataVector &exifData, VImage &image)
{
uint8_t* exifDataPtr = &exifData[0];
uint32_t exifDataLength = static_cast<uint32_t>(exifData.size());

image.set(VIPS_META_EXIF_NAME, nullptr, exifDataPtr, exifDataLength);

int parseResult = vips_exif_parse(image.get_image());

if (parseResult != 0) {
throw logic_error("Failed to parse Exif data");
}

This comment has been minimized.

Copy link
@brendan-rius

brendan-rius Mar 20, 2018

This block here should not have been removed. Looking at its name, it looks like vip_exif_parse just tries to read the exif of the image, but it actually changes it sometime (see 08baa17#r28181401).

Thus, removing this part introduced a bug (see #26)

}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ int convert(const string& inputFilename, Opts& options)
}

DataVector exifData = extractExifData(&reader, contextId, gridItemId);
parseExif(exifData, image);
addExifMetadata(exifData, image);

if (createOutputThumbnail)
{
Expand Down Expand Up @@ -190,8 +190,8 @@ int main(int argc, char* argv[])
catch (const logic_error& le) {
cerr << le.what() << endl;
}
catch (...) {
cerr << "Conversion failed" << endl;
catch (exception& e) {
cerr << "Conversion failed:" << e.what() << endl;
}

return retval;
Expand Down
Loading

0 comments on commit 08baa17

Please sign in to comment.