Skip to content

Commit

Permalink
Merge govips upstream (#36)
Browse files Browse the repository at this point in the history
* append \d after usage print for better user experience

* Add HasAlpha method for ImageRef

* Image#AutorotAngle delivers EXIF rotation angle

* Control over debug-level logs

* Make this repository a git module

* Avoid nil dereference on test failure

* Add `ImageRef.Clone()` method

* Fix copy-paste typo

* - add WebP orientation test

* - add WebP orientation test

* - add WebP orientation test

* Add comment

* Update comment

* Change Hue parameter to be float

* Control over debug-level logs

* Image#AutorotAngle delivers EXIF rotation angle

* Make this repository a git module

* Avoid nil dereference on test failure

* Cleaning extra files

* Fix URL and dependencies

* Fix URL

* Badges for README

* Add sharpen mode parameter

* Remove mode parameter for sharpen (can't find this in APIs)

* Resetting travis config to get CI/CD working

* Fix future-proof bug in tests

* Add MacOS build for Travis

* Upgrade macOS CI/CD images

* Fix documentation

* Update README with working example

* Replace custom scripts with standard Makefile

* Update test image data

* Disable bit-based image comparison tests

* Package documentation

* Remove file size checks - not relevant for testing

* Test coverage reporting via coveralls.io

* Add latest version badge to README

* Fix URLs

* Add make test

* Add instructions on dependencies

* Update to version 2.0.0

* Bump dependencies

* Update badges

* Add `StripMetadata` parameter back

Without this flag some EXIF tags (for example: `PixelXDimension`, `PixelYDimension`)
always added for PNG files.

Even the original file didn't have any EXIF tags.

* Fix travis link

* Fix dependency instructions for macOS

* fixes davidbyttow#112

Include stdlib.h to fix `could not determine kind of name for C.free` error

* Fix old macOS build issues with Python

* Remove old macOS versions due to missing homebrew packages

* Update README.md

* Update README.md

* Update README.md to point to latest godoc directly

* README update

* Clean documentation

* Fix nonexistent automatic kernel for resize()

* Add GC support for `vips.ImageRef`

* Create codeql-analysis.yml

* Undeprecate Copy() function

* Fix test dependencies and add Label() unit test

* Fix github caching test coverage metrics

* Create codeql-analysis.yml

* Undeprecate Copy() function

* Fix test dependencies and add Label() unit test

* Fix github caching test coverage metrics

* Consolidate glib, libvips and govips logging into one channel

* Option to set logging verbosity and override handler

* Clarify logging documentation and provide example

* Best practice for export parameters

* Deprecate Close() as imageRefs are closed automatically via gc

* re-enable golden tests and add macos resources

* Add linux golden resources and rename examples

* Remove Close() from unit test

* Add CI docker images

* Update codeql-analysis.yml

* Enable github CI

* Fix bug reported in issue davidbyttow#124

* Add unit tests and groovy assets

* govips logo assets

* Add logo and wix.com attribution to README.md

* Add the vips thumbnail function for easier image thumbnailing

* Add unit tests for Thumbnail() with and without crop

* 1. add support of `CompositeMulti`
2. add composite test

* Fix ineffectual assignment in example

* add debugging to find memory leaks

* groovy assets for crop unit test

* macos crop assets

* Add benchmark for the exporting of an image

* Avoid allocating a new go byte slice buffer and instead reuse the C buffer

* Add unit tests and groovy assets

* macos unit test assets

* Add linux assets for unit tests

* Add unit tests

* Add colorspace unit test

* Add unit tests for ExtractBand and BandJoin

* mac assets for unit tests

* Final unit test to bring us above 80%

* Just a couple more unit tests

* Add macos assets

* Revert "Avoid allocating a new go byte slice buffer and instead reuse the C buffer"

This reverts commit bf2aa07.

* implement vips_xyz

* implement divide

* add cgo stuff

* implement mapim

* remove public function

* Add Multiply() and Add() methods and tests for linux

* Add macos testing assets

* Add unit test for HEIF subtype ftypmsf1

* Fix HEIF subtype ftypmsf1 recognition

* add public method and test

* add comment, fix naming

* fix test

* delete divide golden image

* Add Windows section to README

* add failing test

* add pub method and test

* add pub method and tests

* Add macOS divide test

* More golden test reference images

* Fix panic on shutdown

* Add null logging handler and fix log override chec

* Change CI logging to console logging without cb

* Replace CI test console logging with TestMain

* Proper temporary files, remove hardcoded paths

* Fix issue davidbyttow#63, if vips compiled without ICC

* Fixes TIFF compression #21

* Remove node_modules

* Remove golden files, add macos golden

* Ubuntu golden images

* Clean up logging override flag behavior

* Support vips_similarity

* - Add bandjoin_const
- Make similarity support alpha background pixels (if the input image has an alpha channel/band)

* Comment

* Add a function to convert vips images as golang image.Image objects for interoperability

* Tests

* Test ToImage

* Use validation function in tests

* - Also support vips_smartcrop
- Commit golden test images

* WIP - Adds format specific export params

* Add groovy golden resources

* Add linux golden resources

* Add draw_rect

* Change test

* Add black

* Adds additional methods and cleans up export

* Add docs and failing unit tests

* Adds more options and default parameters in C

* implement Identity

* adjust comment to look nice

* implement a public method for Cast

* add a test for cast

* implement Maplut

* Adds major version to darwin golden tests

* Adds darwin-10 files

* Update file names

* Update macos-11 files

* Remove seemingly dead/unused code for embed/extend

* Fixes header

* add ushort parameter

* fix ushort implementation

* implement vips_avg

* add failing linear test to bump up coverage

* Format C files according to google style

* Remove redundant pkg-config directives

* Reduces noise in golden image tests during failure

* Uses libvips operation API for saving

* fix defaults

* Put back sharpen mode, nicer golden tests output

* Fix some C compilation warnings because they fail go tests

* Use format-specific export from vips

* ImageRef.OptimizeICCProfile now uses vipsICCTransform that maps to vips_icc_transform, instead of wrapping this in C function optimize_icc_profile (not done, doesn't compile yet)

* Put back support for "near lossless" parameter in webp, fix icc profile paths

* Add missing parameters jpegOptimizeCoding and jpegSubsample

* Change govips jpeg defaults to match previous version

* Restore icc profile parameter passed to save webp

Co-authored-by: Leslie Qi Wang <leslie.qiwa@gmail.com>
Co-authored-by: Tomasz Jezierski <deco.jezierski@gmail.com>
Co-authored-by: Tilo Prütz <tilo@infopark.de>
Co-authored-by: Alessandro Segala <43508+ItalyPaleAle@users.noreply.github.com>
Co-authored-by: John Ford <john@johnford.org>
Co-authored-by: David Byttow <david.byttow@gmail.com>
Co-authored-by: Artem V. Navrotskiy <bozaro@yandex.ru>
Co-authored-by: elad laufer <elad@wix.com>
Co-authored-by: Toni Melisma <toni.melisma@iki.fi>
Co-authored-by: Toni Melisma <59022391+tonimelisma@users.noreply.github.com>
Co-authored-by: Phani Rithvij <phanirithvij2000@gmail.com>
Co-authored-by: Paul van Santen <pvansanten@transip.nl>
Co-authored-by: zzjin <tczzjin@gmail.com>
Co-authored-by: aleksandr.kirillov <aleksandr.kirillov@myposter.de>
Co-authored-by: Aleksandr Kirillov <32141102+axkirillov@users.noreply.github.com>
Co-authored-by: boosh <boosh@example.com>
  • Loading branch information
17 people committed Feb 9, 2021
1 parent 27154cc commit dd2bf48
Show file tree
Hide file tree
Showing 405 changed files with 3,970 additions and 853 deletions.
4 changes: 4 additions & 0 deletions .editorconfig
Expand Up @@ -10,3 +10,7 @@ trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[*.{c,h,cpp,hpp,cc}]
indent_style = space
indent_size = 2
50 changes: 50 additions & 0 deletions .github/workflows/build.yml
@@ -0,0 +1,50 @@
name: build

on: [ push, pull_request ]

jobs:
build:
name: Build
runs-on: ${{ matrix.os }}
env:
CGO_CFLAGS_ALLOW: -Xpreprocessor
strategy:
matrix:
os: [ubuntu-18.04, ubuntu-20.04, macOS-10.15, macos-11.0]

steps:

- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.13

- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: Install linux deps
if: matrix.os == 'ubuntu-18.04' || matrix.os == 'ubuntu-20.04'
run: |
sudo add-apt-repository -y ppa:tonimelisma/ppa
sudo apt-get -y install libvips-dev
- name: Install macos deps
if: matrix.os == 'macos-10.15' || matrix.os == 'macos-11.0'
run: |
brew install vips
- name: Get dependencies
run: |
go get -v -t -d ./...
- name: Build
run: go build -v ./vips

- name: Test
run: go test -v -coverprofile=profile.cov ./...

- name: Coveralls
if: matrix.os == 'ubuntu-20.04'
uses: shogo82148/actions-goveralls@v1
with:
path-to-profile: profile.cov
60 changes: 60 additions & 0 deletions .github/workflows/codeql-analysis.yml
@@ -0,0 +1,60 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
# ******** NOTE ********

name: "CodeQL"

on:
push:
branches: [ master ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ master ]
schedule:
- cron: '37 5 * * 0'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: go
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
3 changes: 1 addition & 2 deletions .gitignore
@@ -1,6 +1,5 @@
.DS_Store
build/
*.failed.*
.vscode
.idea
/vips/vips.test
node_modules/
51 changes: 0 additions & 51 deletions .travis.yml

This file was deleted.

15 changes: 3 additions & 12 deletions CONTRIBUTING.md
Expand Up @@ -7,23 +7,14 @@ Please create a [new issue](https://github.com/davidbyttow/govips/issues/new) wi
If you're having installation problems, please include any and all output from your commandline.

## Want to write some code?
I'd love it for you to take initiative and submit pull requests. It's extra awesome if your code has unit tests to support the change. Let's do this together! I'll add you to the list of contributors.
I'd love it for you to take initiative and submit pull requests. Please ensure your code has unit tests to support the change, including negative ones as well to cover all the code. If you add image manipulation code, I suggest adding a unit test to the golden tests. After running the golden test files will be added to the resources directory, submit them in the PR as well. Let's do this together! I'll add you to the list of contributors.

## Strict linting
The Travis build currently checks strict format and linting, so be sure to add comments!

## Prerequisites

### On Mac
```bash
brew install pkg-config vips
```
The CI/CD currently checks strict format and linting, so be sure to add comments!

## Run the tests

```bash
cd pkg/vips
./tests.sh
```make test
```

## Get in touch
Expand Down
12 changes: 12 additions & 0 deletions Makefile
@@ -0,0 +1,12 @@
all: deps build test

deps: FORCE
CGO_CFLAGS_ALLOW=-Xpreprocessor go get ./...

build: FORCE
CGO_CFLAGS_ALLOW=-Xpreprocessor go build ./vips

test: FORCE
CGO_CFLAGS_ALLOW=-Xpreprocessor go test -v ./...

FORCE:
113 changes: 94 additions & 19 deletions README.md
@@ -1,48 +1,123 @@
# govips ![License](https://img.shields.io/badge/license-MIT-blue.svg)
# <img src="https://raw.githubusercontent.com/davidbyttow/govips/master/assets/SVG/govips.svg" width="90" height="90"> <span style="font-size: 4em;">govips</span>
[![GoDoc](https://godoc.org/github.com/davidbyttow/govips?status.svg)](https://pkg.go.dev/mod/github.com/davidbyttow/govips/v2) [![Go Report Card](http://goreportcard.com/badge/davidbyttow/govips)](http://goreportcard.com/report/davidbyttow/govips) ![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/davidbyttow/govips) ![License](https://img.shields.io/badge/license-MIT-blue.svg) [![Build Status](https://github.com/davidbyttow/govips/workflows/build/badge.svg)](https://github.com/davidbyttow/govips/actions) [![Coverage Status](https://img.shields.io/coveralls/github/davidbyttow/govips)](https://coveralls.io/github/davidbyttow/govips?branch=master)
## A lightning fast image processing and resizing library for Go


## A libvips library for Go
This package wraps the core functionality of [libvips](https://github.com/libvips/libvips) image processing library by exposing all image operations on first-class types in Go.

How fast is libvips? See this: [Speed and Memory Use](https://github.com/libvips/libvips/wiki/Speed-and-memory-use)
Libvips is generally 4-8x faster than other graphics processors such as GraphicsMagick and ImageMagick. Check the benchmark: [Speed and Memory Use](https://github.com/libvips/libvips/wiki/Speed-and-memory-use)

The intent for this is to enable developers to build extremely fast image processors in Go, which is suited well for concurrent requests.

Libvips is generally 4-8x faster than other graphics processors such as GraphicsMagick and ImageMagick.

## Requirements
- [libvips](https://github.com/libvips/libvips) 8.10+
- C compatible compiler such as gcc 4.6+ or clang 3.0+
- Go 1.14+

- [libvips](https://github.com/libvips/libvips) 8.10+
- C compatible compiler such as gcc 4.6+ or clang 3.0+
- Go 1.14+

## Dependencies

### MacOS

Use [homebrew](https://brew.sh/) to install vips and pkg-config:

```bash
brew install vips pkg-config
```

### Ubuntu

You need at least libvips 8.10.2 to work with govips. Groovy (20.10) repositories have the latest version. However on Bionic (18.04) and Focal (20.04), you need to install libvips and dependencies from a backports repository:

```bash
sudo add-apt-repository ppa:tonimelisma/ppa
```

Then:

```bash
sudo apt -y install libvips-dev
```

### Windows

The recommended approach on Windows is to use Govips via WSL and Ubuntu.

If you need to run Govips natively on Windows, it's not difficult but will require some effort. We don't have a recommended environment or setup at the moment. Windows is also not in our list of CI/CD targets so Govips is not regularly tested for compatibility. If you would be willing to setup and maintain a robust CI/CD Windows environment, please open a PR, we would be pleased to accept your contribution and support Windows as a platform.

## Installation

```bash
go get -u github.com/wix-playground/govips/vips
go get -u github.com/davidbyttow/govips/v2/vips
```

### MacOS note

On MacOS, govips may not compile without first setting an environment variable:

```bash
export CGO_CFLAGS_ALLOW="-Xpreprocessor"
```

## Example usage

```go
package main

import (
"github.com/wix-playground/govips/vips"
"fmt"
"io/ioutil"
"os"

"github.com/davidbyttow/govips/v2/vips"
)

image, err := NewImageFromFile("image.jpg")
if err != nil {
return nil, err
func checkError(err error) {
if err != nil {
fmt.Println("error:", err)
os.Exit(1)
}
}
defer image.Close()

// Resize an image
return image.Resize(1200, 1200).Export(nil)
func main() {
vips.Startup(nil)
defer vips.Shutdown()

image1, err := vips.NewImageFromFile("input.jpg")
checkError(err)

// Rotate the picture upright and reset EXIF orientation tag
err = image1.AutoRotate()
checkError(err)

ep := vips.NewDefaultJPEGExportParams()
image1bytes, _, err := image1.Export(ep)
err = ioutil.WriteFile("output.jpg", image1bytes, 0644)
checkError(err)

}
```

See *examples/* folder for more examples.

## Running tests

```bash
$ make test
```

## Contributing
In short, feel free to file issues or send along pull requests. See this [guide on contributing](https://github.com/wix-playground/govips/blob/master/CONTRIBUTING.md) for more information.

Feel free to file issues or create pull requests. See this [guide on contributing](https://github.com/davidbyttow/govips/blob/master/CONTRIBUTING.md) for more information.

## Credits
Thank you to [John Cupitt](https://github.com/jcupitt) for maintaining libvips and providing feedback on vips.

Thanks to:

- [John Cupitt](https://github.com/jcupitt) for creating and maintaining libvips
- [Toni Melisma](https://github.com/tonimelisma) for pushing to a 2.x release
- [wix.com](https://wix.com/) for the govips logo and lots of great functionality
- All of our fantastic [contributors](https://github.com/davidbyttow/govips/graphs/contributors)

## License

MIT - David Byttow
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/Icons/PSD/GoVips black icons.psd
Diff not rendered.
Binary file added assets/Icons/PSD/GoVips color icons.psd
Diff not rendered.
Binary file added assets/Icons/PSD/GoVips white icons.psd
Diff not rendered.
Binary file added assets/PNG/govips black.png
Binary file added assets/PNG/govips color.png
Binary file added assets/PNG/govips white.png
11 changes: 11 additions & 0 deletions assets/SVG/govips.svg

0 comments on commit dd2bf48

Please sign in to comment.