Skip to content

kleisauke/vips-issue-703

Repository files navigation

libvips issue #703

Test case for libvips/libvips#703.

The example images for the various EXIF orientation flags are taken from this repo:
https://github.com/recurser/exif-orientation-examples

Build

git clone https://github.com/kleisauke/vips-issue-703.git
cd vips-issue-703
mkdir build && cd build
cmake .. \
  -DCMAKE_BUILD_TYPE=Release
make

Or if you prefer to build without CMake:

git clone https://github.com/kleisauke/vips-issue-703.git
cd vips-issue-703
g++ -g -Wall test-anim.cpp `pkg-config vips-cpp --cflags --libs` -o test-anim
g++ -g -Wall test-single.cpp `pkg-config vips-cpp --cflags --libs` -o test-single

Run

G_MESSAGES_DEBUG=all ./test-single

# Generate an animated WebP image from the output of `./test-single`
./test-anim

# https://github.com/libvips/pyvips/issues/148
VIPS_CONCURRENCY=1 VIPS_NOVECTOR=1 python3 test-resize.py input/radial.rgb.png

See output/ directory.

Debugging notes

Notes

Only reduce an image vertically (using only reducev):

VIPS_NOVECTOR=1 vips reducev input/Landscape_1.jpg output-patch/lanczos3/Landscape_1.jpg[strip,Q=85] 5.624992969 --kernel lanczos3 --centre

VIPS_NOVECTOR=1 vips reducev input/Landscape_2.jpg temp.v 5.624992969 --kernel lanczos3 --centre
vips flip temp.v output-patch/lanczos3/Landscape_2.jpg[strip,Q=85] horizontal

VIPS_NOVECTOR=1 vips reducev input/Landscape_3.jpg temp.v 5.624992969 --kernel lanczos3 --centre
vips rot temp.v output-patch/lanczos3/Landscape_3.jpg[strip,Q=85] d180

VIPS_NOVECTOR=1 vips reducev input/Landscape_4.jpg temp.v 5.624992969 --kernel lanczos3 --centre
vips rot temp.v temp2.v d180
vips flip temp2.v output-patch/lanczos3/Landscape_4.jpg[strip,Q=85] horizontal

vips rot input/Landscape_5.jpg temp.v d270
VIPS_NOVECTOR=1 vips reducev temp.v temp2.v 5.624992969 --kernel lanczos3 --centre
vips flip temp2.v output-patch/lanczos3/Landscape_5.jpg[strip,Q=85] vertical

vips rot input/Landscape_6.jpg temp.v d90
VIPS_NOVECTOR=1 vips reducev temp.v output-patch/lanczos3/Landscape_6.jpg[strip,Q=85] 5.624992969 --kernel lanczos3 --centre

vips rot input/Landscape_7.jpg temp.v d90
VIPS_NOVECTOR=1 vips reducev temp.v temp2.v 5.624992969 --kernel lanczos3 --centre
vips flip temp2.v output-patch/lanczos3/Landscape_7.jpg[strip,Q=85] vertical

vips rot input/Landscape_8.jpg temp.v d270
VIPS_NOVECTOR=1 vips reducev temp.v output-patch/lanczos3/Landscape_8.jpg[strip,Q=85] 5.624992969 --kernel lanczos3 --centre

rm {temp,temp2}.v

Only reduce an image horizontally (using only reduceh):

vips reduceh input/Landscape_1.jpg output-patch/lanczos3/Landscape_1.jpg[strip,Q=85] 5.624992969 --kernel lanczos3 --centre

vips reduceh input/Landscape_2.jpg temp.v 5.624992969 --kernel lanczos3 --centre
vips flip temp.v output-patch/lanczos3/Landscape_2.jpg[strip,Q=85] horizontal

vips reduceh input/Landscape_3.jpg temp.v 5.624992969 --kernel lanczos3 --centre
vips rot temp.v output-patch/lanczos3/Landscape_3.jpg[strip,Q=85] d180

vips reduceh input/Landscape_4.jpg temp.v 5.624992969 --kernel lanczos3 --centre
vips rot temp.v temp2.v d180
vips flip temp2.v output-patch/lanczos3/Landscape_4.jpg[strip,Q=85] horizontal

vips rot input/Landscape_5.jpg temp.v d270
vips reduceh temp.v temp2.v 5.624992969 --kernel lanczos3 --centre
vips flip temp2.v output-patch/lanczos3/Landscape_5.jpg[strip,Q=85] vertical

vips rot input/Landscape_6.jpg temp.v d90
vips reduceh temp.v output-patch/lanczos3/Landscape_6.jpg[strip,Q=85] 5.624992969 --kernel lanczos3 --centre

vips rot input/Landscape_7.jpg temp.v d90
vips reduceh temp.v temp2.v 5.624992969 --kernel lanczos3 --centre
vips flip temp2.v output-patch/lanczos3/Landscape_7.jpg[strip,Q=85] vertical

vips rot input/Landscape_8.jpg temp.v d270
vips reduceh temp.v output-patch/lanczos3/Landscape_8.jpg[strip,Q=85] 5.624992969 --kernel lanczos3 --centre

rm {temp,temp2}.v

Only shrink an image vertically (using only shrinkv):

vips shrinkv input/Landscape_1.jpg output-patch/lanczos3/Landscape_1.jpg[strip,Q=85] 3

vips shrinkv input/Landscape_2.jpg temp.v 3
vips flip temp.v output-patch/lanczos3/Landscape_2.jpg[strip,Q=85] horizontal

vips shrinkv input/Landscape_3.jpg temp.v 3
vips rot temp.v output-patch/lanczos3/Landscape_3.jpg[strip,Q=85] d180

vips shrinkv input/Landscape_4.jpg temp.v 3
vips rot temp.v temp2.v d180
vips flip temp2.v output-patch/lanczos3/Landscape_4.jpg[strip,Q=85] horizontal

vips rot input/Landscape_5.jpg temp.v d270
vips shrinkv temp.v temp2.v 3
vips flip temp2.v output-patch/lanczos3/Landscape_5.jpg[strip,Q=85] vertical

vips rot input/Landscape_6.jpg temp.v d90
vips shrinkv temp.v output-patch/lanczos3/Landscape_6.jpg[strip,Q=85] 3

vips rot input/Landscape_7.jpg temp.v d90
vips shrinkv temp.v temp2.v 3
vips flip temp2.v output-patch/lanczos3/Landscape_7.jpg[strip,Q=85] vertical

vips rot input/Landscape_8.jpg temp.v d270
vips shrinkv temp.v output-patch/lanczos3/Landscape_8.jpg[strip,Q=85] 3

rm {temp,temp2}.v

Only shrink an image horizontally (using only shrinkh):

vips shrinkh input/Landscape_1.jpg output-patch/lanczos3/Landscape_1.jpg[strip,Q=85] 3

vips shrinkh input/Landscape_2.jpg temp.v 3
vips flip temp.v output-patch/lanczos3/Landscape_2.jpg[strip,Q=85] horizontal

vips shrinkh input/Landscape_3.jpg temp.v 3
vips rot temp.v output-patch/lanczos3/Landscape_3.jpg[strip,Q=85] d180

vips shrinkh input/Landscape_4.jpg temp.v 3
vips rot temp.v temp2.v d180
vips flip temp2.v output-patch/lanczos3/Landscape_4.jpg[strip,Q=85] horizontal

vips rot input/Landscape_5.jpg temp.v d270
vips shrinkh temp.v temp2.v 3
vips flip temp2.v output-patch/lanczos3/Landscape_5.jpg[strip,Q=85] vertical

vips rot input/Landscape_6.jpg temp.v d90
vips shrinkh temp.v output-patch/lanczos3/Landscape_6.jpg[strip,Q=85] 3

vips rot input/Landscape_7.jpg temp.v d90
vips shrinkh temp.v temp2.v 3
vips flip temp2.v output-patch/lanczos3/Landscape_7.jpg[strip,Q=85] vertical

vips rot input/Landscape_8.jpg temp.v d270
vips shrinkh temp.v output-patch/lanczos3/Landscape_8.jpg[strip,Q=85] 3

rm {temp,temp2}.v

Output

Thumbnail

Produces pixel shifts

Portrait Landscape

Shrink an image vertically

Produces pixel shifts on the vertical axis

Landscape-vertical

Shrink an image horizontally

Produces pixel shifts on the horizontal axis

Landscape-horizontal

Upscale

Upscale does not appear to produce pixel shifts

Portrait Landscape

Output after pull request

See libvips/libvips#1592.

Thumbnail

Does not produce pixel shifts

Portrait Landscape

Shrink an image vertically

Pixel shifts are gone

Landscape-vertical

Shrink an image horizontally

Pixel shifts are gone

Landscape-horizontal