-
-
Notifications
You must be signed in to change notification settings - Fork 20
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
Convert to other image formats #70
Comments
Victor is exclusively an SVG generator. $ rsvg-convert in.svg > out.png
# or with specific output width of 1000 pixels
$ rsvg-convert -w 1000 in.svg > out.png |
@DannyBen Thanks for your help. I end up using def to_png
tmp_file_name = SecureRandom.hex(4)
tmp_svg_path = Rails.root.join("tmp", "#{tmp_file_name}.svg")
tmp_png_path = Rails.root.join("tmp", "#{tmp_file_name}.png")
save(tmp_svg_path.to_s)
ImageProcessing::MiniMagick
.source(tmp_svg_path.to_s)
.custom { |magick| magick.alpha("remove") }
.convert("png")
.call(destination: tmp_png_path.to_s)
File.read(tmp_png_path)
ensure
File.delete(tmp_svg_path) if tmp_svg_path && File.exist?(tmp_svg_path)
File.delete(tmp_png_path) if tmp_png_path && File.exist?(tmp_png_path)
end |
Yup. That is also an option. Keep in mind that ImageMagick for me sometimes converted even simple SVGs incorrectly. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
It may not have much to do with the gem, but some good idea to be able to have other formats besides svg, such as jpg or png.
BTW: Thank you very much for the gem
The text was updated successfully, but these errors were encountered: