Quantcast
Channel: magick Discussions Rss Feed
Viewing all 3693 articles
Browse latest View live

New Post: svg to png - transparent background

$
0
0
I have an svg. I want to create a png with c#.
It works fine but the only problem is transparency. The created png has always a white background.
If I open the original svg on a browser or in inkescape i see a transparent background.
Don't know if i must explicit transparency on svg source(in a specific way) or if i must use a particolar option in Magick.net library.

Thanks in advance for any tip.

This is my function:
private Stream convertSVG(Stream svgAsStream)
            {
                Stream convertedImage = new MemoryStream();

                using (MagickImage MGKimage = new MagickImage())
                {
                    //MGKimage.ColorAlpha(new MagickColor(255, 255, 255)); //alpha on white
                    //MGKimage.Alpha(AlphaOption.Background);

                    //set input image proprieties: SVG
                    MagickReadSettings mrs = new MagickReadSettings();
                    mrs.Format = MagickFormat.Svg;
                    mrs.ColorSpace = ColorSpace.Transparent;
                    
                    MGKimage.Read(svgAsStream, mrs);

                    //set output image proprieties: PNG
                    MGKimage.Format = MagickFormat.Png;
                    MGKimage.BackgroundColor = new MagickColor(System.Drawing.Color.Transparent);

                    MGKimage.Write(convertedImage);
                }

                return convertedImage;
            }

New Post: svg to png - transparent background

$
0
0
The internal support for SVG is not that great in ImageMagick. You can however force Magick.NET to use Inkscape instead. You can use the delegates.xml file for this. I don't have time to post an example now so feel free to figure this out yourself. Setting the ColorSpace to ColorSpace.Transparent will not solve your problem. You can use MagickColor.Transparent for a transparent color.

New Post: svg to png - transparent background

$
0
0
Thanks for the reply.
I use the above code on an asp.net page, on the web server, I don't have Inkescape installed.

Is there any way to "translate" the following switch commands of imagemagick to magick.net library?

--THIS--

convert +antialias -background transparent media-playback-start.svg media-playback-start.png;

found that command on this blog.


-- OR THIS--

convert -background none folder.svg folder.png

found that command on this blog

New Post: svg to png - transparent background

$
0
0
-background is the BackgroundColor property of MagickImage. This might work:
MGKimage.BackgroundColor = MagickColor.Transparent;
MGKimage.Read(svgAsStream, mrs);
If this doesn't work I might have to add a BackgroundColor property to MagickReadSettings. Can you post a link to your pdf or contact me through codeplex if this doesn't work?

New Post: svg to png - transparent background

$
0
0
Alredy tryed this with no luck(as i write above):

MGKimage.BackgroundColor = new MagickColor(System.Drawing.Color.Transparent);

I think is the same as you suggest(or not?).
With "Can you post a link to your pdf" did you mean "your svg"?

New Post: svg to png - transparent background

$
0
0
You should try setting the BackgroundColor before reading the image. And yes I mean your svg.

New Post: svg to png - transparent background

$
0
0
I'll do the test as soon as possible, if it fails, i'll post the svg, thanks.

New Post: Generate an image based on character and font

$
0
0
You should use the drawable classes to draw text on an image:
using (MagickImage image = new MagickImage(Color.Black, 100, 100))
{
  DrawableFont font = new DrawableFont("PMingLiu");
  DrawablePointSize pointSize = new DrawablePointSize(20);
  DrawableStrokeColor strokeColor = new DrawableStrokeColor(Color.White);
  DrawableText text = new DrawableText("YOUR TEXT");
 
  image.Draw(font, pointSize, strokeColor, text);
}

New Post: svg to png - transparent background

$
0
0
It works! Thanks a lot dlemstra! :)

New Post: Is there any way to update all pixels at once using a byte array?

$
0
0
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.

New Post: Generate an image based on character and font

$
0
0
Thank you so much dlemstra! The picture could be generated with the property you listed. Is it also possible to import a system ttc font to DrawableFont apart from new DrawableFont("PMingLiu"); ?

New Post: Generate an image based on character and font

$
0
0
You can specify another font like this: new DrawableFont("Arial"). Or are you using a font that you did not register in windows?

New Post: Generate an image based on character and font

$
0
0
The font "Batang" is already installed under Fonts in control panel, but somehow still get "Magick: unable to read font `Batang' @ warning/annotate.c/RenderType/871".

New Post: Generate an image based on character and font

$
0
0
You can see that fonts that are available using the command line version of ImageMagick. Try the following:
convert -list font

New Post: Resize image to a different aspect ratio

$
0
0
I'm trying to resize an image but it is always respecting the ratio. Is there any way to resize an image to a different ratio?

Image current size: 800 x 600
Target size: 1024 x 600

magickImage.Resize(1024, 600);

Result: 1024 x 768

New Post: Resize image to a different aspect ratio

$
0
0
You can use the following:
MagickGeometry geometry = new MagickGeometry(1024, 600);
geometry.Aspect = true; // Yes this looks confusing, I should rename this.
magickImage.Resize(geometry);

magickImage.Resize(new MagickGeometry("1024x600!"));

New Post: Resize image to a different aspect ratio

$
0
0
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.

New Post: IPTC

$
0
0
Hello,

I'm in need to write IPTC info to a given image.
So far I can read the IPTC of the image.

Can anyone give a hint?

Thanks in advance.

New Post: IPTC

$
0
0
At this moment you need to have knowledge on how the IPTC profile is stored byte wise. You can set the profile like this:
using(MagickImage image = new MagickImage("YourImage.png"))
{
  byte[] data = YourCreateIptcProfileMethod();
  IptcProfile profile = new IptcProfile(data);
  image.AddProfile(data);
}
I could add support for writing an IPTC profile.

New Post: IPTC

$
0
0
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Viewing all 3693 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>