Skip to content

Commit

Permalink
Disable animation support and update unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tonimelisma committed May 28, 2021
1 parent e8128e5 commit c725324
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 30 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ brew install vips pkg-config

### Ubuntu

You need at least libvips 8.10.2 to work with govips. Groovy (20.10) and Hirsute (21.04) 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:
You need a recent libvips to work with govips. New govips functionality is continuously added which takes advantage of new libvips functionality. Groovy (20.10) and Hirsute (21.04) repositories have working versions. However on Focal (20.04), you need to install libvips and dependencies from a backports repository:

```bash
sudo add-apt-repository -y ppa:strukturag/libde265
sudo add-apt-repository -y ppa:strukturag/libheif
sudo add-apt-repository ppa:tonimelisma/ppa
```

Expand Down
49 changes: 24 additions & 25 deletions vips/foreign.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ int load_image_buffer(void *buf, size_t len, int imageType, VipsImage **out)
}
else if (imageType == WEBP)
{
code = vips_webpload_buffer(buf, len, out, "n", -1, NULL);
code = vips_webpload_buffer(buf, len, out, NULL);
}
else if (imageType == TIFF)
{
code = vips_tiffload_buffer(buf, len, out, NULL);
}
else if (imageType == GIF)
{
code = vips_gifload_buffer(buf, len, out, "n", -1, NULL);
code = vips_gifload_buffer(buf, len, out, NULL);
}
else if (imageType == PDF)
{
Expand Down Expand Up @@ -100,15 +100,15 @@ int save_buffer(const char *operationName, SaveParams *params,
int set_jpeg_options(VipsOperation *operation, SaveParams *params)
{
int ret = vips_object_set(VIPS_OBJECT(operation),
"strip", params->stripMetadata,
"optimize_coding", params->jpegOptimizeCoding,
"interlace", params->interlace,
"subsample_mode", params->jpegSubsample,
"trellis_quant", params->jpegTrellisQuant,
"overshoot_deringing", params->jpegOvershootDeringing,
"optimize_scans", params->jpegOptimizeScans,
"quant_table", params->jpegQuantTable,
NULL);
"strip", params->stripMetadata,
"optimize_coding", params->jpegOptimizeCoding,
"interlace", params->interlace,
"subsample_mode", params->jpegSubsample,
"trellis_quant", params->jpegTrellisQuant,
"overshoot_deringing", params->jpegOvershootDeringing,
"optimize_scans", params->jpegOptimizeScans,
"quant_table", params->jpegQuantTable,
NULL);

if (!ret && params->quality)
{
Expand All @@ -122,8 +122,8 @@ int set_jpeg_options(VipsOperation *operation, SaveParams *params)
int set_png_options(VipsOperation *operation, SaveParams *params)
{
int ret = vips_object_set(VIPS_OBJECT(operation), "strip", params->stripMetadata,
"compression", params->pngCompression, "interlace",
params->interlace, "filter", params->pngFilter, NULL);
"compression", params->pngCompression, "interlace",
params->interlace, "filter", params->pngFilter, NULL);

if (!ret && params->quality)
{
Expand All @@ -139,8 +139,8 @@ int set_png_options(VipsOperation *operation, SaveParams *params)
int set_webp_options(VipsOperation *operation, SaveParams *params)
{
int ret = vips_object_set(VIPS_OBJECT(operation), "strip", params->stripMetadata,
"lossless", params->webpLossless, "reduction_effort",
params->webpReductionEffort, NULL);
"lossless", params->webpLossless, "reduction_effort",
params->webpReductionEffort, NULL);

if (!ret && params->quality)
{
Expand All @@ -155,7 +155,7 @@ int set_webp_options(VipsOperation *operation, SaveParams *params)
int set_heif_options(VipsOperation *operation, SaveParams *params)
{
int ret = vips_object_set(VIPS_OBJECT(operation), "lossless", params->heifLossless,
NULL);
NULL);

if (!ret && params->quality)
{
Expand All @@ -169,11 +169,11 @@ int set_heif_options(VipsOperation *operation, SaveParams *params)
int set_tiff_options(VipsOperation *operation, SaveParams *params)
{
int ret = vips_object_set(VIPS_OBJECT(operation), "strip", params->stripMetadata,
"compression", params->tiffCompression, "predictor",
params->tiffPredictor, "pyramid", params->tiffPyramid,
"tile_height", params->tiffTileHeight, "tile_width",
params->tiffTileWidth, "tile", params->tiffTile, "xres",
params->tiffXRes, "yres", params->tiffYRes, NULL);
"compression", params->tiffCompression, "predictor",
params->tiffPredictor, "pyramid", params->tiffPyramid,
"tile_height", params->tiffTileHeight, "tile_width",
params->tiffTileWidth, "tile", params->tiffTile, "xres",
params->tiffXRes, "yres", params->tiffYRes, NULL);

if (!ret && params->quality)
{
Expand All @@ -186,11 +186,11 @@ int set_tiff_options(VipsOperation *operation, SaveParams *params)
// https://libvips.github.io/libvips/API/current/VipsForeignSave.html#vips-magicksave-buffer
int set_magick_options(VipsOperation *operation, SaveParams *params)
{
vips_object_set(VIPS_OBJECT(operation),"format" ,"GIF" , NULL);
vips_object_set(VIPS_OBJECT(operation), "format", "GIF", NULL);

if (params->quality)
{
return vips_object_set(VIPS_OBJECT(operation), "quality", params->quality, NULL);
return vips_object_set(VIPS_OBJECT(operation), "quality", params->quality, NULL);
}
}

Expand Down Expand Up @@ -265,8 +265,7 @@ static SaveParams defaultSaveParams = {
.tiffXRes = 1.0,
.tiffYRes = 1.0,

.avifSpeed = 5
};
.avifSpeed = 5};

SaveParams create_save_params(ImageType outputFormat)
{
Expand Down
3 changes: 3 additions & 0 deletions vips/image_golden_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,7 @@ func TestImage_SimilarityRGBA(t *testing.T) {
func TestImage_Decode_JPG(t *testing.T) {
goldenTest(t, resources+"jpg-24bit.jpg", func(img *ImageRef) error {
goImg, err := img.ToImage(nil)
assert.NoError(t, err)

buf := new(bytes.Buffer)
err = jpeg2.Encode(buf, goImg, nil)
Expand All @@ -470,6 +471,7 @@ func TestImage_Decode_JPG(t *testing.T) {
func TestImage_Decode_BMP(t *testing.T) {
goldenTest(t, resources+"bmp.bmp", func(img *ImageRef) error {
goImg, err := img.ToImage(nil)
assert.NoError(t, err)

buf := new(bytes.Buffer)
err = bmp.Encode(buf, goImg)
Expand All @@ -488,6 +490,7 @@ func TestImage_Decode_BMP(t *testing.T) {
func TestImage_Decode_PNG(t *testing.T) {
goldenTest(t, resources+"png-8bit.png", func(img *ImageRef) error {
goImg, err := img.ToImage(nil)
assert.NoError(t, err)

buf := new(bytes.Buffer)
err = png.Encode(buf, goImg)
Expand Down
8 changes: 4 additions & 4 deletions vips/image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,7 @@ func TestGetPages_gif(t *testing.T) {
require.NoError(t, err)

pages := image.GetPages()
assert.Equal(t, pages, 8)
assert.Equal(t, 8, pages)
}

func TestGetPages_webp(t *testing.T) {
Expand All @@ -734,7 +734,7 @@ func TestGetPages_webp(t *testing.T) {
require.NoError(t, err)

pages := image.GetPages()
assert.Equal(t, pages, 8)
assert.Equal(t, 8, pages)
}

func TestImageRef_Divide__Error(t *testing.T) {
Expand Down Expand Up @@ -847,10 +847,10 @@ func TestImageRef_FindTrim_Threshold(t *testing.T) {
assert.Equal(t, 256, height)
}

func TestImageRef_Width(t *testing.T) {
func TestImageRef_Height(t *testing.T) {
image, err := NewImageFromFile(resources + "gif-animated-2.gif")
assert.NoError(t, err)
width := image.Width()
width := image.Height()
assert.Equal(t, 90, width)
}

Expand Down

0 comments on commit c725324

Please sign in to comment.