Skip to content

Instantly share code, notes, and snippets.

@NielsKSchjoedt
Last active August 7, 2024 11:18
Show Gist options
  • Save NielsKSchjoedt/ad9d0f0bdaf212f106041a2034f00da9 to your computer and use it in GitHub Desktop.
Save NielsKSchjoedt/ad9d0f0bdaf212f106041a2034f00da9 to your computer and use it in GitHub Desktop.
Reproduce issue with imagemagick
# Setup container
docker run -it ubuntu:22.04
apt update
apt -y install git gcc make autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm6 libgdbm-dev libpq-dev libmagickwand-dev libcurl4 libcurl4-openssl-dev iputils-ping nano sudo imagemagick wget curl
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
~/.rbenv/bin/rbenv init
source ~/.bashrc
git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build
rbenv install 3.2.2
rbenv global 3.2.2
# download a png:
wget https://toppng.com/uploads/preview/cute-rainbow-svg-cutting-files-rainbow-svg-cut-file-cute-rainbow-clip-art-1156289172309tnqyglqg.png

#install rmagick
gem install rmagick 

# Run console
irb

Now you can run the following code in the console to produce the error

# Run ruby
require "rmagick"
require "rvg/rvg"

# Load the PNG file
png_image = Magick::Image.read("/cute-rainbow-svg-cutting-files-rainbow-svg-cut-file-cute-rainbow-clip-art-1156289172309tnqyglqg.png").first

# Create an RVG image
rvg = Magick::RVG.new(png_image.columns, png_image.rows) do |canvas|
  canvas.background_fill = "white"
  canvas.image(png_image)
end

# Render the RVG to an Image
rvg_image = rvg.draw
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment