Skip to Content Skip to Menu

[#6805] CB gallery image rotation

  • activha
  • activha
  • ONLINE
  • Posts: 2334
  • Thanks: 117
  • Karma: 13
7 years 2 months ago - 7 years 1 month ago #297371 by activha
[#6805] CB gallery image rotation was created by activha
Hello

We tried to use CB Gallery with image upload in a comment from iOS album

It seems that the image is not rotated correctly when uploaded : see app.activ-ha.com/business/81-restaurants/3599-vecchia-senese for an example

I guess this may be due to iOS which needs a special tag for the upload but I don't remember exactly what it was. We had the same problem a couple of years ago

Hope you can solve it

Regards
Jean
Last edit: 7 years 1 month ago by krileon. Reason: Added [#6805] tag to subject

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48536
  • Thanks: 8290
  • Karma: 1445
7 years 2 months ago #297381 by krileon
Replied by krileon on topic CB gallery image rotation
EXIF data can not be parsed for client side resizing. If you want EXIF orientation handled then you have to turn off client side resizing. Alternatively just open the model window and use the rotate buttons on the images menu as CB Gallery lets you rotate images.

I will be reviewing EXIF parsing for client side resizing usecase in a later release, but it's unlikely to happen. The EXIF data is completely encoded to bytes in this case and it takes a heavy JS library to parse it out, which I really do not want to have to include in CB Gallery.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

  • activha
  • activha
  • ONLINE
  • Posts: 2334
  • Thanks: 117
  • Karma: 13
7 years 1 month ago #297570 by activha
Replied by activha on topic CB gallery image rotation
I found this plugin to fix orientation.
Will it work with gallery image upload ?
Or can you implement the case with exit orientation tag in CB uploads ?
Code:
/<?php // *********************************************************************************** // * * // * Nifty iOS Image Fixer * // * * // *********************************************************************************** // * * // * @package plg_content_nifty_iosimagefixer * // * @author In2 Computing Ltd. <support@in2computing.com> * // * @copyright Copyright (c) 2017 In2 Computing Ltd. All Rights Reserved. * // * @license GNU General Public Licence http://www.gnu.org/licenses/gpl-3.0.html * // * @website https://in2computing.com/ * // * @link https://in2computing.com/nifty-products/ios-image-fixer * // * @version 1.0.0 * // * * // *********************************************************************************** defined('_JEXEC') or die; /** * Nifty iOS Images Fixer content editing Plugin * * @package Joomla.Plugin * @subpackage Content.Nifty_iosimagefixer */ jimport('joomla.filesystem.file'); class PlgContentNifty_iosimagefixer extends JPlugin { public function onContentAfterSave($context, $object_file, $isNew) { if($context === 'com_media.file' && $isNew) { if(!JFile::exists($object_file->filepath)) { $this->LogError('onContentBeforeSave: File not found.'); return true; } return $this->fixImageRotation($object_file->filepath); } return true; } protected function fixImageRotation($file) { try { // new JImage object from image path $image = new JImage($file); // Read the exif data from the image $exif = exif_read_data($file); $rotate = 0; // Get the angle to rotate the image based on the orientation if (!empty($exif['Orientation'])) { // Based on the orientation of time image, assign the rotation angle. switch ($exif['Orientation']) { case 3: $rotate = 180; break; case 6: $rotate = -90; break; case 8: $rotate = 90; break; } // Rotate the image appropriately $newImage = $image->rotate($rotate); // Overwrite the old image with new image if (!$newImage->toFile($file)) { $this->LogError("Unable to overwrite '" . $file . "'"); return false; } } else { // No exif data found. return true; } } catch(exception $ex) { $this->LogError($ex->getMessage()); return false; } } protected function LogError($msg) { // Include the JLog class. jimport('joomla.log.log'); // Initialise a basic logger with no options (once only). JLog::addLogger(array()); // Log the error. JLog::add('plg_content_nifty_iosimagefixer->nifty_iosimagefixer.php: ' . $msg, JLog::ERROR); } }

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48536
  • Thanks: 8290
  • Karma: 1445
7 years 1 month ago - 7 years 1 month ago #297576 by krileon
Replied by krileon on topic CB gallery image rotation
CB Gallery already handles the orientation PHP side. As explained it does not work with client side resizing. This is because client side resizing removes the EXIF data. Disable client side resizing and orientation will be handled fine, but you lose the benefit of client side resizing. No that won't work with CB Gallery and isn't necessary regardless. Your only option if you want orientation AND client side resizing is to use the rotate left/right menu options in the modal window of the photo.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
Last edit: 7 years 1 month ago by krileon.

Please Log in or Create an account to join the conversation.

  • activha
  • activha
  • ONLINE
  • Posts: 2334
  • Thanks: 117
  • Karma: 13
7 years 1 month ago #297656 by activha
Replied by activha on topic CB gallery image rotation
Either I'm tired or just dumb, but can you tell me where to deactivate client side resizing ?? :S

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48536
  • Thanks: 8290
  • Karma: 1445
7 years 1 month ago - 7 years 1 month ago #297659 by krileon
Replied by krileon on topic CB gallery image rotation
Globally it can be disabled within CB Gallery > Parameters > Photos > Validation. But like I said there is manual rotating built into the modal windows. It's not really necessary to give up this functionality, which makes it possible to upload from mobile devices without burning through data since it's resized by the phone before upload. All you have to do is open the modal window of a photo you uploaded and you can rotate it from the menu.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
Last edit: 7 years 1 month ago by krileon.

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum