Sharp: .max is not a function

Created on 30 May 2019  路  4Comments  路  Source: lovell/sharp

What is the output of running npx envinfo --binaries --languages --system --utilities?

npx: installed 1 in 3.838s

  System:
    OS: macOS Sierra 10.12.6
    CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
    Memory: 85.00 MB / 16.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 10.15.3 - ~/.nvm/versions/node/v10.15.3/bin/node
    npm: 6.4.1 - ~/.nvm/versions/node/v10.15.3/bin/npm
  Utilities:
    Make: 3.81 - /usr/bin/make
    GCC: 4.2.1 - /usr/bin/gcc
    Git: 2.19.1 - /usr/local/bin/git
  Languages:
    Bash: 3.2.57 - /bin/bash
    Java: 1.8.0_202 - /usr/bin/javac
    Perl: 5.18.2 - /usr/bin/perl
    PHP: 5.6.30 - /usr/bin/php
    Python: 2.7.10 - /usr/bin/python
    Ruby: 2.0.0 - /usr/bin/ruby

My sharp version is 0.22.1

What are the steps to reproduce?
Run code below

What is the expected behaviour?
Resize occurs successfully. Removing .max causes the code to work

Are you able to provide a standalone code sample, without other dependencies, that demonstrates this problem?

      const fetch = require('node-fetch');

      const url = https://litcouncil.com/wp-content/uploads/resultados-test_9.jpg
      const imgBuffer = await (await fetch(url)).buffer();
      const resizedImage = await sharp(imgBuffer)
        .clone()
        .resize(width, height)
        .max()
        .toFormat(sharp.format.png);

Are you able to provide a sample image that helps explain the problem?
image

Funny thing is .trim, .background, and .embed aren't there either.

Most helpful comment

Here is the relevant line of the changelog:

max().withoutEnlargement() is now resize(width, height, { fit: 'inside', withoutEnlargement: true })

All 4 comments

Just read the changelog

Looks like a number of functions are deprecated and moved to params.

Here is the relevant line of the changelog:

max().withoutEnlargement() is now resize(width, height, { fit: 'inside', withoutEnlargement: true })

@lovell can you please follow Semantic Versioning so these breaking changes are more apparent.

https://semver.org/

Also, why is the library not at version 1? Is it not production ready?

@mattgaspar Please see #1448 #1754

Was this page helpful?
0 / 5 - 0 ratings