Assigned
Status Update
Comments
jm...@google.com <jm...@google.com> #2
There is a tutorial for converting images to JPG [1], but I am not sure if this works for PDFs. Cloud Functions simply runs 'apt-get install imagemagick' as seen in the source here [2] (it uses the same Dockerfile as App Engine) to install the ImageMagick commands [3].
As per the blue 'Note' in the tutorial [4], you can additionally use a Node.js wrapper for ImageMagick [5] to directly make use of all of the functionalities of ImageMagick via the Node.js language (as opposed to running commands in Node.js).
[1]https://github.com/firebase/functions-samples/tree/master/convert-images
[2]https://github.com/GoogleCloudPlatform/nodejs-docker/blob/master/runtime-image/Dockerfile
[3]https://www.imagemagick.org/script/convert.php
[4]https://cloud.google.com/functions/docs/tutorials/imagemagick
[5]https://www.npmjs.com/package/gm
As per the blue 'Note' in the tutorial [4], you can additionally use a Node.js wrapper for ImageMagick [5] to directly make use of all of the functionalities of ImageMagick via the Node.js language (as opposed to running commands in Node.js).
[1]
[2]
[3]
[4]
[5]
er...@skovin.no <er...@skovin.no> #3
Hi, and thank you for your reply.
To clarify, I have successfully created functions that uses imagemagick for
* jpg -> jpg (thumbnails)
* jpg -> pdf
But unfortunately
* pdf -> jpg
doesn't work which I believe is because the gs package is missing. So I can confirm that it doesn't work for creating PDFs. I don't think using imagemagick directly in node will change that unfortunately.
To clarify, I have successfully created functions that uses imagemagick for
* jpg -> jpg (thumbnails)
* jpg -> pdf
But unfortunately
* pdf -> jpg
doesn't work which I believe is because the gs package is missing. So I can confirm that it doesn't work for creating PDFs. I don't think using imagemagick directly in node will change that unfortunately.
jm...@google.com <jm...@google.com> #4
You are correct. I was hoping installing ImageMagick would also include Ghostscript, but I am only seeing the 'type-ghostscript.xml' file included. I went ahead and notified the engineering team of this issue and they are currently investigating it. There is no ETA at this time for the fix.
mt...@gmail.com <mt...@gmail.com> #5
This would be great!
sa...@gmail.com <sa...@gmail.com> #6
hi, i have the same problem... i need of gs for convert pdf to thumbnail jpg...
There is a solutions ?
Thanks
There is a solutions ?
Thanks
bf...@spatialdatalogic.com <bf...@spatialdatalogic.com> #7
any news on this? it would be great for processing pdfs in cloud storage
tc...@gmail.com <tc...@gmail.com> #8
I am using chrome headless in a cloud function to generate PDFs but, sadly, it creates enormous files when there are many duplicate images. I want to use ghostscript to remove the duplicate images and perform other optimizations.
" I went ahead and notified the engineering team of this issue and they are currently investigating it. There is no ETA at this time for the fix. "
This has been with the engineering team for 1.5 **years**. Can we please get a resolution here?
" I went ahead and notified the engineering team of this issue and they are currently investigating it. There is no ETA at this time for the fix. "
This has been with the engineering team for 1.5 **years**. Can we please get a resolution here?
rl...@bol.com <rl...@bol.com> #9
Turns out that ghostscript is already installed in the Go 1.11 runtime!!
you can try it yourselves, but deploying the code below as a function.
// Package p contains a Google Cloud Storage Cloud Function.
package p
import (
"context"
"log"
"os/exec"
)
// GCSEvent is the payload of a GCS event. Please refer to the docs for
// additional information regarding GCS events.
type GCSEvent struct {
Bucket string `json:"bucket"`
Name string `json:"name"`
}
// HelloGCS prints a message when a file is changed in a Cloud Storage bucket.
func HelloGCS(ctx context.Context, e GCSEvent) error {
log.Printf("Processing file: %s", e.Name)
path, err := exec.LookPath("gs")
if err != nil {
log.Fatalf("error: %v", err)
}
log.Printf("ghostscript installed at %s\n", path)
return nil
}
you can try it yourselves, but deploying the code below as a function.
// Package p contains a Google Cloud Storage Cloud Function.
package p
import (
"context"
"log"
"os/exec"
)
// GCSEvent is the payload of a GCS event. Please refer to the docs for
// additional information regarding GCS events.
type GCSEvent struct {
Bucket string `json:"bucket"`
Name string `json:"name"`
}
// HelloGCS prints a message when a file is changed in a Cloud Storage bucket.
func HelloGCS(ctx context.Context, e GCSEvent) error {
log.Printf("Processing file: %s", e.Name)
path, err := exec.LookPath("gs")
if err != nil {
log.Fatalf("error: %v", err)
}
log.Printf("ghostscript installed at %s\n", path)
return nil
}
cc...@gmail.com <cc...@gmail.com> #11
Ghostscript is available in the Go system packages, but not in the Python. Is it possible to add Ghostscript to the Python system packages?
We use a function to parse a pdf file that is triggered when a partner uploads the file to a particular google storage bucket -- We are using the Python package `camelot` (reads pdf tables) which depends on ghostscript.
We use a function to parse a pdf file that is triggered when a partner uploads the file to a particular google storage bucket -- We are using the Python package `camelot` (reads pdf tables) which depends on ghostscript.
sl...@zengers.de <sl...@zengers.de> #12
I just check the nodejs environment of functions and it also has Ghostscript already installed in version 9.26.
de...@gmail.com <de...@gmail.com> #13
Ghostscript is left out of the latest (Ubuntu 22.04) runtime base image. I can't upgrade to Node 18 until the Ubuntu 22.04 image includes ghostscript.
It was included in the previous runtime base image (Ubuntu 18.04). Please add it to the latest package.
Thank you!
It was included in the previous runtime base image (Ubuntu 18.04). Please add it to the latest package.
Thank you!
wi...@musedecks.com <wi...@musedecks.com> #14
Is this controversial? Will you please update on this? What is holding it up?
ghostscript is a basic package that should be included by default and has been on previous images.
ghostscript is a basic package that should be included by default and has been on previous images.
jo...@jobbatical.com <jo...@jobbatical.com> #15
I have a few cloud functions that use Ghostscript for PDF compression. All of them are working fine in the Node16 runtime but I'm not able to upgrade to the latest Node20 because ghostscript is not available yet in Ubuntu 22.04.
It would be good if you could make the package available on the latest Ubuntu image. Thanks.
It would be good if you could make the package available on the latest Ubuntu image. Thanks.
ba...@getgc.ai <ba...@getgc.ai> #16
Same request here. Can't use it to process PDFs and need it using node18.
la...@gmail.com <la...@gmail.com> #17
It would be greatly appreciated if this issue could be resolved. It completely prevents any handling of PDFs inside cloud functions. Thank you.
Description
I would like to use Google Cloud Functions to create thumbnails of PDFs. This can be done using convert from ImageMagick, which also can be used to create thumbnail from regular images. However, it seems like the ghostscript package is not available, and therefore I'm not able to create the thumbnails.
Will you consider adding this package?
The issue is also described (by another user) in this stack overflow post: