Downsampled image has lower quality than expected

Discussions on NConvert - the command line tool for image conversion and manipulation

Moderators: XnTriq, xnview

Post Reply
stickynoteme
Posts: 4
Joined: Mon Jan 11, 2021 7:18 pm

Downsampled image has lower quality than expected

Post by stickynoteme »

Hi, I am use to using Faststone Image resizer, but need to do resizing with bat files which it doesn't support.

When using nconvert however the image quality is substantially lower.

I've included a source attachment and the goal is to reduce it to 333px 333px [odd number's but that's just because this is a panel being taken out of context of a comic to avoid overly large images on the BBS]

Any help would be greatly appreciated.
Attachments
compare.jpg
source.jpg
source.jpg (80.47 KiB) Viewed 350 times
cday
XnThusiast
Posts: 2658
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: downsample quality

Post by cday »

Could you post the code you are using?

I don't have any immediate idea of what could be causing the quality problem, unless it is possibly simply the use of different JPEG quality values, but you do seem to be using different Lanczcos versions unless they are actually just different names for the same resampling method?

If you wish to experiment with different settings, you could possibly do it more easily using XnView MP GUI software, where you could change settings and see the result immediately... When I downloaded your source file and had a very quick look, the unsaved result seemed similar to your NConvert output.

Edit:

If you are using a bat file because you need do batch convert files, you might also consider the possibility of using XnConvert (or XnView MP Batch convert).

And if you wish to try different resampling options, and also possibly other options such as applying a filter to the resized image, you can very easily preview the effect of different actions using the preview displayed in XnConvert.
stickynoteme
Posts: 4
Joined: Mon Jan 11, 2021 7:18 pm

Re: Downsampled image has lower quality than expected

Post by stickynoteme »

yes they are different, as I can't seem to find Lanczcos3 in nconvert at least not using the -help command or readme files which seems to be the only real documentation.

nconvert -out jpeg -ratio -rtype lanczos -resize 700 0 -o %%_SWH_W700_nuttytales.net.jpg "%~1"\


I don't need to do batches I need a single image to be automatically renaming and converted to different sizes for each new comic for all the different sties.

So I need to take a source file and than have it resized to about 10 different sizes all with unique names, which is why I want to use a .bat file to do it.
Last edited by stickynoteme on Mon Jan 11, 2021 9:56 pm, edited 1 time in total.
stickynoteme
Posts: 4
Joined: Mon Jan 11, 2021 7:18 pm

Re: Downsampled image has lower quality than expected

Post by stickynoteme »

I just tired using XnConvert and it produced better quality than nConvert using the same settings?
Attachments
compare.jpg
settings.jpg
cday
XnThusiast
Posts: 2658
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Downsampled image has lower quality than expected

Post by cday »

'The default JPEG quality setting if the -q setting isn't used is 85 I believe, so that isn't likely to be a factor.

I can only suggest at the moment that if necessary you look for a workaround, the preview facility in NConvert (or XnView MP batch convert) provides a very convenient way to quickly test different combinations of loaded actions... I have sometimes seen a filter such as 'Enhance focus' or 'Soften' enhance the subjective appearance of images with small pixel dimensions.

Pierre do you know anything about Lanczos3 ?
stickynoteme
Posts: 4
Joined: Mon Jan 11, 2021 7:18 pm

Re: Downsampled image has lower quality than expected

Post by stickynoteme »

This turned out to be the -q flag. I didn't realize that faststone defaulted to a higher than nConvert setting them to the same here produced roughly equal quality.

Thank you for the help.
cday
XnThusiast
Posts: 2658
Joined: Sun Apr 29, 2012 9:45 am
Location: Cheltenham, U.K.

Re: Downsampled image has lower quality than expected

Post by cday »

stickynoteme wrote: Mon Jan 11, 2021 10:31 pm This turned out to be the -q flag. I didn't realize that faststone defaulted to a higher than nConvert setting them to the same here produced roughly equal quality.
I'm surprised, as normally there wouldn't much if any visible difference in image quality been 85 and even 100, just a fairly large difference in filesize, but you are working with images with small pixel dimensions.

On the assumption that Lanczos3 is better than Lanczos, I was going to suggest that you try finding the Lanczos3 plug-in in Faststone, and then try using it in NConvert, suitably renamed and with the NConvert plug-in disabled by, for example, renaming it. That would require that both plug-ins are the same bit depth, NConvert is available in either 32-bit or 64-bit versions if needed. Or maybe it can be downloaded directly?

One reference from a quick search: Lanczos3 algorithm as a way to produce better image downscaling.
User avatar
XnTriq
Moderator & Librarian
Posts: 5634
Joined: Sun Sep 25, 2005 3:00 am
Location: Ref Desk

Re: Downsampled image has lower quality than expected

Post by XnTriq »

xnview wrote: Tue Sep 27, 2005 2:04 pmLanczos3 is available in XnView/NConvert, so i can add it easily in GFL SDK & GFLAx.
nconvert.exe -help wrote:

Code: Select all

-rtype            : Type of resampling
    quick    : Quick resize
    linear   : Bi-linear (linear)
    hermite  : Hermite
    gaussian : Gaussian
    bell     : Bell
    bspline  : Bspline
    mitchell : Mitchell
    lanczos  : Lanczos

Code: Select all

-sharpen percent  : Sharpen (1...100)

Code: Select all

-unsharp radius amount threshold : Unsharp mask
XnTriq (“bicubic resize ?”) wrote: Sun Feb 10, 2013 11:00 pm
Algorithms currently available in XnView v1.9 (Image » Resize):
  1. Nearest Neighbour
  2. Bilinear
  3. Hermite (Cubic Hermite spline?)
  4. Gaussian
  5. Bell
  6. Bspline
  7. Mitchell
  8. Lanczos (3-lobe)
  9. Hanning
https://forum.doom9.org/showthread.php?p=1595641 wrote:Faststone Image Viewer

Resizers:

Bell
Bicubic
Bilinear
BSpline
Fastlinear
Lanczos2 (sharper)
Lanczos3 (default)

Linear
Mitchell
Nearest
Triangle
https://legacy.imagemagick.org/Usage/filter/index.html#lanczos wrote:The “Lanczos” filter basically uses the first “lobe” of the Sinc() function, to window the Sinc() function. That is, the filter's weighting function is used to set the filter's own windowing function. Many people see this as being a good reason to select it over the many other Windowed Sinc Filters. Though there is little to no real evidence that it is the best, it is a solid middle range filter.

By default IM defines the “Lanczos” filter as having 3 “lobes”. The reason for this is because the windowing function itself is “untappered”, in that it is just a single lobe that cuts off, with the functions first zero crossing coinciding with the window support limits. See How Windowed Filters Work above.

However a 2-lobed “Lanczos2” filter (Lanczos with a default lobes of 2, added for easy user selection) has also been found to be popular, as it will avoid the positive Ringing Artefacts that can be generated by Windowed-Sinc filters.
XnView Classic: SHARPEN “built in” in resize image panel
User avatar
XnTriq
Moderator & Librarian
Posts: 5634
Joined: Sun Sep 25, 2005 3:00 am
Location: Ref Desk

Re: Downsampled image has lower quality than expected

Post by XnTriq »

stickynoteme's source.jpg converted to PNG and downsampled from 447×447 to 333×333 pixels with…
  • XnView Classic (Bilinear + Lanczos)
  • XnView MP (Lanczos)
  • XnConvert (Lanczos)
  • nConvert (Lanczos)
  • PhotoFiltre (Lanczos)
  • IrfanView (Lanczos)
  • FastStone Image Viewer (Lanczos3 + Lanczos2)
  • Photoshop CS2 (Bicubic + Bicubic Sharper + Bicubic Smoother)
… and compressed with PngOptimizer:

p167343.zip
(922.39 KiB) Downloaded 7 times
Post Reply