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  (Read 13730 times)

0 Members and 1 Guest are viewing this topic.

cybermoron

  • Coppermine newbie
  • Offline Offline
  • Posts: 2
Auto Rotate Photos
« on: August 19, 2004, 12:49:06 am »

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:

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

Then find the phrase
Code: [Select]
if (!file_exists($thumb)) {and add this below it:
Code: [Select]
auto_rotate_image($image);
I have 1.3.1.

Hope it helps.

« Last Edit: July 12, 2006, 05:44:23 am by TranzNDance »
Logged

mstralka

  • VIP
  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 178
Re: Auto Rotate Photos
« Reply #1 on: August 19, 2004, 12:59:50 am »

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
Logged
GO IRISH

cybermoron

  • Coppermine newbie
  • Offline Offline
  • Posts: 2
Re: Auto Rotate Photos
« Reply #2 on: August 19, 2004, 01:16:27 am »

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/
Logged

mstralka

  • VIP
  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 178
Re: Auto Rotate Photos
« Reply #3 on: August 19, 2004, 01:23:54 am »

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

Will someone with a *nix server and a camera that captures orientation test this?
« Last Edit: August 21, 2004, 05:36:42 am by mstralka »
Logged
GO IRISH

olly69

  • Coppermine newbie
  • Offline Offline
  • Posts: 6
Re: Auto Rotate Photos
« Reply #4 on: July 11, 2006, 11:51:32 pm »

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.

.
Logged

Nibbler

  • Guest
Re: Auto Rotate Photos
« Reply #5 on: July 12, 2006, 12:29:18 am »

After

Code: [Select]
auto_rotate_image($image);
add

Code: [Select]
$imagesize = getimagesize($image);
That should fix the problem.
Logged

olly69

  • Coppermine newbie
  • Offline Offline
  • Posts: 6
Re: Auto Rotate Photos
« Reply #6 on: July 12, 2006, 02:03:53 am »

Thanks Nibbler  ;D  That's sorted it.  Perfect.
Logged
Pages: [1]   Go Up
 

Page created in 0.027 seconds with 20 queries.