This topic is locked

Three features for image uploader

8/26/2015 8:15:17 AM
Suggestions
A
automaticjack author

Hi, currently I've fixed this for my projects but I think it's a good idea to make it default features for image uploader.
1) Fix exif rotation issue.
Windows 8 users have a old bug with image rotation, when they rotate a picture, picture is rotated only in exif image, when image is uploaded vertical images are uploaded as horizontal ones.
The issue is very old and described here (as example) http://answers.microsoft.com/en-us/windows/forum/windows8_1-pictures/rotation-of-images-windows-vista-vs-windows-81/5298ed4b-9a5e-4613-bd88-a3cab7a0dd6e?page=3
Currently I'm using this code to fix it (extracted from stackoverflow), added to uploadhandler.php



function corrigeorientacion($fichero, $nombre) {

// primero controlo la orientacion



$exif = exif_read_data($fichero);
if (!empty($exif['Orientation'])) {



$pathInfo = pathinfo($nombre);

$ext = trim(strtolower($pathInfo["extension"]));

switch ($ext) {

case "jpg":

case "jpeg":

$image = imagecreatefromjpeg($fichero);

break;

case "gif":

$image = imagecreatefromgif($fichero);

break;

case "png":

$image = imagecreatefrompng($fichero);

break;

}

switch ($exif['Orientation']) {

case 3:

$image = imagerotate($image, 180, 0);

break;
case 6:

$image = imagerotate($image, -90, 0);

break;
case 8:

$image = imagerotate($image, 90, 0);

break;

}
switch ($ext) {

case "jpg":

case "jpeg":

imagejpeg($image, 'tmp_'.$nombre,65);

break;

case "gif":

imagegif($image, 'tmp_'.$nombre);

break;

case "png":

imagepng($image, 'tmp_'.$nombre,6);

break;

}

}



return 'tmp_'.$nombre;



}

}


2) Set image quality
My customers are used to upload very heavy image sizes and my hosting free space is suffering, I'll love to see a quality parameter on image fields.
3) Make it sortable
At this moment, I'm doing this with jquery ui sortable and some css hacks, could be a good idea allow sort with drag and drop.
Thank you and keep the good work.