Git Product home page Git Product logo

express-sharp's People

Contributors

dependabot[bot] avatar kriscarle avatar meabed avatar northamerican avatar pmb0 avatar renovate-bot avatar semantic-release-bot avatar winstonewert avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

express-sharp's Issues

ctrl-c doesn't kill the node process

Thanks for your project. I'm using it as a basis for one of my own (I have some unique requirements). =)

ctrl-c works if I just start up the server and don't use it. But, if I use it to render an image, I can't ctrl-c it. Nothing obvious stands out as to why that happens.

Thoughts?

How to get orginal size of image?

I saw this project code. But I see fix width 500px

resize.dto.ts

@Transform(Number) @IsNumber() @Min(1) @Max(10000) public width: number = 500

So I ask how to get orignal image size Eg: 1080px. I guess I must to pass query string w=1080. But I want to get origin w=1080 without pass w=1080

Thank you for this best useful project

Bypass transform

We use express-sharp to serve images. One problem we face is that there is no mechanism in express-sharp to bypass transformation, so we cannot serve animated GIFs from the same endpoint (without a middleware costing a double hit to storage).

As libvips has no [planned] support for animation, it would be useful if there was either a search parameter to bypass transform and just return the raw image, or if express-sharp could detect the prescence of an animation and bypass transformations for that file.

AVIF support

Hello, thank you for an awesome library. Do you plan to enable AVIF support?

basic configuration: Error: url must be an URL address

hey there,

thank you very much for your work!

I got a problem with a very simple configuration:

const sellerProductUploadDirectory = path.join(__dirname, '../upload/sellerProductImage');
app.use(express.static(sellerProductUploadDirectory));
app.use(
  '/upload/sellerProductImage',
  expressSharp({
    imageAdapter: new FsAdapter(sellerProductUploadDirectory),
  })
);

When trying to access the page i get the following for some images and not all:

node_1      | GET /upload/sellerProductImage/I8bKvIgxn-_default-product.jpg.jpg 400 30.998 ms - 261
node_1      | Error: url must be an URL address
node_1      |     at /backend/node_modules/express-sharp/src/middleware/validator.middleware.ts:21:14

This url seems to be fine: http://localhost:8080/upload/sellerProductImage/FrGn0UIUI-fernando-meloni-va6b5ag3Jvo-unsplash.jpg.jpg

This url is not working: http://localhost:8080/upload/sellerProductImage/i6va5p7dE-1060-536x354-blur_2.jpg.jpg

When i remove the middleware, both images work without a problem.

Any help would be appreciated!

npm install is showing vulnaribility due to class-validator ^0.13.1

Hello
Whenever I am running npm install, I am getting critical severity vulnerabilities. npm audit fix --force rollback express-sharp to 3.1.1, however, it again shows vulnerabilities there for other packages. Currently, I am in a loop and cannot solve this. Can someone please help me here to solve this?

Any help or guidance is much appreciated. Thanks in advance.

Error when express-sharp 4.2.41 is used:

class-validator  <0.14.0
Severity: critical
SQL Injection and Cross-site Scripting in class-validator - https://github.com/advisories/GHSA-fj58-h2fr-3pp2
fix available via `npm audit fix --force`
Will install [email protected], which is a breaking change
node_modules/class-validator
  express-sharp  >=4.0.1
  Depends on vulnerable versions of class-validator
  node_modules/express-sharp

2 critical severity vulnerabilities

To address all issues (including breaking changes), run:
  npm audit fix --force

image

Error when express-sharp 3.1.1 is used:


# npm audit report

got  <11.8.5
Severity: moderate
Got allows a redirect to a UNIX socket - https://github.com/advisories/GHSA-pfrx-2q88-qq97
fix available via `npm audit fix --force`
Will install [email protected], which is a breaking change
node_modules/got
  express-sharp  <=4.2.40
  Depends on vulnerable versions of express-validator
  Depends on vulnerable versions of got
  Depends on vulnerable versions of sharp
  node_modules/express-sharp

sharp  <0.30.5
Severity: moderate
sharp vulnerable to Command Injection in post-installation over build environment - https://github.com/advisories/GHSA-gp95-ppv5-3jc5
fix available via `npm audit fix --force`
Will install [email protected], which is a breaking change
node_modules/sharp

validator  <13.7.0
Severity: moderate
Inefficient Regular Expression Complexity in validator.js - https://github.com/advisories/GHSA-qgmg-gppg-76g5
fix available via `npm audit fix --force`
Will install [email protected], which is a breaking change
node_modules/express-sharp/node_modules/validator
  express-validator  0.2.0 - 6.4.1
  Depends on vulnerable versions of validator
  node_modules/express-sharp/node_modules/express-validator

5 moderate severity vulnerabilities

compatibility with AWS SDK for JavaScript (v3)

express-sharp is currently implementing AWS SDK for JavaScript (v2), which, following to aws, will enter maintenance mode soon. There is a warning message saying:

(node:697) NOTE: We are formalizing our plans to enter AWS SDK for JavaScript (v2) into maintenance mode in 2023.

Please migrate your code to use AWS SDK for JavaScript (v3).
For more information, check the migration guide at https://a.co/7PzMCcy

It would be great to migrate this project to v3 then. Thank you!

resize/num without height does not work

setup: follow readme instructions and request my-scale/resize/400
Results: Error: Expected integer between 1 and 16383 for height but received NaN of type number

Looking at sharp, in the resize function, it checks if height is defined, and the parseInt returns a defined number of 0 and thus errors out.

Please add support for node 12. Support for Node.js 12 was added in sharp v0.22.1

npx envinfo --binaries --languages --system --utilities

System:
OS: Linux 4.15 Ubuntu 18.04.3 LTS (Bionic Beaver)
CPU: (1) x64 Intel(R) Xeon(R) CPU E5-2676 v3 @ 2.40GHz
Memory: 395.96 MB / 983.69 MB
Container: Yes
Shell: 4.4.20 - /bin/bash
Binaries:
Node: 12.16.1 - /usr/bin/node
npm: 6.13.4 - /usr/bin/npm
Utilities:
Make: 4.1 - /usr/bin/make
GCC: 7.4.0 - /usr/bin/gcc
Git: 2.17.1 - /usr/bin/git
Languages:
Bash: 4.4.20 - /bin/bash
Perl: 5.26.1 - /usr/bin/perl
Python: 2.7.17 - /usr/bin/python
Python3: 3.6.9 - /usr/bin/python3

What are the steps to reproduce?

npm install --save express-sharp --verbose

sample that helps explain the problem

sudo npm install --save express-sharp --verbose npm info it worked if it ends with ok
npm verb cli [
npm verb cli '/usr/bin/node',
npm verb cli '/usr/bin/npm',
npm verb cli 'install',
npm verb cli '--save',
npm verb cli 'express-sharp',
npm verb cli '--verbose'
npm verb cli ]
npm info using [email protected]
npm info using [email protected]
npm verb npm-session 3fc7b0c9bc0b1d6b
npm http fetch GET 304 https://registry.npmjs.org/express-sharp 84ms (from cache)
npm timing stage:loadCurrentTree Completed in 507ms
npm timing stage:loadIdealTree:cloneCurrentTree Completed in 6ms
npm timing stage:loadIdealTree:loadShrinkwrap Completed in 208ms
npm http fetch GET 304 https://registry.npmjs.org/cors 63ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/debug 82ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/express-validator 83ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/sharp 93ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/object-assign 22ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/ms 26ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/validator 24ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/@types%2fexpress 31ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/@types%2fbody-parser 35ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/@types%2fexpress-serve-static-core 39ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/@types%2fserve-static 40ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/@types%2fconnect 26ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/@types%2fnode 41ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/@types%2frange-parser 27ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/@types%2fmime 35ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/color 64ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/caw 82ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/detect-libc 85ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/nan 87ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/tar 90ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/semver 93ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/simple-get 93ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/get-proxy 31ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/url-to-options 41ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/isurl 43ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/npm-conf 39ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/config-chain 21ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/pify 28ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/proto-list 40ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/ini 41ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/has-to-string-tag-x 32ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/is-object 44ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/has-symbol-support-x 21ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/color-convert 19ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/color-string 33ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/color-name 19ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/simple-swizzle 20ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/is-arrayish 25ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/decompress-response 22ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/once 31ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/simple-concat 38ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/mimic-response 16ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/wrappy 18ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/minizlib 44ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/minipass 45ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/yallist 48ms (from cache)
npm http fetch GET 304 https://registry.npmjs.org/chownr 50ms (from cache)
npm timing stage:loadIdealTree:loadAllDepsIntoIdealTree Completed in 1187ms
npm timing stage:loadIdealTree Completed in 1479ms
npm timing stage:generateActionsToTake Completed in 24ms
npm verb correctMkdir /home/udhay/.npm/_locks correctMkdir not in flight; initializing
npm verb lock using /home/udhay/.npm/_locks/staging-9b3b6422e8b6e054.lock for /home/udhay/api/node_modules/.staging
npm timing action:extract Completed in 452ms
npm timing action:finalize Completed in 48ms
npm timing action:refresh-package-json Completed in 134ms
npm info lifecycle @types/[email protected]: @types/[email protected]
npm info lifecycle @types/[email protected]: @types/[email protected]
npm info lifecycle @types/[email protected]: @types/[email protected]
npm info lifecycle @types/[email protected]: @types/[email protected]
npm info lifecycle @types/[email protected]: @types/[email protected]
npm info lifecycle @types/[email protected]: @types/[email protected]
npm info lifecycle @types/[email protected]: @types/[email protected]
npm info lifecycle @types/[email protected]: @types/[email protected]
npm info lifecycle [email protected]: [email protected]
npm info lifecycle [email protected]: [email protected]
npm info lifecycle [email protected]: [email protected]
npm info lifecycle [email protected]: [email protected]
npm info lifecycle [email protected]: [email protected]
npm info lifecycle [email protected]: [email protected]
npm info lifecycle [email protected]: [email protected]
npm info lifecycle [email protected]: [email protected]
npm info lifecycle [email protected]: [email protected]
npm info lifecycle [email protected]: [email protected]
npm info lifecycle [email protected]: [email protected]
npm info lifecycle [email protected]: [email protected]
npm info lifecycle [email protected]: [email protected]
npm info lifecycle [email protected]: [email protected]
npm info lifecycle [email protected]: [email protected]
npm info lifecycle [email protected]: [email protected]
npm info lifecycle [email protected]: [email protected]
npm info lifecycle [email protected]: [email protected]
npm info lifecycle [email protected]: [email protected]
npm info lifecycle [email protected]: [email protected]
npm info lifecycle [email protected]: [email protected]
npm info lifecycle [email protected]: [email protected]
npm info lifecycle [email protected]: [email protected]
npm info lifecycle [email protected]: [email protected]
npm info lifecycle [email protected]: [email protected]
npm info lifecycle [email protected]: [email protected]
npm info lifecycle [email protected]: [email protected]
npm info lifecycle [email protected]: [email protected]
npm info lifecycle [email protected]: [email protected]
npm info lifecycle [email protected]: [email protected]
npm info lifecycle [email protected]: [email protected]
npm info lifecycle [email protected]: [email protected]
npm info lifecycle [email protected]: [email protected]
npm info lifecycle [email protected]: [email protected]
npm info lifecycle [email protected]: [email protected]
npm info lifecycle [email protected]: [email protected]
npm info lifecycle [email protected]: [email protected]
npm info lifecycle [email protected]: [email protected]
npm info lifecycle [email protected]: [email protected]
npm info lifecycle [email protected]: [email protected]
npm timing action:preinstall Completed in 31ms
npm info linkStuff @types/[email protected]
npm info linkStuff @types/[email protected]
npm info linkStuff @types/[email protected]
npm info linkStuff @types/[email protected]
npm info linkStuff @types/[email protected]
npm info linkStuff @types/[email protected]
npm info linkStuff @types/[email protected]
npm info linkStuff @types/[email protected]
npm info linkStuff [email protected]
npm info linkStuff [email protected]
npm info linkStuff [email protected]
npm info linkStuff [email protected]
npm verb linkBins [
npm verb linkBins { 'detect-libc': 'bin/detect-libc.js' },
npm verb linkBins '/home/udhay/api/node_modules/.bin',
npm verb linkBins false
npm verb linkBins ]
npm info linkStuff [email protected]
npm info linkStuff [email protected]
npm info linkStuff [email protected]
npm info linkStuff [email protected]
npm info linkStuff [email protected]
npm info linkStuff [email protected]
npm info linkStuff [email protected]
npm info linkStuff [email protected]
npm info linkStuff [email protected]
npm info linkStuff [email protected]
npm info linkStuff [email protected]
npm info linkStuff [email protected]
npm info linkStuff [email protected]
npm info linkStuff [email protected]
npm info linkStuff [email protected]
npm info linkStuff [email protected]
npm info linkStuff [email protected]
npm verb linkBins [
npm verb linkBins { semver: 'bin/semver' },
npm verb linkBins '/home/udhay/api/node_modules/.bin',
npm verb linkBins false
npm verb linkBins ]
npm info linkStuff [email protected]
npm info linkStuff [email protected]
npm info linkStuff [email protected]
npm info linkStuff [email protected]
npm info linkStuff [email protected]
npm info linkStuff [email protected]
npm info linkStuff [email protected]
npm info linkStuff [email protected]
npm info linkStuff [email protected]
npm info linkStuff [email protected]
npm info linkStuff [email protected]
npm info linkStuff [email protected]
npm info linkStuff [email protected]
npm info linkStuff [email protected]
npm info linkStuff [email protected]
npm info linkStuff [email protected]
npm info linkStuff [email protected]
npm info linkStuff [email protected]
npm info linkStuff [email protected]
npm timing action:build Completed in 33ms
npm info lifecycle @types/[email protected]: @types/[email protected]
npm info lifecycle @types/[email protected]: @types/[email protected]
npm info lifecycle @types/[email protected]: @types/[email protected]
npm info lifecycle @types/[email protected]: @types/[email protected]
npm info lifecycle @types/[email protected]: @types/[email protected]
npm info lifecycle @types/[email protected]: @types/[email protected]
npm info lifecycle @types/[email protected]: @types/[email protected]
npm info lifecycle @types/[email protected]: @types/[email protected]
npm info lifecycle [email protected]: [email protected]
npm info lifecycle [email protected]: [email protected]
npm info lifecycle [email protected]: [email protected]
npm info lifecycle [email protected]: [email protected]
npm info lifecycle [email protected]: [email protected]
npm info lifecycle [email protected]: [email protected]
npm info lifecycle [email protected]: [email protected]
npm info lifecycle [email protected]: [email protected]
npm info lifecycle [email protected]: [email protected]
npm info lifecycle [email protected]: [email protected]
npm info lifecycle [email protected]: [email protected]
npm info lifecycle [email protected]: [email protected]
npm info lifecycle [email protected]: [email protected]
npm info lifecycle [email protected]: [email protected]
npm info lifecycle [email protected]: [email protected]
npm info lifecycle [email protected]: [email protected]
npm info lifecycle [email protected]: [email protected]
npm info lifecycle [email protected]: [email protected]
npm info lifecycle [email protected]: [email protected]
npm info lifecycle [email protected]: [email protected]
npm info lifecycle [email protected]: [email protected]
npm info lifecycle [email protected]: [email protected]
npm info lifecycle [email protected]: [email protected]
npm info lifecycle [email protected]: [email protected]
npm info lifecycle [email protected]: [email protected]
npm info lifecycle [email protected]: [email protected]
npm info lifecycle [email protected]: [email protected]
npm info lifecycle [email protected]: [email protected]
npm info lifecycle [email protected]: [email protected]
npm info lifecycle [email protected]: [email protected]
npm info lifecycle [email protected]: [email protected]
npm info lifecycle [email protected]: [email protected]
npm info lifecycle [email protected]: [email protected]
npm info lifecycle [email protected]: [email protected]
npm info lifecycle [email protected]: [email protected]
npm info lifecycle [email protected]: [email protected]
npm info lifecycle [email protected]: [email protected]
npm info lifecycle [email protected]: [email protected]
npm info lifecycle [email protected]~install: [email protected]

[email protected] install /home/udhay/api/node_modules/sharp
node-gyp rebuild

gyp info it worked if it ends with ok
gyp verb cli [
gyp verb cli '/usr/bin/node',
gyp verb cli '/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js',
gyp verb cli 'rebuild'
gyp verb cli ]
gyp info using [email protected]
gyp info using [email protected] | linux | x64
gyp verb command rebuild []
gyp verb command clean []
gyp verb clean removing "build" directory
gyp verb command configure []
gyp verb find Python Python is not set from command line or npm configuration
gyp verb find Python Python is not set from environment variable PYTHON
gyp verb find Python checking if "python" can be used
gyp verb find Python - executing "python" to get executable path
gyp verb find Python - executable path is "/usr/bin/python"
gyp verb find Python - executing "/usr/bin/python" to get version
gyp verb find Python - version is "2.7.17"
gyp info find Python using Python version 2.7.17 found at "/usr/bin/python"
gyp verb get node dir no --target version specified, falling back to host node version: 12.16.1
gyp verb command install [ '12.16.1' ]
gyp verb install input version string "12.16.1"
gyp verb install installing version: 12.16.1
gyp verb install --ensure was passed, so won't reinstall if already installed
gyp verb install version is already installed, need to check "installVersion"
gyp verb got "installVersion" 9
gyp verb needs "installVersion" 9
gyp verb install version is good
gyp verb get node dir target node version installed: 12.16.1
gyp verb build dir attempting to create "build" dir: /home/udhay/api/node_modules/sharp/build
gyp verb build dir "build" dir needed to be created? /home/udhay/api/node_modules/sharp/build
gyp verb build/config.gypi creating config file
gyp verb build/config.gypi writing out config file: /home/udhay/api/node_modules/sharp/build/config.gypi
gyp verb config.gypi checking for gypi file: /home/udhay/api/node_modules/sharp/config.gypi
gyp verb common.gypi checking for gypi file: /home/udhay/api/node_modules/sharp/common.gypi
gyp verb gyp gyp format was not specified; forcing "make"
gyp info spawn /usr/bin/python
gyp info spawn args [
gyp info spawn args '/usr/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args 'binding.gyp',
gyp info spawn args '-f',
gyp info spawn args 'make',
gyp info spawn args '-I',
gyp info spawn args '/home/udhay/api/node_modules/sharp/build/config.gypi',
gyp info spawn args '-I',
gyp info spawn args '/usr/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
gyp info spawn args '-I',
gyp info spawn args '/home/udhay/.cache/node-gyp/12.16.1/include/node/common.gypi',
gyp info spawn args '-Dlibrary=shared_library',
gyp info spawn args '-Dvisibility=default',
gyp info spawn args '-Dnode_root_dir=/home/udhay/.cache/node-gyp/12.16.1',
gyp info spawn args '-Dnode_gyp_dir=/usr/lib/node_modules/npm/node_modules/node-gyp',
gyp info spawn args '-Dnode_lib_file=/home/udhay/.cache/node-gyp/12.16.1/<(target_arch)/node.lib',
gyp info spawn args '-Dmodule_root_dir=/home/udhay/api/node_modules/sharp',
gyp info spawn args '-Dnode_engine=v8',
gyp info spawn args '--depth=.',
gyp info spawn args '--no-parallel',
gyp info spawn args '--generator-output',
gyp info spawn args 'build',
gyp info spawn args '-Goutput_dir=.'
gyp info spawn args ]
gyp verb command build []
gyp verb build type Release
gyp verb architecture x64
gyp verb node dev dir /home/udhay/.cache/node-gyp/12.16.1
gyp verb which succeeded for make /usr/bin/make
gyp info spawn make
gyp info spawn args [ 'V=1', 'BUILDTYPE=Release', '-C', 'build' ]
make: Entering directory '/home/udhay/api/node_modules/sharp/build'
touch Release/obj.target/libvips-cpp.stamp
g++ '-DNODE_GYP_MODULE_NAME=sharp' '-DUSING_UV_SHARED=1' '-DUSING_V8_SHARED=1' '-DV8_DEPRECATION_WARNINGS=1' '-DV8_DEPRECATION_WARNINGS' '-DV8_IMMINENT_DEPRECATION_WARNINGS' '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-D__STDC_FORMAT_MACROS' '-DOPENSSL_NO_PINSHARED' '-DOPENSSL_THREADS' '-D_GLIBCXX_USE_CXX11_ABI=0' '-DBUILDING_NODE_EXTENSION' -I/home/udhay/.cache/node-gyp/12.16.1/include/node -I/home/udhay/.cache/node-gyp/12.16.1/src -I/home/udhay/.cache/node-gyp/12.16.1/deps/openssl/config -I/home/udhay/.cache/node-gyp/12.16.1/deps/openssl/openssl/include -I/home/udhay/.cache/node-gyp/12.16.1/deps/uv/include -I/home/udhay/.cache/node-gyp/12.16.1/deps/zlib -I/home/udhay/.cache/node-gyp/12.16.1/deps/v8/include -I../../nan -I../vendor/include -I../vendor/include/glib-2.0 -I../vendor/lib/glib-2.0/include -fPIC -pthread -Wall -Wextra -Wno-unused-parameter -m64 -O3 -fno-omit-frame-pointer -fno-rtti -fno-exceptions -std=gnu++1y -std=c++0x -fexceptions -Wall -O3 -MMD -MF ./Release/.deps/Release/obj.target/sharp/src/common.o.d.raw -c -o Release/obj.target/sharp/src/common.o ../src/common.cc
In file included from ../src/common.cc:27:0:
../src/common.h:78:20: error: ‘Handle’ is not a member of ‘v8’
bool HasAttr(v8::Handlev8::Object obj, std::string attr);
^~~~~~
../src/common.h:78:37: error: expected primary-expression before ‘>’ token
bool HasAttr(v8::Handlev8::Object obj, std::string attr);
^
../src/common.h:78:39: error: ‘obj’ was not declared in this scope
bool HasAttr(v8::Handlev8::Object obj, std::string attr);
^~~
../src/common.h:78:56: error: expected primary-expression before ‘attr’
bool HasAttr(v8::Handlev8::Object obj, std::string attr);
^~~~
../src/common.h:78:60: error: expression list treated as compound expression in initializer [-fpermissive]
bool HasAttr(v8::Handlev8::Object obj, std::string attr);
^
../src/common.h:79:29: error: ‘Handle’ is not a member of ‘v8’
std::string AttrAsStr(v8::Handlev8::Object obj, std::string attr);
^~~~~~
../src/common.h:79:46: error: expected primary-expression before ‘>’ token
std::string AttrAsStr(v8::Handlev8::Object obj, std::string attr);
^
../src/common.h:79:48: error: ‘obj’ was not declared in this scope
std::string AttrAsStr(v8::Handlev8::Object obj, std::string attr);
^~~
../src/common.h:79:65: error: expected primary-expression before ‘attr’
std::string AttrAsStr(v8::Handlev8::Object obj, std::string attr);
^~~~
../src/common.h:80:48: error: ‘Handle’ is not a member of ‘v8’
template v8::Local AttrAs(v8::Handlev8::Object obj, std::string attr) {
^~~~~~
../src/common.h:80:65: error: expected primary-expression before ‘>’ token
template v8::Local AttrAs(v8::Handlev8::Object obj, std::string attr) {
^
../src/common.h:80:67: error: ‘obj’ was not declared in this scope
template v8::Local AttrAs(v8::Handlev8::Object obj, std::string attr) {
^~~
../src/common.h:80:84: error: expected primary-expression before ‘attr’
typename T> v8::Local AttrAs(v8::Handlev8::Object obj, std::string attr) {
^~~~
../src/common.h:80:37: warning: variable templates only available with -std=c++14 or -std=gnu++14
template v8::Local AttrAs(v8::Handlev8::Object obj, std::string attr) {
^~~~~~
../src/common.h:80:90: error: expected ‘;’ before ‘{’ token
typename T> v8::Local AttrAs(v8::Handlev8::Object obj, std::string attr)

../src/common.h:83:37: error: ‘Handle’ is not a member of ‘v8’
template T AttrTo(v8::Handlev8::Object obj, std::string attr) {
^~~~~~
../src/common.h:83:54: error: expected primary-expression before ‘>’ token
template T AttrTo(v8::Handlev8::Object obj, std::string attr) {
^
../src/common.h:83:56: error: ‘obj’ was not declared in this scope
template T AttrTo(v8::Handlev8::Object obj, std::string attr) {
^~~
../src/common.h:83:73: error: expected primary-expression before ‘attr’
template T AttrTo(v8::Handlev8::Object obj, std::string attr) {
^~~~
../src/common.h:83:26: warning: variable templates only available with -std=c++14 or -std=gnu++14
template T AttrTo(v8::Handlev8::Object obj, std::string attr) {
^~~~~~
../src/common.h:83:79: error: expected ‘;’ before ‘{’ token
template T AttrTo(v8::Handlev8::Object obj, std::string attr)

../src/common.h:86:37: error: ‘Handle’ is not a member of ‘v8’
template T AttrTo(v8::Handlev8::Object obj, int attr) {
^~~~~~
../src/common.h:86:54: error: expected primary-expression before ‘>’ token
template T AttrTo(v8::Handlev8::Object obj, int attr) {
^
../src/common.h:86:56: error: ‘obj’ was not declared in this scope
template T AttrTo(v8::Handlev8::Object obj, int attr) {
^~~
../src/common.h:86:61: error: expected primary-expression before ‘int’
template T AttrTo(v8::Handlev8::Object obj, int attr) {
^~~
../src/common.h:83:26: warning: variable templates only available with -std=c++14 or -std=gnu++14
template T AttrTo(v8::Handlev8::Object obj, std::string attr) {
^~~~~~
../src/common.h:86:71: error: expected ‘;’ before ‘{’ token
template T AttrTo(v8::Handlev8::Object obj, int attr) {
^
../src/common.h:92:9: error: ‘Handle’ is not a member of ‘v8’
v8::Handlev8::Object input, std::vectorv8::Localv8::Object &buffersToPersist);
^~~~~~
../src/common.h:92:26: error: expected primary-expression before ‘>’ token
v8::Handlev8::Object input, std::vectorv8::Localv8::Object &buffersToPersist);
^
../src/common.h:92:28: error: ‘input’ was not declared in this scope
v8::Handlev8::Object input, std::vectorv8::Localv8::Object &buffersToPersist);
^~~~~
../src/common.h:92:28: note: suggested alternative: ‘ino_t’
v8::Handlev8::Object input, std::vectorv8::Localv8::Object &buffersToPersist);
^~~~~
ino_t
../src/common.h:92:70: error: expected primary-expression before ‘&’ token
v8::Handlev8::Object input, std::vectorv8::Localv8::Object &buffersToPersist);
^
../src/common.h:92:71: error: ‘buffersToPersist’ was not declared in this scope
v8::Handlev8::Object input, std::vectorv8::Localv8::Object &buffersToPersist);
^~~~~~~~~~~~~~~~
../src/common.h:92:87: error: expression list treated as compound expression in initializer [-fpermissive]
andlev8::Object input, std::vectorv8::Localv8::Object &buffersToPersist);
^
../src/common.cc:34:20: error: redefinition of ‘bool sharp::HasAttr’
bool HasAttr(v8::Handlev8::Object obj, std::string attr) {
^~~~~~
In file included from ../src/common.cc:27:0:
../src/common.h:78:8: note: ‘bool sharp::HasAttr’ previously defined here
bool HasAttr(v8::Handlev8::Object obj, std::string attr);
^~~~~~~
../src/common.cc:34:20: error: ‘Handle’ is not a member of ‘v8’
bool HasAttr(v8::Handlev8::Object obj, std::string attr) {
^~~~~~
../src/common.cc:34:37: error: expected primary-expression before ‘>’ token
bool HasAttr(v8::Handlev8::Object obj, std::string attr) {
^
../src/common.cc:34:39: error: ‘obj’ was not declared in this scope
bool HasAttr(v8::Handlev8::Object obj, std::string attr) {
^~~
../src/common.cc:34:56: error: expected primary-expression before ‘attr’
bool HasAttr(v8::Handlev8::Object obj, std::string attr) {
^~~~
../src/common.cc:37:29: error: redefinition of ‘std::string sharp::AttrAsStr’
std::string AttrAsStr(v8::Handlev8::Object obj, std::string attr) {
^~~~~~
In file included from ../src/common.cc:27:0:
../src/common.h:79:15: note: ‘std::string sharp::AttrAsStr’ previously declared here
std::string AttrAsStr(v8::Handlev8::Object obj, std::string attr);
^~~~~~~~~
../src/common.cc:37:29: error: ‘Handle’ is not a member of ‘v8’
std::string AttrAsStr(v8::Handlev8::Object obj, std::string attr) {
^~~~~~
../src/common.cc:37:46: error: expected primary-expression before ‘>’ token
std::string AttrAsStr(v8::Handlev8::Object obj, std::string attr) {
^
../src/common.cc:37:48: error: ‘obj’ was not declared in this scope
std::string AttrAsStr(v8::Handlev8::Object obj, std::string attr) {
^~~
../src/common.cc:37:65: error: expected primary-expression before ‘attr’
std::string AttrAsStr(v8::Handlev8::Object obj, std::string attr) {
^~~~
../src/common.cc:43:9: error: redefinition of ‘sharp::InputDescriptor* sharp::CreateInputDescriptor’
v8::Handlev8::Object input, std::vectorv8::Localv8::Object &buffersToPersist
^~~~~~
In file included from ../src/common.cc:27:0:
../src/common.h:91:20: note: ‘sharp::InputDescriptor* sharp::CreateInputDescriptor’ previously defined here
InputDescriptor* CreateInputDescriptor(
^~~~~~~~~~~~~~~~~~~~~
../src/common.cc:43:9: error: ‘Handle’ is not a member of ‘v8’
v8::Handlev8::Object input, std::vectorv8::Localv8::Object &buffersToPersist
^~~~~~
../src/common.cc:43:26: error: expected primary-expression before ‘>’ token
v8::Handlev8::Object input, std::vectorv8::Localv8::Object &buffersToPersist
^
../src/common.cc:43:28: error: ‘input’ was not declared in this scope
v8::Handlev8::Object input, std::vectorv8::Localv8::Object &buffersToPersist
^~~~~
../src/common.cc:43:28: note: suggested alternative: ‘ino_t’
v8::Handlev8::Object input, std::vectorv8::Localv8::Object &buffersToPersist
^~~~~
ino_t
../src/common.cc:43:70: error: expected primary-expression before ‘&’ token
v8::Handlev8::Object input, std::vectorv8::Localv8::Object &buffersToPersist
^
../src/common.cc:43:71: error: ‘buffersToPersist’ was not declared in this scope
v8::Handlev8::Object input, std::vectorv8::Localv8::Object &buffersToPersist
^~~~~~~~~~~~~~~~
sharp.target.mk:135: recipe for target 'Release/obj.target/sharp/src/common.o' failed
make: *** [Release/obj.target/sharp/src/common.o] Error 1
make: Leaving directory '/home/udhay/api/node_modules/sharp/build'
gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack at ChildProcess.emit (events.js:311:20)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
gyp ERR! System Linux 4.15.0-1057-aws
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/udhay/api/node_modules/sharp
gyp ERR! node -v v12.16.1
gyp ERR! node-gyp -v v5.0.5
gyp ERR! not ok
npm verb lifecycle [email protected]: unsafe-perm in lifecycle false
npm verb lifecycle [email protected]: PATH: /usr/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/udhay/api/node_modules/sharp/node_modules/.bin:/home/udhay/api/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin
npm verb lifecycle [email protected]: CWD: /home/udhay/api/node_modules/sharp
npm timing audit submit Completed in 1165ms
npm http fetch POST 200 https://registry.npmjs.org/-/npm/v1/security/audits/quick 1165ms
npm timing audit body Completed in 5ms
npm info lifecycle [email protected]: Failed to exec install script
npm timing action:install Completed in 21375ms
npm verb unlock done using /home/udhay/.npm/_locks/staging-9b3b6422e8b6e054.lock for /home/udhay/api/node_modules/.staging
npm timing stage:rollbackFailedOptional Completed in 198ms
npm timing stage:runTopLevelLifecycles Completed in 24379ms
npm WARN [email protected] No description
npm WARN [email protected] No repository field.

npm verb stack Error: [email protected] install: node-gyp rebuild
npm verb stack Exit status 1
npm verb stack at EventEmitter. (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
npm verb stack at EventEmitter.emit (events.js:311:20)
npm verb stack at ChildProcess. (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
npm verb stack at ChildProcess.emit (events.js:311:20)
npm verb stack at maybeClose (internal/child_process.js:1021:16)
npm verb stack at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
npm verb pkgid [email protected]
npm verb cwd /home/udhay/api
npm verb Linux 4.15.0-1057-aws
npm verb argv "/usr/bin/node" "/usr/bin/npm" "install" "--save" "express-sharp" "--verbose"
npm verb node v12.16.1
npm verb npm v6.13.4
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm verb exit [ 1, true ]
npm timing npm Completed in 24784ms

npm ERR! A complete log of this run can be found in:
npm ERR! /home/udhay/.npm/_logs/2020-02-23T10_14_17_798Z-debug.log

v4.1.4 fix

I don't need Amazon S3. Could you fix the issue for image IDs may contain slashes again (34811d0) in v4.1.4? Many thanks!!

How to set cache control

Dear All,

Please help me config cache control into response headers

cache-control: public,max-age=2592000

Translation request for KoaJS

I want the index.js to be written for koajs as an alternative to express. koajs is almost similar to express, but I'm new to this nodejs stuff and I am not familiar with koa. ReactQL uses koa instead of express. Can you translate index.js of express-sharp (of version present at: npm) to koa if you've time?

I tried to translate but I faced basic conceptual difficulty related to Promise(because I'm weak at it), tried asking on Stackoverflow but failed to write the code with the help.

I am stuck at handling promise & using it's result further, code generated till now:
Server.js:

const koa = require('koa');
var app = new koa();
const etag = require('etag')
const sharp = require('sharp')
const url = require('url')
const http = require('http')
const https = require('https')
const router = require('koa-router')();
require('koa-validate')(app);

const options = {baseHost: '127.0.0.1:3000'};

const transform = function(width, height) {
  const transformer = sharp()
 transformer.resize(width, height).ignoreAspectRatio()
  return transformer
}

const getImageUrl = function(baseHost, inputUrl) {
  let imageUrl = url.parse(inputUrl)
  imageUrl.host = baseHost.replace('https://', '').replace('http://', '')
  imageUrl.protocol = baseHost.startsWith('https') ? 'https' : 'http'
  return url.format(imageUrl)
}

router.get('/my-scale/resize/:width/:height?', async(ctx, next) => {
  const protocol = (options.baseHost.startsWith('https')) ? https : http
		let format = 'webp'
		const quality = parseInt(ctx.query.quality || 75, 10)
		const imageUrl = getImageUrl(options.baseHost, ctx.query.url)

		const width = parseInt(ctx.params.width, 10)
		const height = parseInt(ctx.params.height, 10) || null
		const transformer = transform(width, height).on('error', function sharpError(err) {
        ctx.status = 500;
        next(new Error(err))
      })

		const etagBuffer = Buffer.from([imageUrl, width, height, format, quality])
		ctx.set('ETag', etag(etagBuffer, {weak: true}))
		if (ctx.fresh) {
			ctx.status = 304;
			return next();
		}
		        const request = new Promise(resolve => protocol.get(imageUrl, resolve));
        const result = await request;
		

        if (result.statusCode >= 400) {
          ctx.status = result.statusCode;
		  return next();
        }
        ctx.status = result.statusCode;
        const inputFormat = result.headers['content-type'] || ''
        format = format || inputFormat.replace('image/', '')

        format = sharp.format.hasOwnProperty(format) ? format : 'jpeg'
        transformer[format]({
          quality: quality,
          progressive: false,
        })
        ctx.type = 'image/' + format
        result.pipe(transformer).pipe(ctx)

});

app.use(router.routes()).use(router.allowedMethods());
app.listen(3000);
console.log("Listening on port 3000");

Package.json:

{
  "name": "sharpkoa",
  "version": "1.0.0",
  "description": "",
  "main": "server.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "etag": "^1.8.1",
    "http": "0.0.0",
    "https": "^1.0.0",
    "koa": "^2.4.1",
    "koa-router": "^7.3.0",
    "koa-validate": "^1.0.7",
    "sharp": "^0.18.4",
    "url": "^0.11.0"
  }
}

I need only width, height, format(webp) option nothing else and no need of special custom validations. I will be happy if someone helps me out to get the result as same as the express-sharp gives.

Option to disable default width of 500px and option to maintain the original rotation

I have the following code

const { expressSharp, HttpAdapter } = require('express-sharp')

const express = require('express');
const cache = require('express-cache-headers')
const Keyv = require('keyv');

const app = express();

app.disable('x-powered-by');
app.use(cache(315360000))

app.use(
  '/storage',
  expressSharp({
    imageAdapter: new HttpAdapter({
      cache: new Keyv('redis://cache', { namespace: 'connect-sharp' }),
      prefixUrl: 'https://connect.5-anker.com/storage',
    }),
  })
)

When I embed the following image without a specified width/height I get an auto width of 500px and the rotation is wrong:

"Sharped":
https://assets.5-anker.com/storage/boat/planenvariante-4-bug-humfree-nofreetete-freedy-gonzales-freewatuut-alfreedojpg_6516e5d7b14a6.jpg

"Original":
https://connect.5-anker.com/storage/boat/planenvariante-4-bug-humfree-nofreetete-freedy-gonzales-freewatuut-alfreedojpg_6516e5d7b14a6.jpg

How do I maintain the original width and rotation?

ipfs support using exiv2

links that dont have a extension type such as ipfs isnt supported, also resizing gifs doesnt seem tow rok

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.