Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue when using with express #3

Open
Loyz07 opened this issue Oct 17, 2021 · 2 comments
Open

Issue when using with express #3

Loyz07 opened this issue Oct 17, 2021 · 2 comments

Comments

@Loyz07
Copy link

Loyz07 commented Oct 17, 2021

Hello kriasoft,

First thanks for your job. Very helpful !

I try to use this package within an express server but i face an issue. When i try to display the original image all works fine but when i add a manipulation prefix (for instance w_50), the cache image is generated in the cache bucket but empty 😳.

If i use the createHandler directly in a cloud function all works very well !

Could you help ?
Thanks.

Here a sample of my code

`
const express = require('express');
const { createHandler } = require('image-resizing');

const app = express();
const port = 3000;

app.get(
'/*',
createHandler({
sourceBucket: 'gs:///assets',
cacheBucket: 'gs:///cache',
})
);

app.listen(port, () => {
console.log(Example app listening at http://localhost:${port});
});
`

@koistya
Copy link
Member

koistya commented Oct 18, 2021

Most likely it means that ImageMagick is not installed on the machine where you run this code. Also note note that ImageMagick is one of the pre-installed native modules in Google Cloud Functions (GCF) environment. On MacOS you can install it via Brew:

$ brew update
$ brew install imagemagick

BTW, if you can create a PR with this info added to README.md that would be awesome!

@Loyz07
Copy link
Author

Loyz07 commented Oct 23, 2021

Hello Kriasoft,

You're right, with ImageMagick installed all works well.

I prepared a branch to create the PR but i don't have the permission to push it on the repo so I don't know how to create a PR. Sorry for that.

I only added the small text:
Note that ImageMagick must be installed for this package to work.
It is one of the pre-installed native modules in Google Cloud Functions (GCF) environment.
On MacOS you can install it via Brew:

brew update
brew install imagemagick

If you plan to deploy this package inside a Docker container, do not forget to install ImageMagick.
For instance, when using node:alpine base image, add the line below in your Dockerfile.

RUN apk add --no-cache file imagemagick

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants