resampling a png results in terrible output quality

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: resampling a png results in terrible output quality

Post by Bonzo »

This gave a resonable result for me:

Code: Select all

convert test.png -resize 65x38 -filter Blackman testout2.png
The Blackman filter looks quite good; do you have access to php ? If you do try this code for the other filters if not PM me a link to an image and I will run it for you.

Code: Select all

<?php
// Build the array of filters to be used
exec("convert -list filter", $IMarray, $code);
// Start the loop to resize with the different filters
foreach ($IMarray as $value) {
$new_name = $value."_resize.jpg";
exec ("convert test.png -filter $value -resize 100x100 $new_name");
echo "<br><img src=\"".$new_name."\"width=\"100\"><br>";
echo $value;
}
?>
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: resampling a png results in terrible output quality

Post by anthony »

Using -sample to resize is not a good idea.

Using -resize is the better way. Using a Blackman filter produces a sharper resized image that the default Mitchell (slightly blurry), or Lanczos (slightly ringing) filter, though at a cost of some aliasing. See the re-vampled page on IM Examples, Resizing, for more details of these 'resize artifacts'

However the ideal way is to draw the font at the right size in the first place. Preferably with a font that is designed to be draw at very small pointsizes. There are some, such as the Libration, and DejaVu LGC fonts designed for use on Linux displays that do work at small scales.

Ideally a bitmap font should be available as an option in IM, which will allows for really small pointsized fonts (5 to 8 pixels high), however at this time IM fails in this regard. It is supposed to be able to handle it but I have as yet failed to get any bitmap font (non-Truetype) to work properly.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply