Advanced search  

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Pages: [1]   Go Down

Author Topic: Auto Rotate Photos (follow up)  (Read 2344 times)

0 Members and 1 Guest are viewing this topic.

ddtof

  • Coppermine newbie
  • Offline Offline
  • Posts: 1
Auto Rotate Photos (follow up)
« on: October 30, 2006, 04:00:30 pm »

This is to follow up topic: http://forum.coppermine-gallery.net/index.php?topic=9057.0

That is now closed as related to 1.3.x, but still valid for 1.4.x

I propose the following function to be compatible with Linux and Windows:
Code: [Select]
// auto rotate using JHead
function auto_rotate_image($path_to_image) {
   $real_path_to_image = realpath($path_to_image);

   // Form the command to rotate the image.
   if (eregi("win",$_ENV['OS'])) {
       $cmd = "jhead.exe -autorot \"$real_path_to_image\"";
   } else {
       $cmd = "jhead -autorot ".$real_path_to_image;
   }

   exec ($cmd);
}

Then I do not like the idea to modify the original picture, so I propose to modify only the thumb and normal picture.
Fore that replace the
Code: [Select]
        if (!file_exists($thumb)) {
            if (!resize_image($image, $thumb, $CONFIG['thumb_width'], $CONFIG['thumb_method'], $CONFIG['thumb_use']))
                return false;
        }
        if (max($imagesize[0], $imagesize[1]) > $CONFIG['picture_width'] && $CONFIG['make_intermediate'] && !file_exists($normal)) {
            if (!resize_image($image, $normal, $CONFIG['picture_width'], $CONFIG['thumb_method'], $CONFIG['thumb_use']))
                return false;
        }
by
Code: [Select]
        if (!file_exists($thumb)) {
            if (!resize_image($image, $thumb, $CONFIG['thumb_width'], $CONFIG['thumb_method'], $CONFIG['thumb_use']))
                return false;
            auto_rotate_image($thumb);
        }
        if (max($imagesize[0], $imagesize[1]) > $CONFIG['picture_width'] && $CONFIG['make_intermediate'] && !file_exists($normal)) {
            if (!resize_image($image, $normal, $CONFIG['picture_width'], $CONFIG['thumb_method'], $CONFIG['thumb_use']))
                return false;
            auto_rotate_image($normal);
        }

Don't hesitate to give me your opinion.
Logged
Pages: [1]   Go Up
 

Page created in 0.016 seconds with 19 queries.