Skip to content

Commit

Permalink
overwrite orientation
Browse files Browse the repository at this point in the history
  • Loading branch information
Idan Yael committed Dec 15, 2019
1 parent 2639f77 commit c75175b
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 0 deletions.
4 changes: 4 additions & 0 deletions vips/header.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,7 @@ int get_meta_orientation(VipsImage *in) {

return orientation;
}

void set_meta_orientation(VipsImage *in, int orientation) {
vips_image_set_int(in, VIPS_META_ORIENTATION, orientation);
}
4 changes: 4 additions & 0 deletions vips/header.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,7 @@ func vipsRemoveMetadata(in *C.VipsImage) {
func vipsGetMetaOrientation(in *C.VipsImage) int {
return int(C.get_meta_orientation(in))
}

func vipsSetMetaOrientation(in *C.VipsImage, orientation int) {
C.set_meta_orientation(in, C.int(orientation))
}
1 change: 1 addition & 0 deletions vips/header.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ int remove_icc_profile(VipsImage *in);
void remove_metadata(VipsImage *in);

int get_meta_orientation(VipsImage *in);
void set_meta_orientation(VipsImage *in, int orientation);
4 changes: 4 additions & 0 deletions vips/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@ func (r *ImageRef) GetOrientation() int {
return vipsGetMetaOrientation(r.image)
}

func (r *ImageRef) SetOrientation(orientation int) {
vipsSetMetaOrientation(r.image, orientation)
}

// ResX returns the X resolution
func (r *ImageRef) ResX() float64 {
return float64(r.image.Xres)
Expand Down
10 changes: 10 additions & 0 deletions vips/transform.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ type TransformParams struct {
SharpM2 float64
StripProfile bool
StripMetadata bool
OverwriteOrientation int
Interpretation Interpretation
BackgroundColor *Color
}
Expand Down Expand Up @@ -120,6 +121,11 @@ func (t *Transform) CropOffsetY(y int) *Transform {
return t
}

func (t *Transform) SetOverwriteOrientation(o int) *Transform {
t.transformParams.OverwriteOrientation = o
return t
}

// CropRelativeOffsetX sets the target offset from the crop position
func (t *Transform) CropRelativeOffsetX(x float64) *Transform {
t.transformParams.CropOffsetX.SetScale(x)
Expand Down Expand Up @@ -693,6 +699,10 @@ func (b *blackboard) postProcess() error {
}
}

if b.OverwriteOrientation > 1 {
b.image.SetOrientation(b.OverwriteOrientation)
}

return nil
}

Expand Down

0 comments on commit c75175b

Please sign in to comment.