How to rezise an image and get the best posible quality

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
joel_fe

How to rezise an image and get the best posible quality

Post by joel_fe »

hello, to everybody:

When a resize images I notice that looses some quality, ¿what can y I do for generate rezised images with the best posible quality?. Actualy im usuing the next command

convert originalimage.jpg -resize 300x300 -quality 100 resizedimage.jpg

I' ll apreciate any help

regards

Joel
andrewadperfect

Re: How to rezise an image and get the best posible quality

Post by andrewadperfect »

convert originalimage.jpg -resize 300x300 -density 300 -quality 100 resizedimage.jpg


Try specifying the density (dpi). The above addition to your command will set the density at 300dpi.
For a web photo, -density 72 should be fine (and will keep the file smaller, and take way less
time processing).

Let me know if that works for you.
joel_fe

Re: How to rezise an image and get the best posible quality

Post by joel_fe »

andrewadperfect :

Really, thank yoy very much, ill try and let you know

Regards

Joel
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: How to rezise an image and get the best posible quality

Post by anthony »

andrewadperfect wrote:Try specifying the density (dpi). The above addition to your command will set the density at 300dpi. For a web photo, -density 72 should be fine (and will keep the file smaller, and take way less time processing).
andrewadperfect, How does this improve quality?

It should not effect the resize, nor the pixels in the final image. Is the JPEG compression 'density' effected? Or does this only effect the program used to display the JPEG by adding resolution meta-data to the JPEG image.

I am sure this information would be important to other IM users and should be added to IM examples. As such I would like to know how this solved the users issue.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
andrewadperfect

Re: How to rezise an image and get the best posible quality

Post by andrewadperfect »

I'm afraid I can't tell you all the specifics on how IM handles things... I am only speaking from
experience. It could be that when resizing a JPG, it retains the DPI of the original image. And
I suppose that resizing to 300x300 will make an otherwise large image look like it has less
quality even though it has the same DPI.

However, I always use the -density option whether it's needed or not, and have found
some cases were I didn't, that there was a poor result.

In this case, since the example shown was -quality 100, setting the density seemed like
the next logical step in improving the end result.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: How to rezise an image and get the best posible quality

Post by anthony »

Okay thanks. Looks like it is just later applications need for a correct density that then proves to be the problem.

Many JPEGs have no density, and IM may add a 72dpi density by default.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
joel_fe

Re: How to rezise an image and get the best posible quality

Post by joel_fe »

andrewadperfect:
I did that yo seggested, about adding density, but i dont had the results I was waiting, even I combine image magic with other free tools like Jpegtran an Jhead, those free programs are line driven programs for manipulating the non-image parts of Exif flavour JPEG files that most digital cameras produce, and tranfer it to the image you are modified to preserve the information and get lossless quality, but either I didn´t get what i was lloking for. Next is an example how i combine the tools to get what I want:

jhead -cmd "mogrify -quality 100 -resize 576x380 -density 300 &i " *.jpg

This comand mogrify all jpg file an rezise then to a 576x380 pixel size with a quality 100 I espected to preserve the quality of the image, but it fails. Actually I´m developing a fotokiosk in visiual basic, so I need to print images from digital cameras, my problem happens when I try to resize the images for an especific paper size, when I do that, the resized images looses quality, for this proces I´m using, imagemagick, jpegtran an jhead, but i can obtain the quality image i need, and ¿What is this quality parameter?, well, if you print an image with the windows photograph asistant in a 4x6 size (In the file explorer, select an image, click over with the right mouse button and from the menu listed select print), the print you get have an excelent quality, otherwise if you try to reply this procedure by hand,resizing an image using imagemagic an jhead, to obtain a 576x380 (4x6 size) an print it directly to the pinter without any asistant or inclusive with the windows asistant this print haven´t a good quality, you can try it with the image ím using downloading it from http://www.aspes.com.mx/imagenes/dscf0086.jpg .

In resume i need a way using free o non free component that allow me generate resized jpeg image with high printable quality, i was searching the web for a solution but i can't find it

Really I apreciate you help or some other idea, is very important for my company and my job

Regards

Joel
andrewadperfect

Re: How to rezise an image and get the best posible quality

Post by andrewadperfect »

joel_fe wrote:to obtain a 576x380 (4x6 size) an print it directly to the pinter without any asistant or inclusive with the windows asistant this print haven´t a good quality

I think that's your problem right there. If you want to print this file, you do not want to resize it to 576x380. That's only 96 dpi, not enough for a good quality print, only slightly higher than the 72 dpi which is standard for web quality.

576 pixels / 6 inches = 96 dpi (poor quality for print, newspaper quality at best)

2048 pixels / 6 inches = 341 dpi (this is a good quality print level)

The image you listed is 2048x1536... there is no need to resize this image for better printing. In fact, processing it in any way could cause the quality to go down simply due to the JPEG processing.

What you need to realize is that pixels is only a dot and has nothing to do with how wide a picture will be printed. The more dots you can print into a smaller area, the better quality the image will be. Don't be fooled by a program telling you that you need to resize and image to print it at a certain size. You want to use large files for printing to get better results.
Post Reply