Skip to content

Commit

Permalink
Docs: clarify which axis is used when mirroring
Browse files Browse the repository at this point in the history
  • Loading branch information
lovell committed May 11, 2023
1 parent 5255964 commit e873978
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
6 changes: 4 additions & 2 deletions docs/api-operation.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ const resizeThenRotate = await sharp(input)


## flip
Flip the image about the vertical Y axis. This always occurs before rotation, if any.
Mirror the image vertically (up-down) about the x-axis.
This always occurs before rotation, if any.
The use of `flip` implies the removal of the EXIF `Orientation` tag, if any.


Expand All @@ -73,7 +74,8 @@ const output = await sharp(input).flip().toBuffer();


## flop
Flop the image about the horizontal X axis. This always occurs before rotation, if any.
Mirror the image horizontally (left-right) about the y-axis.
This always occurs before rotation, if any.
The use of `flop` implies the removal of the EXIF `Orientation` tag, if any.


Expand Down
2 changes: 1 addition & 1 deletion docs/search-index.json

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions lib/operation.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ function rotate (angle, options) {
}

/**
* Flip the image about the vertical Y axis. This always occurs before rotation, if any.
* Mirror the image vertically (up-down) about the x-axis.
* This always occurs before rotation, if any.
* The use of `flip` implies the removal of the EXIF `Orientation` tag, if any.
*
* @example
Expand All @@ -95,7 +96,8 @@ function flip (flip) {
}

/**
* Flop the image about the horizontal X axis. This always occurs before rotation, if any.
* Mirror the image horizontally (left-right) about the y-axis.
* This always occurs before rotation, if any.
* The use of `flop` implies the removal of the EXIF `Orientation` tag, if any.
*
* @example
Expand Down
4 changes: 2 additions & 2 deletions src/pipeline.cc
Original file line number Diff line number Diff line change
Expand Up @@ -380,11 +380,11 @@ class PipelineWorker : public Napi::AsyncWorker {
if (autoRotation != VIPS_ANGLE_D0) {
image = image.rot(autoRotation);
}
// Flip (mirror about Y axis)
// Mirror vertically (up-down) about the x-axis
if (baton->flip || autoFlip) {
image = image.flip(VIPS_DIRECTION_VERTICAL);
}
// Flop (mirror about X axis)
// Mirror horizontally (left-right) about the y-axis
if (baton->flop || autoFlop) {
image = image.flip(VIPS_DIRECTION_HORIZONTAL);
}
Expand Down

0 comments on commit e873978

Please sign in to comment.