How to use Imagemagick?

based in the table at https://developers.cloudflare.com/pages/platform/language-support-and-tools/, Imagemagick 6.7.7 is included in v1 build system I have to questions: 1- how to use it? Because I tried using magick -version and errors 2- is it available in v2 build system? The table at the previous link show it's not included, but maybe is just showing some of the tools
9 Replies
James
James16mo ago
cc @johndotawesome
JohnDotAwesome
JohnDotAwesome16mo ago
I'd be interested in giving v2 imagemagick support. How are you utilizing it in your build? I'm unsure how folks have been using it in v1, but I know it's installed
alex.plescan
alex.plescan16mo ago
Hey @johndotawesome - thanks for looking into this! I'm also keen to use ImageMagick on v2. I think it's the only thing stopping me from being able to migrate my Jekyll site over from v1. I use the jekyll_picture_tag ruby gem at build-time to create variants of my blog's images in different formats and sizes. Under the hood, that gem requires either ImageMagick or MiniMagick to be installed. Let me know if you want more details, I'm happy to share deployment logs with you, etc.
JohnDotAwesome
JohnDotAwesome16mo ago
Thanks for the info @alex.plescan ! Since v2 uses asdf, you could install imagemagick in your build by adding the following environment variable to your project:
UNSTABLE_PRE_BUILD: "asdf plugin add imagemagick && asdf install imagemagick 7.1.1-15 && asdf global imagemagick 7.1.1-15"
UNSTABLE_PRE_BUILD: "asdf plugin add imagemagick && asdf install imagemagick 7.1.1-15 && asdf global imagemagick 7.1.1-15"
The alternative to the pre_build env var is to prefix your build command with that^ or add it to a build script The other option is to add a .tool-versions file with the contents:
imagemagick 7.1.1-15
imagemagick 7.1.1-15
Or whatever version you wanted
alex.plescan
alex.plescan16mo ago
Hey @johndotawesome - thanks for that. I use asdf for local development so it's great to know it aligns with what the Cloudflare builder uses too! Looks like the imagemagick asdf plugin isn't included though. After declaring it my .tool-versions, my build fails on the "Building application" step, with:
08:31:10.135 Success: Finished cloning repository files
08:31:10.817 Found a .tool-versions file. Installing dependencies.
08:31:11.404 imagemagick plugin is not installed
08:31:10.135 Success: Finished cloning repository files
08:31:10.817 Found a .tool-versions file. Installing dependencies.
08:31:11.404 imagemagick plugin is not installed
JohnDotAwesome
JohnDotAwesome16mo ago
huhmph that's weird. I suppose asdf requires you to preinstall plugins listed in the .tool-version file. In that case, you'll still need to run asdf plugin add imagemagick in your UNSTABLE_PRE_BUILD` COMMAND
alex.plescan
alex.plescan16mo ago
Aaah I missed your mention of setting the UNSTABLE_PRE_BUILD env var. I just did that and of course it immediately started working! A thought is that it may be useful for the imagemagick plugin to be preinstalled. It took ~8 minutes between running the pre-build command and my build continuing on - smells like maybe imagemagick was being built from source?
18:24:53.237 Running user-defined pre-build script: asdf plugin add imagemagick && asdf install imagemagick 7.1.1-15 && asdf global imagemagick 7.1.1-15
...
18:33:15.490 Found a .tool-versions file. Installing dependencies.
18:24:53.237 Running user-defined pre-build script: asdf plugin add imagemagick && asdf install imagemagick 7.1.1-15 && asdf global imagemagick 7.1.1-15
...
18:33:15.490 Found a .tool-versions file. Installing dependencies.
Anyway - now my site's building with the V2 build system! Thanks for your help and for your work on Pages 😁 🧡
JohnDotAwesome
JohnDotAwesome16mo ago
Yeah very much likely being built from source. I agree. We should probably include it. Although, it seems that more and more static site builders are relying on their own prepackaged binaries for image processing (like in the case of node.js/sharp/vips) We're trying to keep the v2 build system slimmer than v1 so that it's easier for us to maintain/update over time. That being said! I do think imagemagick deserves to be pre-installed. I'll talk to our team about it 🙂
Stavros
Stavros7mo ago
Hey, I'm trying to use ImageMagick but the above doesn't work, the build just freezes. What could be up? It turns out that this works, but just the installation step takes 6 minutes to run. The workflow generally takes a few seconds, but now it's 6 minutes just because of the installation @JohnDotAwesome I haven't managed to find any other way to install this
Want results from more Discord servers?
Add your server