GoogleCloudPlatform / GoogleCloudPlatform/functions-framework-nodejs

imagemagick not working on google cloud function

Đang mở
#607 0 bình luận 1 reaction 0 người được giao Xem trên GitHub
bug P3
Ngôn ngữ chính
TypeScript
Star
1.4k
Fork
181
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

I am using this npm package for [image-magick](https://www.npmjs.com/package/imagemagick) and using google cloud functions framework to be used with my package.

the package that google cloud function are using for image magick as mentioned in their docs [https://cloud.google.com/appengine/docs/standard/reference/system-packages?tab=node.js#top](url), this doesn't work.

I am creating a simple function to download a file and then convert that pdf file to png file using this code

```
import * as util from "util";
import fs from "fs";

import * as im from "imagemagick";
import * as child_process from "child_process";
import functions from "@google-cloud/functions-framework";
import { CloudProvider } from "./packages/cloud-provider/src/index.js";

const { execFileSync, spawnSync, execSync } = child_process;

const cloud = CloudProvider.getInstance();

functions.http("im-testing", async (req, res) => {
let val = await cloud.storage.getFile(
"gcp-setup-testing",
"asad-testing/pdf-test.pdf"
);
const output1 = execSync("ls ./temp").toString();
console.log("before: ", output1);
fs.writeFileSync("./temp/pdf-test.pdf", val?.Body);
if (fs.existsSync("./temp/pdf-test.pdf")) {
execSync('chmod 755 ./temp/pdf-test.pdf');
}

let convert = util.promisify(im.convert);
let convArr = [
"-density",
"400",
"./temp/pdf-test.pdf",
"-resize",
"25%",
"./temp/a.png",
];
await convert(convArr);
const output2 = execSync("ls ./temp").toString();
console.log("after: ", output2);
res.status(200).json({ message: "File converted successfully" });
});

```

I always get this error `Command failed: convert-im6.q16: no images defined `./temp/a.png' @
error/convert.c/ConvertImageCommand/3229.`

I made a docker container using this

```
FROM node:20.9.0
# Install ImageMagick
RUN apt-get update -y && \
apt-get install -y imagemagick
WORKDIR /usr/src/app

COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build-ts
CMD ["npm", "run", "start-ts"]
```

but the max version that container allows for imagemagick is 6.9.11 and that isn't working.
I tried running a simple command for convert that also gave me the same error. Let me know if you need any other log or information on this one but the imagemagick v6.9.11 isn't working anymore on google cloud function

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Issue không nêu tên tệp hoặc bài kiểm thử nào trong repository; hãy bắt đầu với Node.js handler và Dockerfile được cung cấp, sau đó tái hiện lệnh chuyển đổi ImageMagick trong container đó và trong môi trường Google Cloud Function. Một kết quả hữu ích sẽ là xác nhận được nguyên nhân và ghi lại một thay đổi về framework hoặc runtime, nhưng issue không xác định hành vi nào cần được thay đổi.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
google-cloud, node.js, typescript
Lĩnh vực
backend, cloud
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Cần làm rõ
Mức phù hợp với người mới
25/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.