PHP image rotation is lost after each rotation

I am currently using GD and some PHP to rotate images. After each rotation, the image quality deteriorates. Is there a better way to do this or is this expected?

    $img = new ImageClass;
    list($original, $info) = $img->load($src);

    // Determine angle
    $angle = strtolower($angle);
    if( $angle == 'cw' || $angle == 'clockwise' ) $angle = 270;
    if( $angle == 'ccw' || $angle == 'counterclockwise' ) $angle = 90;

    $rgb = $img->hex2rgb($bg_color);
    $bg_color = imagecolorallocate($original, $rgb['r'], $rgb['g'], $rgb['b']);

    $new = imagerotate($original, $angle, $bg_color);

Is it possible to rotate the client side of the image, possibly jquery, and then save the image via PHP to the server? I guess this will help with image quality.

+5
source share
4 answers

In our exchange service, we handle it differently. We save the original image at any time and keep the initial rotation (0).

, +/- 90 . .

, . , (, , ), , , .

+4

, , , .

, ( ) .

+3

, JPG, . "" . PNG, , , , .

+1

+1

All Articles