11-13-2024, 10:01 AM (This post was last modified: 11-13-2024, 10:10 AM by Ofnuts.)
Good for you, but it would have been much simpler and faster with ImageMagick in a shell script. (imagemagick in your repo, + potrace if you haven't got it already)
Code:
convert input.svg -resize WIDTHxHEIGHT output.png
And if you stick with Gimp, INTERPOLATION-NOHALO is a better option, the only thing "Cubic" has for itself is a low CPU usage, but on modern PCs you won't notice the difference.
I have a preference for GIMP because after some tests with imagemagik and inkscape, the quality of the converted/resized images seems to be better with GIMP.
(11-13-2024, 12:46 PM)Alpha504 Wrote: Thanks for the advice about INTERPOLATION-NOHALO.
I have a preference for GIMP because after some tests with imagemagik and inkscape, the quality of the converted/resized images seems to be better with GIMP.
... and you use Cubic?
In Imagemagick there is an -interpolate option (to be used with -scale) to define the interpolation algorithm used.
You'll see plenty of bad advice over interpolation algorithms on the web, because what works for some images won't work on others.
The interpolation algorithms have a frequency response (a bit like low-pass audio filters). But the high frequency response is not a simple decreasing curve, the response curves have bumps on high frequencies (strong bumps for simple algorithms like linear and cubic). So when the image that you scale has spatial components with frequencies that fall on these bumps they produce artefacts: roof and floor tiles, but also edges of oblique lines in CGI (so, typically, SVG renders). Using a different algorithm can put the frequency response bumps elsewhere so they no longer are a problem with the current image (but that doesn't make that new algorithm universal solution).
The general solution is to apply a good low-pass filter to the image before scaling it down, so that the image has no spatial frequency components in the bumps area. This good low pass filter is called "Gaussian blur". You just blur the image enough to blur out the details that will anyway be invisible in the scaled down output. And IM has a -blur operator that you can insert before the -scale.
(11-13-2024, 01:27 PM)Ofnuts Wrote: ... and you use Cubic?
In Imagemagick there is an -interpolate option (to be used with -scale) to define the interpolation algorithm used.
With Imagemagick, I didn't use the interpolate option, I'm very new to image manipulation softwares. But for my manual tests with GIMP I used Cubic.
From Imagemagik, I only used "mogrify" with "resize" and "format" options, and the SVG to PNG convertion was very bad, very different from the original image.
(11-13-2024, 01:27 PM)Ofnuts Wrote: ... and you use Cubic?
In Imagemagick there is an -interpolate option (to be used with -scale) to define the interpolation algorithm used.
With Imagemagick, I didn't use the interpolate option, I'm very new to image manipulation softwares. But for my manual tests with GIMP I used Cubic.
From Imagemagik, I only used "mogrify" with "resize" and "format" options, and the SVG to PNG convertion was very bad, very different from the original image.
I did a couple of tests before posting and things are fine, scaling down 2X or even scaling up 3X. Can you post an example?
(11-13-2024, 04:06 PM)Ofnuts Wrote: I did a couple of tests before posting and things are fine, scaling down 2X or even scaling up 3X. Can you post an example?
I have attached a screenshot of my experiments, and the original SVG file of size 96x96. This file is a modified image I took from MATE Desktop environment "mate" theme. I have only modified the colors, replacing blue colors by green ones.
11-15-2024, 11:46 PM (This post was last modified: 11-15-2024, 11:48 PM by Ofnuts.)
You are starting from SVGs. SVG files, being vector graphics, can be scaled losslessly. If you convert them to raster first and scale next. the cale is don on ratser and not correct. A good CLI tool to scale SVG as vector and only then output the result to PNG is rsvg-convert
Thanks for the information. For converting a lot of files, it will probably be faster than the shell script I wrote that do multiple call to my gimp script.