Imagemagik Issue creating a bitmap image with a layered SVG - svg

We have an issue with creating an image with an SVG that we can’t seem to solve. We would greatly appreciate any help to get this sorted or learn if this is a bug in Imagemagik which has no solution.
So we are creating a bitmap image by layering an SVG on top of a jpg image. When we do this what happens is that the SVG gets distorted or displaced from the centre as it should be. When we create an image by layering a png on top of a jpg everything works correctly. It is just when using an SVG image that the problem happens.
magick -size 654x508 canvas:#ff0000 ( original.jpg -thumbnail 938x508 -page -142+0 ) ( -background transparent -density 300 original.svg -thumbnail 536x79! -page +59+214 ) -layers flatten
We are using ImageMagick 7.1.0-47 Q16-HDRI x86_64 d91623c12:20220827
Features: Cipher DPC HDRI OpenMP(4.5)
Delegates (built-in): bzlib djvu fontconfig freetype jbig jng jpeg lcms lqr lzma openexr png raqm tiff webp x xml zlib
Compiler: gcc (7.5)

Did you click Export PNG Image or shortcut Shift+Ctrl+E and export the file format as .png? And make sure your image is inside the Document Properties - Page you provided.

Related

How to convert PNG/JPEG images to svg with ImageMagick?

It seems that with potrace installed, I can just run magick convert x.png x.svg or magick convert x.jpg x.svg.However this just returns a deformed image in black and white, and I need the svg image to be in full color. Additionally, I really need the file format to be svg because svg images are small and portable, and I don't have a lot of disk space on my server.Does anyone know how to convert png/jpeg to svg while retaining color?

How to convert an SVG file into a JPEG?

I'm using SF Symbols in buttons for a Mac App, but since I'm trying to customize their colors to better fit the theme. I'm thinking of converting the vector based file into a JPEG image.
rsvg can convert SVG to PNG.
PNG is lossless, while JPEG distorts image pixels, which also affects colors.
brew install librsvg
rsvg-convert in.svg out.png

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

Transparent Image Using GraphicsMagick

I am using GraphicsMagick and I am trying to create a 200px by 200px transparent TIF image. However, the resulting image, when opened in Photoshop, has a black background. If I use ImageMagick, it works.
The following ImageMagick command creates a transparent image (when opened in Photoshop)
magick convert -size 200x200 xc:transparent transparent1.tif
But, the same GraphicsMagic command creates a black image (when opened in Photoshop)
gm convert -size 200x200 xc:transparent transparent2.tif
I am at a loss. I would like to use GraphicsMagic because the Node API has streaming support and provides some other nice features.

How are 16x16 PNG icons rendered from original SVG files?

When I open a Tango SVG icon file and export it (using Inkscape) to a 16x16 png, I get a rather blurry image. Instead, the "official" 16x16 render is extremely sharp. How did they do it? Did they pixel-paint the icons at small resolutions?
Compare and for an example.
Gimp has a better scaling algorithm than Inkscape.
I Export from inkscape to 256x256 pixels and then scale to 16x16 in Gimp.

Resources