Kunena 6.0.9.1 Released
The Kunena team has announce the arrival of Kunena 6.0.9.1 [K 6.0.9.1] which is now available for download as a native Joomla extension for J! 4.2.x. This version addresses most of the issues that were discovered in K 6.0 and issues discovered during the development stages of K 6.0.
Solved Image orientation on upload - K 4.06 with Crypsis
- WolfgangOWL
-
Topic Author
- Offline
- Senior Member
Less
More
7 years 4 months ago #1
by WolfgangOWL
Image orientation on upload - K 4.06 with Crypsis was created by WolfgangOWL
Hello folks,
I recently updated from K 4.05 with Blue Eagle template to 4.06 with Crypsis. I modified the upload.php to change the orientation of uploaded images with portrait orientation using the orientation tag of jpg files. This worked fine until before the update. The same modification applied after the update has no effect at all. Can anyone help me with this?
Thanks in advance,
Wolfgang
I recently updated from K 4.05 with Blue Eagle template to 4.06 with Crypsis. I modified the upload.php to change the orientation of uploaded images with portrait orientation using the orientation tag of jpg files. This worked fine until before the update. The same modification applied after the update has no effect at all. Can anyone help me with this?
Thanks in advance,
Wolfgang
Please Log in or Create an account to join the conversation.
- WolfgangOWL
-
Topic Author
- Offline
- Senior Member
7 years 4 months ago #2
by WolfgangOWL
Replied by WolfgangOWL on topic Image orientation on upload - K 4.06 with Crypsis
I found out the reason. Crypsis uses the ajaxUpload function for file uploads. After applying the image rotation there it works fine.
Please Log in or Create an account to join the conversation.
7 years 4 months ago #3
by 810
Replied by 810 on topic Image orientation on upload - K 4.06 with Crypsis
good, could you add the code, how to change it, maybe someone else can use it.
Please Log in or Create an account to join the conversation.
- WolfgangOWL
-
Topic Author
- Offline
- Senior Member
7 years 4 months ago #4
by WolfgangOWL
Shure I can.
This is the function which does the image rotation:
This code must be placed in function ajaxUpload above of
}
catch (Exception $exception)
{
}
And this must be placed in function upload above of
if (!KunenaFile::copy($file->tmp_name, $file->destination))
{
throw new RuntimeException(JText::_('COM_KUNENA_UPLOAD_ERROR_FILE_RIGHT_MEDIA_DIR'), 500);
}
Replied by WolfgangOWL on topic Image orientation on upload - K 4.06 with Crypsis
810 wrote: good, could you add the code, how to change it, maybe someone else can use it.
Shure I can.
This is the function which does the image rotation:
Code:
function correctImageOrientation($filename)
{
$testForJpg = getimagesize($filename);
if ($testForJpg[2] == 2)
{
if (function_exists('exif_read_data'))
{
$deg = 0;
$exif = exif_read_data($filename);
if ($exif && isset($exif['Orientation']))
{
$orientation = $exif['Orientation'];
if ($orientation != 1)
{
$img = imagecreatefromjpeg($filename);
switch ($orientation)
{
case 3:
case 4: $deg = 180;
break;
case 5:
case 6: $deg = 270;
break;
case 7:
case 8: $deg = 90;
break;
}
}
}
if ($deg > 0)
{
$img = imagerotate($img, $deg, 0);
imagejpeg($img, $filename, 95);
}
}
}
}
This code must be placed in function ajaxUpload above of
}
catch (Exception $exception)
{
}
Code:
// get filename from stream
$meta_data = stream_get_meta_data($out);
$filename = $meta_data["uri"];
$this->correctImageOrientation($filename);
And this must be placed in function upload above of
if (!KunenaFile::copy($file->tmp_name, $file->destination))
{
throw new RuntimeException(JText::_('COM_KUNENA_UPLOAD_ERROR_FILE_RIGHT_MEDIA_DIR'), 500);
}
Code:
$this->correctImageOrientation($file->tmp_name);
Please Log in or Create an account to join the conversation.
Time to create page: 0.231 seconds