Welcome Guest, Not a member yet? Register   Sign In
Modify the updoad class to check image orientation?
#1

[eluser]chefnelone[/eluser]
Hello,

I need to do some change to the upload class to check on the uploaded image orientation.

I´d create the parameter:
Code:
function initialize($config = array())
{
  $defaults = array(
        
    'orientation'            => 'landscape', // lanscape, portrait
     .....
  );
}

The class should check if the uploade image orientation match the preference, and if not should show the error with:

Code:
if ( ! $this->is_allowed_orientation())
        {
            $this->set_error('upload_invalid_orientation');
            return FALSE;
        }

But then I found complicate to make the rest...
This week I´ll be posting what I do to get some help

Thanks
#2

[eluser]Cristian Gilè[/eluser]
One the image has been uploaded, check if the width is longer than the length for landscape, and if the length is longer than the width for portrait.

Code:
$im = @imagecreatefromjpeg('path/to/your/uploaded/image');

if(imagesx($im) > imagesy($im))
{
    //landscape
}
elseif(imagesx($im) < imagesy($im))
{
    //portrait
}
else
{
    //default
}


Cristian Gilè
#3

[eluser]chefnelone[/eluser]
[quote author="Cristian Gilè" date="1296002007"]One the image has been uploaded, check if the width is longer than the length for landscape, and if the length is longer than the width for portrait.

Code:
$im = @imagecreatefromjpeg('path/to/your/uploaded/image');

if(imagesx($im) > imagesy($im))
{
    //landscape
}
elseif(imagesx($im) < imagesy($im))
{
    //portrait
}
else
{
    //default
}




Cristian Gilè[/quote]

thanks, I think that your code is to put in the controller, not in the upload class. Am I right?
#4

[eluser]Cristian Gilè[/eluser]
Yes, in the controller or, as a function, in the extended upload class.


Cristian Gilè




Theme © iAndrew 2016 - Forum software by © MyBB