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!
resize svg without antialiasing: +antialias not working
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: resize svg without antialiasing: +antialias not working
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.
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
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: resize svg without antialiasing: +antialias not working
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
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
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: resize svg without antialiasing: +antialias not working
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.
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.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: resize svg without antialiasing: +antialias not working
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)?
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)?
-
- Posts: 1015
- Joined: 2005-03-21T21:16:57-07:00
Re: resize svg without antialiasing: +antialias not working
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
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
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: resize svg without antialiasing: +antialias not working
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.el_supremo wrote:If you want an image 1000 pixels wide, use a density of 1000/8.5 = 117.65 => 118 dpi
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
-
- Posts: 1015
- Joined: 2005-03-21T21:16:57-07:00
Re: resize svg without antialiasing: +antialias not working
Indeed it does Anthony. I tried converting a PDF with densities of 2 and 2.5 and it produced different image sizes.
Pete
Pete