Auto Rotate Photos Auto Rotate Photos
 

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]

Main Menu

Auto Rotate Photos

Started by cybermoron, August 19, 2004, 12:49:06 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

cybermoron

Well, I had no luck to find this anywhere, so I did something, if anyone is interested.

You will need JHead.exe and jpegtran.exe which should reside in the coppermine root folder.

Add this function to include/picmgmt.inc:

// 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.
$cmd = "jhead.exe -autorot \"$real_path_to_image\"";
exec ($cmd);
}


Then find the phrase if (!file_exists($thumb)) {and add this below it:
auto_rotate_image($image);

I have 1.3.1.

Hope it helps.


mstralka

This could be very cool.  I haven't tried it yet but I think you should note that the code you provided is for Windows servers.  jhead.exe won't work on linux servers (most web hosts). 

What happens if you're uploading a non-JPEG file that doesn't have exif data?

Thanks
GO IRISH

cybermoron

Good question.
Tried that and everything works just cool.

In the Jhead site there is a Linux version, do you mean that it just doesnt work there?

http://www.sentex.net/~mwandel/jhead/

mstralka

#3
Your code references jhead.exe... Linux doesn't use ".exe".  My camera doesn't seem to capture the orientation (Optio s4i) so I couldn't test this.  For *nix systems try this code

// 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.
   $cmd = "jhead -autorot ".$real_path_to_image;
   exec ($cmd);
}


Will someone with a *nix server and a camera that captures orientation test this?
GO IRISH

olly69

Hi,

I am using a Fedora Core 4 virtual machine for coppermine.

Coppermine 1.4.8 (stable), , jhead 2.6, Apache 2.0.54-10.2, mysql-4.1.16-1.FC4.1, mysql-server-4.1.16-1.FC4.1, php-mysql-5.0.4-10.5, php-5.0.4-10.5

I have implemented the code mstralka suggested with mixed success.  It works, but (and I can't see why this would be restricted to a *nix problem) whilst all 3 images are rotated correctly, the html/php generated to build the thumbnail view doesn't get updated with the new dimensions, so the correctly rotated portrait thumbnail gets stretched out.  The intermediate and full res pictures are fine.  Exif data gets retained as well which is great (including updated rotate).

Annoyingly one of my tests worked totally correctly.  I have tried to replicate the exact situation but have frustratingly been unable to do so.

I'm a coppermine newbie (though already a fan) so I don't really know where to start looking. I'd be very grateful if someone could have a look for me.  Maybe this is a new problem with the later versions of coppermine ?

I really want this to work.  Both cameras I use correctly export the exif rotation data and I have several thousand to import, so this will make life really easy.

Cheers

Olly.

.

Nibbler

After

auto_rotate_image($image);

add

$imagesize = getimagesize($image);

That should fix the problem.

olly69

Thanks Nibbler  ;D  That's sorted it.  Perfect.