Page 1 of 1

resize svg without antialiasing: +antialias not working

Posted: 2008-05-02T08:23:49-07:00
by coregis
Problem solved from an answer in another post today:

To resize without antialiasing I did:

convert img.svg -filter point -resize XxY! img.png

My problem seemed to be that the filter must come before the resize.

Thanks!

Re: resize svg without antialiasing: +antialias not working

Posted: 2008-05-26T21:13:20-07:00
by anthony
Note that SVG is a vector image format. Which are freely scalable. SVG -> Scalable Vector Graphic!

You can adjust the image size using -density. For anti-aliasing add +antialias BEFORE reading the SVG.

Code: Select all

convert +antialias -density 144 image.svg  image.png

Re: resize svg without antialiasing: +antialias not working

Posted: 2008-07-10T12:14:57-07:00
by landon.silla
I (think I) have the same problem as the original poster. I have a bunch of svg's that i want to make very big. Since they are svg's they should be able to scale to any size without loss of quality. I have been running:

convert -resize 500% /var/web/temp/8742.svg /var/web/temp/6194.png

and that gives me this ugly image:
http://archive.cyark.org/temp/6194.png

it would appear that it is creating a raster image of size 100% and then resizing the raster image to 500%. resizing a raster image is no good. how do i get convert to create a very large png without loss?

i've messed around with scale and filter and that seems to do nothing. also, density doesn't seem to have any effect at all.

fyi, if you want, you can get my svg at:
http://archive.cyark.org/temp/8742.svg

Re: resize svg without antialiasing: +antialias not working

Posted: 2008-07-10T22:22:48-07:00
by anthony
See my original reply!!!! You are making the same mistake!

Use -density to change the pixel size of the image, and thus the number of pixels in the image!!!

-resize is for raster images (which is usually what IM is used for) NOT for vector images.

Re: resize svg without antialiasing: +antialias not working

Posted: 2008-07-11T11:23:48-07:00
by landon.silla
ok, now we are getting somewhere. i think previously i was putting the -density option after the image file and it wasn't working correctly. anyway, now i'm having difficulty understanding what exactly density does. i have run these commands:

convert /var/web/temp/8742.svg /var/web/temp/0.png
convert -density 100 /var/web/temp/8742.svg /var/web/temp/1.png
convert -density 200 /var/web/temp/8742.svg /var/web/temp/2.png
convert -density 300 /var/web/temp/8742.svg /var/web/temp/3.png
convert -density 400 /var/web/temp/8742.svg /var/web/temp/4.png

which created these files:
http://archive.cyark.org/temp/0.png
http://archive.cyark.org/temp/1.png
http://archive.cyark.org/temp/2.png
http://archive.cyark.org/temp/3.png
http://archive.cyark.org/temp/4.png

The widths of these images are 612, 849, 1699, 2550, and 3399 respectively. I've read the documentation on this option but i can't seem to make sense of it. it says that if you give one integer value, it will be the new width of the output (and presumably the height will scale accordingly). the other obvious option would be a scaling factor, meaning 200 would mean it would double from it's original size. Per the widths of the png's i created, both of these options are obviously not true for my case.

Basically, I want to take the svg and make a series of png that double in size (for example, 500x1000, 1000x2000, 2000,4000 etc).

So bottom line, how can i convert this svg into a png of any width i choose, say, 1000px (and have the height scale accordingly)?

Re: resize svg without antialiasing: +antialias not working

Posted: 2008-07-11T14:41:19-07:00
by el_supremo
In the case of the image you converted, density is specified in dpi (or you can force the units to be in pixels per centimetre).
When you don't specify a density, IM uses a default of 72 dpi.

So, your first command used 72dpi. The second command used 100 dpi etc.
Your image was 8.5 inches wide which translates into an image which is 612 pixels wide at 72 dpi (0.png), 849 pixels at 100 dpi (presumably a rounding error there?) etc.

If you want an image 1000 pixels wide, use a density of 1000/8.5 = 117.65 => 118 dpi

Pete

Re: resize svg without antialiasing: +antialias not working

Posted: 2008-07-13T18:55:31-07:00
by anthony
el_supremo wrote:If you want an image 1000 pixels wide, use a density of 1000/8.5 = 117.65 => 118 dpi
Many arguments in IM uses floating point numbers, I am not certain about density, but it is probably a floating point number too. Try it and see, then let us know.

Re: resize svg without antialiasing: +antialias not working

Posted: 2008-07-13T19:12:59-07:00
by el_supremo
Indeed it does Anthony. I tried converting a PDF with densities of 2 and 2.5 and it produced different image sizes.

Pete