Convert svg animation to apng sequence - svg

Is there any way to do this?
I tried magick -background none in.svg out.png with ImageMagick 7.1.0-61, it removed the transparency and only kept the first frame of animation.

Related

Convert svg to png imagemagick black border around path

I am on macOs Mojave 10.14.3 (18D109)
My imagemagick details (installed with brew)
convert -version
Version: ImageMagick 7.0.8-35 Q16 x86_64 2019-03-25 https://imagemagick.org
Copyright: © 1999-2019 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC HDRI Modules OpenMP
Delegates (built-in): bzlib freetype heic jng jp2 jpeg lcms ltdl lzma openexr png tiff webp xml zlib
I have a basic svg (adopted from W3Schools example):
<?xml version="1.0"?>
<svg xmlns="http://www.w3.org/2000/svg" width="52" height="52" viewBox="0 0 52 52">
<path fill="#fff" d="M22 0 L33 52 L12 42 Z">
</path>
</svg>
That looks like this (Gapplin):
Now when i convert it to png like so:
convert -background none -density 9600 -resize 32x "myFile.svg" "myFile.png"
i get a perfect image, except it has a black border:
I tried just about every variation of command options for imagemagick that had to do with color or black and sadly it never comes out with what i want - transparent background, solid white path (as described by fill on the SVG).
Any suggestions?
In ImageMagick, SVG files can be rendered by any one of three tools: Imagemagick's MSVG/XML, RSVG delegate and Inkscape, usually in order of increasing accuracy.
I just tried the following command with Inkscape 0.92.4 and it comes out totally white. If Inkscape is installed Imagemagick will use it automatically. But in this case it is not working well with that file.
magick test.svg test2.png
But it works fine if I added -background none
magick -background none test.svg test2.png
I get a white triangle on a transparent background.
or if I want a black background
magick -background black test.svg test2.png
When I force Imagemagick to use MSVG, I get a white triangle with a simple black outline on a white background. So again not correct by your comments.
magick MSVG:test.svg test2.png
If I add -background none, then I get white triangle with black outline on a transparent background.
magick -background none MSVG:test.svg test2.png
But if I just want a black background, then
magick -background black MSVG:test.svg test2.png
I then get a white triangle on a black background. But I suspect the white triangle is slightly smaller from the black border it had.
When I force the use of RSVG 2.44.12 by creating an entry in the delegates.xml file, I get a white triangle on a transparent background, which I assume is what you want.
magick RSVG:test.svg test3.png
or
magick -background none RSVG:test.svg test3.png
You can tell if your Imagemagick has MSVG/XML or RSVG by
magick -list format
and look for the line starting with SVG. At the end of that line it will either say XML or RSVG. You cannot tell about Inkscape with this method.
Check to see what you are using for your SVG renderer and its version. Also the version of libpng. Mine is 1.6.36
From your version information, I do not see rsvp listed. So I assume you are using MSVG, but it could be Inkscape if you have installed that on your system.
I am on Mac OSX Sierra with Imagemagick 7.0.8.35 Q16.
I had this problem converting SVG to PNG with PHP - black lines around the path. I install Inkscape on the server that was processing the image and that seemed to fix it, no code change necessary.
In my case, switching converters did not help.
Thus I experimented with the SVG itself.
And adding stroke-opacity="0" to the svg (or the individual paths if you dont want everything to have no outline) helped.
I assume that there is some default for stroke values that the converters set that makes them visible and this defines them as invisible on the svg level

ImageMagic renders image with black background

I'm converting pdf files to images with ImageMagic, everything is ok until I use -resize option, then I get image with black background. I use this command:
convert -density 400 image.pdf -resize 25% image.png
I need to use -resize option otherwise I get really large image. Is there any other option which I can use to resize image or is there option to set background in white.
That's not a Ghostscript command, You will need to find out what convert is sending to Ghostscript. As it stands I can't even be sure that your problem is with Ghostscript ,since it could easily be something that convert is doing.
Solved it by removing alpha from image, it seems imagemagic tries to apply some opacity but since jpeg doesn't allow transperency result was black background. So I found example on imagemagic website and it helped me:
convert a.pdf -background skyblue -alpha remove -alpha off a_remove.jpg

Using ImageMagick to remove all color except black in an image?

The situation is : I have many images of documents from scanning. I want to keep the document's main content - which is printed in color black (a small range of colors around #000000). But, you know, the documents are always full of colors : stamp, background, decorations, logos...etc.
I just want to keep the TEXTS ONLY which were printed in the color black.
I've tried with ImageMagick and this command so far:
convert X.png -matte (+clone -fuzz 20% -transparent "#000000") -compose DstOut -composite X1.png
But the result was not as expected , the text was very damaged that I cannot read.
Someone suggested me to increase the fuzz to 70%:
convert X.png -matte (+clone -fuzz 70% -transparent "#000000") -compose DstOut -composite X1.png
Then the text appeared to be more readable, but the other colors kept remaining too.
Can you please show me a better solution for my situation? Every suggestion would be highly appreciated!
To match all colors except black you can use +opaque "#000000".
In order to include a little range around #000000 you can try different percentages with the fuzz operator:
convert input.png -fill white -fuzz 10% +opaque "#000000" result.png
Tested with ImageMagick 6.6.0-1 on Windows
I stumbled upon this question while looking for an answer to this question. I found a couple imagemagick forum posts that helped. Here is what I came up with:
convert input.gif -matte \( +clone -fuzz 1 -transparent black \) -compose DstOut -composite ~/Desktop/output.png
Forum post: ImageMagick: Removing all but one color
You should try the level command:
convert test.png -level 25%,75% test_level.png

How to convert SVG image to 32-bit RGBA with ImageMagick?

How to convert SVG image to 32-bit RGBA with ImageMagick?
Background must be transparent.
Simply try this command:
convert in.svg -transparent white out.png
(Assuming the original SVG uses a transparent or white background. Otherwise, if SVG background is red or blue or '#235689': use -transparent red, -transparent blue or -transparent '#235689'....)
If your version of ImageMagick doesn't do it right, check if convert -list configure | grep svg shows rsvg output in the DELEGATES and CONFIGURE lines.
I found that setting background to none worked for me:
convert -background none in.svg out.png

GraphiccMagick, how to remove alpha channel

Tell me please, how to convert PNG to JNG without alpha channel in GraphicsMagick?
JPG? JPG has no alpha channel, after you convert PNG to JPG, alpha channel will be remove automatically.
If you are trying to remove alpha from png you can use convert (imagemagick):
convert in.png -background black -alpha remove -alpha off -resize 1024x1024 out.png

Resources