Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
Manual merge of #300 exif rotation
Browse files Browse the repository at this point in the history
  • Loading branch information
cdujeu committed Apr 16, 2014
1 parent a0e8862 commit 2315aa7
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 59 deletions.
57 changes: 28 additions & 29 deletions core/src/plugins/editor.diaporama/PThumb.lib.php
Expand Up @@ -1087,40 +1087,39 @@ function fastimagecopyresampled (&$dst_image, $src_image, $dst_x, $dst_y, $src_x
return true;
}

function exiforientation($image, $fetch)
{
if (!$this -> exif_rotation)
return;

if ($fetch)
{
$image_data = $this -> retrieve_remote_file($image,true, false, 1);
$exif = @exif_read_data("data://image/jpeg;base64,".@base64_encode($image_data),'IFD0');
} else
{
$exif = @exif_read_data($image);
}
if ($exif!=FALSE)
function exiforientation($image, $fetch)
{
return $exif['Orientation'];
if (!$this -> exif_rotation)
return;

if ($fetch)
{
$image_data = $this -> retrieve_remote_file($image,true, false, 1);
$exif = @exif_read_data("data://image/jpeg;base64,".@base64_encode($image_data),'IFD0');
} else
{
$exif = @exif_read_data($image);
}
if ($exif!=FALSE)
{
return $exif['Orientation'];
}
}
}

function rotationsupported($exif_orientation)
{
if (!$exif_orientation)
return FALSE;
function rotationsupported($exif_orientation)
{
if (!$exif_orientation)
return FALSE;

if (!$this -> exif_rotation)
return FALSE;
if (!$this -> exif_rotation)
return FALSE;

if (function_exists("imageflip"))
return TRUE;
if (function_exists("imageflip"))
return TRUE;

if ($exif_orientation!=2 and $exif_orientation!=4 and $exif_orientation!=5 and $exif_orientation!=7)
return TRUE;
if ($exif_orientation!=2 and $exif_orientation!=4 and $exif_orientation!=5 and $exif_orientation!=7)
return TRUE;

return FALSE;
}
return FALSE;
}
}
?>
58 changes: 29 additions & 29 deletions core/src/plugins/editor.diaporama/class.Diaporama.js
Expand Up @@ -343,39 +343,39 @@ Class.create("Diaporama", AbstractEditor, {
var height = parseInt(nPercent*this.crtHeight / 100);
var width = parseInt(nPercent*this.crtWidth / 100);

// apply rotation
this.imgBorder.removeClassName("ort-rotate-1");
this.imgBorder.removeClassName("ort-rotate-2");
this.imgBorder.removeClassName("ort-rotate-3");
this.imgBorder.removeClassName("ort-rotate-4");
this.imgBorder.removeClassName("ort-rotate-5");
this.imgBorder.removeClassName("ort-rotate-6");
this.imgBorder.removeClassName("ort-rotate-7");
this.imgBorder.removeClassName("ort-rotate-8");
var ort = node.getMetadata().get("ort");
if (ort)
this.imgBorder.addClassName("ort-rotate-"+ort);
// apply rotation
this.imgBorder.removeClassName("ort-rotate-1");
this.imgBorder.removeClassName("ort-rotate-2");
this.imgBorder.removeClassName("ort-rotate-3");
this.imgBorder.removeClassName("ort-rotate-4");
this.imgBorder.removeClassName("ort-rotate-5");
this.imgBorder.removeClassName("ort-rotate-6");
this.imgBorder.removeClassName("ort-rotate-7");
this.imgBorder.removeClassName("ort-rotate-8");
var ort = node.getMetadata().get("image_exif_orientation");
if (ort)
this.imgBorder.addClassName("ort-rotate-"+ort);

// Center vertically
var marginTop=0;
var marginLeft=0;
this.containerDim = $(this.imgContainer).getDimensions();
// Center vertically
var marginTop=0;
var marginLeft=0;
this.containerDim = $(this.imgContainer).getDimensions();

if (ort>4)
{
tmp=height;
height=width;
width=tmp;
}
if (ort>4)
{
tmp=height;
height=width;
width=tmp;
}

if (height < this.containerDim.height){
marginTop = parseInt((this.containerDim.height - height) / 2);
}
if (width < this.containerDim.width){
marginLeft = parseInt((this.containerDim.width - width) / 2);
}
if (height < this.containerDim.height){
marginTop = parseInt((this.containerDim.height - height) / 2);
}
if (width < this.containerDim.width){
marginLeft = parseInt((this.containerDim.width - width) / 2);
}

if(morph && this.imgBorder.visible()){
if(morph && this.imgBorder.visible()){
new Effect.Morph(this.imgBorder,{
style:{height:height+'px', width:width+'px',marginTop:marginTop+'px',marginLeft:marginLeft+'px'},
duration:0.5,
Expand Down
19 changes: 18 additions & 1 deletion core/src/plugins/editor.diaporama/class.ImagePreviewer.php
Expand Up @@ -122,7 +122,7 @@ public function generateThumbnail($masterFile, $targetFile)
{
$size = $this->currentDimension;
require_once(AJXP_INSTALL_PATH."/plugins/editor.diaporama/PThumb.lib.php");
$pThumb = new PThumb($this->getFilteredOption("THUMBNAIL_QUALITY"));
$pThumb = new PThumb($this->getFilteredOption("THUMBNAIL_QUALITY"), $this->getFilteredOption("EXIF_ROTATION"));
if (!$pThumb->isError()) {
$pThumb->remote_wrapper = $this->streamData["classname"];
//$this->logDebug("Will fit thumbnail");
Expand Down Expand Up @@ -176,6 +176,23 @@ public function extractImageMetadata(&$ajxpNode)
} else {
$realFile = $ajxpNode->getRealFile();
list($width, $height, $type, $attr) = @getimagesize($realFile);

if($this->getFilteredOption("EXIF_ROTATION")){
require_once(AJXP_INSTALL_PATH."/plugins/editor.diaporama/PThumb.lib.php");
$pThumb = new PThumb($this->getFilteredOption["THUMBNAIL_QUALITY"],$this->getFilteredOption("EXIF_ROTATION"));
$orientation = $pThumb->exiforientation($realFile, false);
if ($pThumb->rotationsupported($orientation))
{
$ajxpNode->image_exif_orientation = $orientation;
if ($orientation>4)
{
$tmp=$height;
$height=$width;
$width=$tmp;
}
}
}

$ajxpNode->image_type = image_type_to_mime_type($type);
$ajxpNode->image_width = $width;
$ajxpNode->image_height = $height;
Expand Down
2 changes: 2 additions & 0 deletions core/src/plugins/editor.diaporama/i18n/conf/en.php
Expand Up @@ -29,4 +29,6 @@
"Generate thumbnails or not" => "Generate thumbnails or not",
"Quality" => "Quality",
"Thumbs quality" => "Thumbs quality",
"Exif Rotation" => "Exif Rotation",
"Rotate image using exif rotation" => "Rotate image using exif rotation"
);
2 changes: 2 additions & 0 deletions core/src/plugins/editor.diaporama/i18n/conf/fr.php
Expand Up @@ -29,4 +29,6 @@
"Generate thumbnails or not" => "Génération des vignettes ou pas",
"Quality" => "Qualité",
"Thumbs quality" => "Qualité pour le rendu de la vignette.",
"Exif Rotation" => "Exif Rotation",
"Rotate image using exif rotation" => "Rotate image using exif rotation"
);
2 changes: 2 additions & 0 deletions core/src/plugins/editor.diaporama/i18n/conf/pt.php
Expand Up @@ -29,4 +29,6 @@
"Generate thumbnails or not" => "Gerar ou não miniaturas",
"Quality" => "Qualidade",
"Thumbs quality" => "Qualidade das miniaturas",
"Exif Rotation" => "Exif Rotation",
"Rotate image using exif rotation" => "Rotate image using exif rotation"
);

0 comments on commit 2315aa7

Please sign in to comment.