@@ -444,14 +444,42 @@ class json_response
444444{
445445 try
446446 {
447- $ query = 'SELECT coi, width, height FROM ' .$ prefixeTable .'images WHERE path= \'' .$ page ['src_location ' ].'\'' ;
447+ $ query = '
448+ SELECT
449+ id,
450+ coi,
451+ width,
452+ height,
453+ rotation
454+ FROM ' .$ prefixeTable .'images
455+ WHERE path= \'' .$ page ['src_location ' ].'\'
456+ ; ' ;
457+
448458 if ( ($ row =pwg_db_fetch_assoc (pwg_query ($ query ))) )
449459 {
450460 if (isset ($ row ['width ' ]))
451461 {
452462 $ page ['original_size ' ] = array ($ row ['width ' ],$ row ['height ' ]);
453463 }
454464 $ page ['coi ' ] = $ row ['coi ' ];
465+
466+ include_once (PHPWG_ROOT_PATH . 'admin/include/image.class.php ' );
467+
468+ if (empty ($ row ['rotation ' ]))
469+ {
470+ $ page ['rotation_angle ' ] = pwg_image::get_rotation_angle ($ page ['src_path ' ]);
471+
472+ single_update (
473+ $ prefixeTable .'images ' ,
474+ array ('rotation ' => pwg_image::get_rotation_code_from_angle ($ page ['rotation_angle ' ])),
475+ array ('id ' => $ row ['id ' ])
476+ );
477+ }
478+ else
479+ {
480+ $ page ['rotation_angle ' ] = pwg_image::get_rotation_angle_from_code ($ row ['rotation ' ]);
481+ }
482+
455483 }
456484 if (!$ row )
457485 {
@@ -472,8 +500,6 @@ class json_response
472500 ierror ("dir create error " , 500 );
473501}
474502
475- include_once (PHPWG_ROOT_PATH . 'admin/include/image.class.php ' );
476-
477503ignore_user_abort (true );
478504set_time_limit (0 );
479505
@@ -482,7 +508,11 @@ class json_response
482508
483509$ changes = 0 ;
484510
485- // todo rotate
511+ // rotate
512+ if (0 != $ page ['rotation_angle ' ])
513+ {
514+ $ image ->rotate ($ page ['rotation_angle ' ]);
515+ }
486516
487517// Crop & scale
488518$ o_size = $ d_size = array ($ image ->get_width (),$ image ->get_height ());
@@ -554,6 +584,7 @@ class json_response
554584{// strip metadata for small images
555585 $ image ->strip ();
556586}
587+
557588$ image ->set_compression_quality ( $ params ->quality );
558589$ image ->write ( $ page ['derivative_path ' ] );
559590$ image ->destroy ();
0 commit comments