Page 1 of 1

Rotate keeping quality

Posted: 2014-06-03T12:59:56-07:00
by myspacee
Hello,
i'm building a Imagemagick php service for my lan users.

I want to allow, via Browser, image rotation that rotate image one step at time (+1% | -1%)
but after few rotations image result very degraded.

Is there any way (or script strategy) to keep quality rotation after rotation ?

thank you for any help,
m.

Re: Rotate keeping quality

Posted: 2014-06-03T13:07:31-07:00
by snibgo
You are not using lossy compression, such as jpeg, I hope.

Are you:
1. Rotating original by 1 degree, than rotating that by another degree, etc, or

2. Keeping the original, rotating it by 1 degree, then rotating the original by 2 degrees, etc?

Re: Rotate keeping quality

Posted: 2014-06-03T15:06:12-07:00
by myspacee
Hello,
I'm using only png for my site and all conversions.

Case 1. Rotating original and ovewrite it with rotated image, then return to user for further steps.

After rotation, image is inscribed in white square so i trim white board in excess.
This causes a false zoom effect that ruins image after 5/6 rotations.

I think to script: keeping original, save user preferences and apply wanted rotations always on original image.
But i'm forced to rethink php UI if choose this scenario.

Anyway to rotate without big loss of quality?

Thank you,
M.

Re: Rotate keeping quality

Posted: 2014-06-03T16:12:40-07:00
by snibgo
myspacee wrote:After rotation, image is inscribed in white square so i trim white board in excess.
This causes a false zoom effect that ruins image after 5/6 rotations.
I don't understand. Can you show examples? Perhaps the solution is not to trim each time.

Any operation like rotating or resizing will mangle pixels. There is no escaping this. The trick is to minimise the number of operations. Sometimes, operations can be done on large images but small versions are shown to the user.

Re: Rotate keeping quality

Posted: 2014-06-04T00:24:34-07:00
by myspacee
my PHP script isn't so easy to show here, it's module called by other one.

But i can summarize in this way:

Code: Select all

copy original.png 11.png /y

cconvert 11.png -rotate 1% zz.png
copy zz.png 11.png /y
cconvert 11.png -rotate 1% zz.png
copy zz.png 11.png /y
cconvert 11.png -rotate 1% zz.png
copy zz.png 11.png /y
cconvert 11.png -rotate 1% zz.png
copy zz.png 11.png /y
cconvert 11.png -rotate 1% zz.png
copy zz.png 11.png /y
cconvert 11.png -rotate 1% zz.png
copy zz.png 11.png /y
cconvert 11.png -rotate 1% zz.png
copy zz.png 11.png /y
cconvert 11.png -rotate 1% zz.png
copy zz.png 11.png /y
cconvert 11.png -rotate 1% zz.png
copy zz.png 11.png /y
cconvert 11.png -rotate 1% zz.png
copy zz.png 11.png /y
cconvert 11.png -rotate 1% zz.png
copy zz.png 11.png /y
cconvert 11.png -rotate 1% zz.png
copy zz.png 11.png /y
cconvert 11.png -rotate 1% zz.png
copy zz.png 11.png /y
All start from uploaded image. this image, after rotation, overwrite original.
In above example i don't trim to show 'tunnel zoom' effect.

m.

Re: Rotate keeping quality

Posted: 2014-06-04T08:26:18-07:00
by holden
The only way you are going to be able to do this nicely is to do each rotation from the base image, not from the previously rotated image.

Re: Rotate keeping quality

Posted: 2014-06-04T19:39:42-07:00
by anthony
Every type of distortion will degrade the image in some way.

The only manipulations that do not are simple cuts, crops, move (integer only) flips, flops etc...
See Simple Distotions
http://www.imagemagick.org/Usage/warping/#simple

All other types will degrade the image.. It is a fact due to the nature of the 'raster' storage, which is itself a degradion of the original source (real life or mathematical construct) of the image. Of course the higher the resolution the less degrading you would get even from the original.

The act of saving images in a raster format or worse a JPG lossy format (which is itself a image distortion, transforming it into a fourier frequency space), is itself a degrading process.


As such the rule of thumb with most image manipulation is... start with the most undistorted image you have, and try to minimise the total number of distortion steps applied. One very complex distion systems can apply hundreds of distortions all in a single step, and thus minimise the total degrading to that of a single step.

In your case always distort from the first original image, using the total amount of rotation the user has specified to generate that image.

This problem is also talked about in an example on generating a image of a stack of rotated images..
See last example in the section...
http://www.imagemagick.org/Usage/thumbnails/#polaroid