mirror of
https://github.com/talgo-cloud/bimg.git
synced 2026-03-07 21:48:13 -08:00
fix(vips): panic error on exif orientation
This commit is contained in:
parent
4bf5d7391e
commit
6142436743
3 changed files with 13 additions and 6 deletions
11
README.md
11
README.md
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
Small [Go](http://golang.org) library for blazing fast and efficient image processing based on [libvips](https://github.com/jcupitt/libvips) using C bindings. It provides a clean, simple and fluent [API](https://godoc.org/github.com/h2non/bimg) in pure Go.
|
||||
|
||||
bimg is designed to be a small and efficient library with a generic and useful set of features.
|
||||
It uses internally libvips, which requires a [low memory footprint](http://www.vips.ecs.soton.ac.uk/index.php?title=Speed_and_Memory_Use)
|
||||
bimg was designed to be a small and efficient library with a generic and useful features.
|
||||
It uses internally libvips, a powerful library written in C for binary image processing which requires a [low memory footprint](http://www.vips.ecs.soton.ac.uk/index.php?title=Speed_and_Memory_Use)
|
||||
and it's typically 4x faster than using the quickest ImageMagick and GraphicsMagick settings or Go native `image` package, and in some cases it's even 8x faster processing JPEG images.
|
||||
|
||||
It can read JPEG, PNG, WEBP and TIFF formats and output to JPEG, PNG and WEBP, including conversion between them. It supports common [image operations](#supported-image-operations) such as crop, resize, rotate, zoom, watermark...
|
||||
|
|
@ -230,6 +230,13 @@ if err != nil {
|
|||
bimg.Write("new.jpg", newImage)
|
||||
```
|
||||
|
||||
#### Debugging
|
||||
|
||||
Run the process passing the `DEBUG` environment variable
|
||||
```
|
||||
DEBUG=* ./app
|
||||
```
|
||||
|
||||
#### func DetermineImageTypeName
|
||||
|
||||
```go
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ func TestMetadata(t *testing.T) {
|
|||
for _, file := range files {
|
||||
metadata, err := Metadata(readFile(file.name))
|
||||
if err != nil {
|
||||
t.Fatalf("Cannot read the image: %#v", err)
|
||||
t.Fatalf("Cannot read the image: %s -> %s", file.name, err)
|
||||
}
|
||||
|
||||
if metadata.Type != file.format {
|
||||
|
|
|
|||
6
vips.h
6
vips.h
|
|
@ -68,12 +68,12 @@ vips_rotate(VipsImage *in, VipsImage **buf, int angle)
|
|||
int
|
||||
vips_exif_orientation(VipsImage *image) {
|
||||
int orientation = 0;
|
||||
const char **exif;
|
||||
const char *exif;
|
||||
if (
|
||||
vips_image_get_typeof(image, "exif-ifd0-Orientation") != 0 &&
|
||||
!vips_image_get_string(image, "exif-ifd0-Orientation", exif)
|
||||
!vips_image_get_string(image, "exif-ifd0-Orientation", &exif)
|
||||
) {
|
||||
orientation = atoi(exif[0]);
|
||||
orientation = atoi(&exif[0]);
|
||||
}
|
||||
return orientation;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue