Resizing images without losing sharpness/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
benjamin10
Posts: 3
Joined: 2018-06-01T05:23:54-07:00
Authentication code: 1152

Resizing images without losing sharpness/quality

Post by benjamin10 »

Hello everyone!
I am quite new here, but working for many years with imagemagick (rudimentary ;) ).
My aim is to render pictures as to get the following specs:

- Size: 105x140mm
- Normalized
- very sharp

I tried it with the following command:
mogrify -normalize -resize 298x397 -quality 100% *.jpg
The problem is that the images get the right size but the quality/sharpness is too bad for my aims. I need the images for protocols, so they should be very sharp. In the end i want to use the images in libreoffice impress. Any hints for me?

In the past I used:
mogrify -normalize -resize 1280x1024 *.jpg
I then used the images in libreoffice impress but had to resize every picture by hand, which is a lot of work ;) (I am making a lot of protocols ;) ) The quality of the pictures did work in this method but it is time consuming!
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Resizing images without losing sharpness/quality

Post by snibgo »

Please say what version of IM you use, on what platform.

It would help if you linked to some example inputs, and what you have tried so far.
benjamin10 wrote:... but the quality/sharpness is too bad for my aims. I need the images for protocols, so they should be very sharp.
What type of images are these? Photos or graphics? Are you resizing down or up? Do you want to add more sharpness than is in the input images? Have you tried for example "-unsharp"?

If you are resizing photos down, eg for the web, I like the technique shown in Resampling with halo minimization. This sharpens without much side-effect such as halos.
snibgo's IM pages: im.snibgo.com
benjamin10
Posts: 3
Joined: 2018-06-01T05:23:54-07:00
Authentication code: 1152

Re: Resizing images without losing sharpness/quality

Post by benjamin10 »

I use
Version: ImageMagick 6.9.7-4 Q16 x86_64 20170114
On Kubuntu 18.04

Okay here are some sample pics in their original sizes (from different Cams/Smartphones):
https://owncloud.usedandabused.at/index ... zaCavYuQmh
Are you resizing down or up?
I want to resize them down, but as i write this it comes to my mind maybe it is not "resizing" the pictures but "compressing" them to 105x140mm so that the resolution stays the same, were as the size changes... Is this correct?
Have you tried for example "-unsharp"?
I tried it with:

Code: Select all

mogrify -normalize -resize 298x397 -quality 100% *.jpg && mogrify -unsharp 397x298 *.jpg 
But the result is too pixelated. (See here: https://owncloud.usedandabused.at/index ... RAZTBLtLgC)

The thing is that when i resize the pictures to say 1024x768 and edit them in libreoffice impress within the protocoll (make them smaller and place them into the right position) the resolution/quality of the picture is still very good. The pictures are still sharp and in good quality (see: https://owncloud.usedandabused.at/index ... MlMfx3i9Tg)
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Resizing images without losing sharpness/quality

Post by snibgo »

benjamin10 wrote:-unsharp 397x298
Typical unsharp settings are "0x1" or "0x5" for a heavy effect. Your setting will give horrible results.
benjamin10 wrote:I want to resize them down, but as i write this it comes to my mind maybe it is not "resizing" the pictures but "compressing" them to 105x140mm so that the resolution stays the same, were as the size changes... Is this correct?
If you don't want to change the number of pixels, but simply the size in mm, use a suitable "-density" setting.
snibgo's IM pages: im.snibgo.com
benjamin10
Posts: 3
Joined: 2018-06-01T05:23:54-07:00
Authentication code: 1152

Re: Resizing images without losing sharpness/quality

Post by benjamin10 »

Okay thank you for help. -density option did the trick!
This is the command I am using to get the desired images:

Code: Select all

mogrify -unsharp 0.25x0.25+8+0.065 -resize 1280x1024 -normalize -density 180 *.jpg 
If someone find it helpful here is the script I am using as a dolphin script to copy the originals and downsize them:

Code: Select all

#!/bin/bash

#Create a new folder and copy the content of the current folder to the new folder
mkdir small
cp *.jpg small
cp *.JPG small
cd small

#Unsharp, Resize and change the density to the right size (in my case: ~100x14mm) as to use them in powerpoint, libreoffice impress for flipchart protocolls. If you want to change the size do not change the resolution but the density parameter.
for i in *.jpg; do
 if [ -e "$i" ]; then
   file=`basename "$i" .jpg`
   mogrify -unsharp 0.25x0.25+8+0.065 -resize 1280x1024 -normalize -density 180 "$i"
 fi
done

for i in *.JPG; do
 if [ -e "$i" ]; then
   file=`basename "$i" .JPG`
   mogrify -unsharp 0.25x0.25+8+0.065 -resize 1280x1024 -normalize -density 180 "$i"
 fi
done
Post Reply