Rotattion makes text blurry

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
boromb
Posts: 17
Joined: 2009-01-29T03:20:34-07:00

Rotattion makes text blurry

Post by boromb »

Hello!

I have tried to find a solution for my problem but I couldn't.

I first convert a PDF file to JPG and then if user wants to, rotate
the image but rotation makes text little blurry. The image is an invoice.
White background and black text. But after rotation the text get some
gray background. Is it possible to rotate without those side-effects?

Best regards!
boromb
Posts: 17
Joined: 2009-01-29T03:20:34-07:00

Re: Rotattion makes text blurry

Post by boromb »

Hello!

Blurriness is less if I don't change the quality.
-quality 90 gives blurriness
-quality 100 seems to work fine
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Rotattion makes text blurry

Post by magick »

Try this command to lessen the blurriness of your image:
  • convert -density 400 text.pdf -resize 25% -quality 100 image.jpg
boromb
Posts: 17
Joined: 2009-01-29T03:20:34-07:00

Re: Rotattion makes text blurry

Post by boromb »

magick wrote:Try this command to lessen the blurriness of your image:
  • convert -density 400 text.pdf -resize 25% -quality 100 image.jpg
Hello magick!

I'm almost doing that.
This is the command I run to convert PDF to jpg

Code: Select all

convert -density 300 text.pdf -scale 900 -quality 100 text.jpg
Having quality 100 the rotation seems so go well. I can't see any distortion with my own eyes.
Having quality 90 distortion gets very visible.

I'm running with density -300 because it's faster and it gives quite good quality images.

Best regards and thanks for the help!
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Rotattion makes text blurry

Post by anthony »

Going back to the original query....

First do not save to JPEG, when you are NOT finished processing the image. That image file format is lossy and will loose color and blur sharp edges as it attempt to do extreme image compression.

Second the technique of creating a larger version of the image the shrinking is known as 'Super-Sampling'
http://www.imagemagick.org/Usage/distorts/#super_sample
basically by working with a larger image then resizing the final image you increase the number of pixels per final pixel, removing any small edge noise or blurring that results from image processing.

For PDF the noise is 'Aliasing Effects' from rasterization.
For Rotation it is interpolation or distortion noise.

now you were complaing of rotation blur. so the recommended solution is..
1/ read you PDF at the larger -density
2/ rotate or otherwise 'fix' the image as needed
3/ NOW -resize or -resample the image to its final size
4/ write the image into its final file format
And do NO more processing of the image.

NOTE if you always do all your processing starting with the source image you will get the best quality.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
boromb
Posts: 17
Joined: 2009-01-29T03:20:34-07:00

Re: Rotattion makes text blurry

Post by boromb »

Thank you very much for your help Anthony!

My task is this:
1. Make all incoming PDF files showable in the application dialog. I need to convert PDF to some image files so they can be shown.
2. Fast and use as little hard drive as possible.
3. Do it with so good quality as possible

My test shows that JPG gives smallest images with sufficient quality.

I tried to use PNG but images gets about 30% bigger and they are not
noticeable better. PNG was my first choice.

User that use our software need to see the file before he tries to rotate. PDF files that converts to JPG will not be rotated.
But user may rotate files other then PDF.
I need to resize the file because we don't have enough good dialog object(widgets) that can show the file in good way.

bla bla bla :)

I'll look at super_sample and return.

Thank you very much for all help and great software.

Best regards!
Post Reply