[3.2][3.3][ALPHA] EXIR - Exif Image Rotation 📸

A place for Extension Authors to post and receive feedback on Extensions still in development. No Extensions within this forum should be used within a live environment!
Anti-Spam Guide
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

IMPORTANT: Extensions Development rules

IMPORTANT FOR NEEDED EVENTS!!!
If you need an event for your extension please read this for the steps to follow to request the event(s)
KYPREO
Registered User
Posts: 392
Joined: Fri Feb 02, 2018 9:56 am

Re: [3.2][ALPHA] EXIR - Exif Image Rotation

Post by KYPREO »

Excellent. Thanks I will have some images from my Samsung 9 which I know do not rotate correctly on vanilla phpBB 3.2.2
phpBB user since 2002
www.AusRotary.com
User avatar
3Di
I've Been Banned!
Posts: 17538
Joined: Mon Apr 04, 2005 11:09 pm
Location: I'm with Ukraine 🇺🇦
Name: Marco

Re: [3.2][ALPHA] EXIR - Exif Image Rotation

Post by 3Di »

KYPREO wrote: Fri Jun 29, 2018 12:02 am Excellent. Thanks I will have some images from my Samsung 9 which I know do not rotate correctly on vanilla phpBB 3.2.2
You may start from here: http://owl.phy.queensu.ca/~phil/exiftool/ or the GUI http://u88.n24.queensu.ca/~bogdan/

If your image doesn't have the 'Orientation' Exif's metadata this extension can't rotate it.

You will be able to modify it's metadata in order to reach that goal using this extension.

Image
🆓 Free support for our extensions also provided here: phpBB Studio
🚀 Looking for a specific feature or alternative option? We will rock you!
Please PM me only to request paid works. Thx. Buy me a coffee -> Image
My development's activity º PhpStorm's proud user º Extensions, Scripts, MOD porting, Update/Upgrades
Andimp3
Registered User
Posts: 12
Joined: Tue Feb 13, 2018 7:47 pm

Re: [3.2][ALPHA] EXIR - Exif Image Rotation

Post by Andimp3 »

KYPREO wrote: Thu Jun 28, 2018 11:23 pmThe ideal fix for this would be to have rotate icon next to attachments or inline attachments in the preview window, allowing the user to see the orientiation error and fix it in the post itself.
In my opinion, this would be the optimal solution to the problem.
User avatar
Mick
Support Team Member
Support Team Member
Posts: 26874
Joined: Fri Aug 29, 2008 9:49 am

Re: [3.2][ALPHA] EXIR - Exif Image Rotation

Post by Mick »

Andimp3 wrote: Fri Jun 29, 2018 6:14 am
KYPREO wrote: Thu Jun 28, 2018 11:23 pmThe ideal fix for this would be to have rotate icon next to attachments or inline attachments
In my opinion, this would be the optimal solution to the problem.
Agreed, you should make an extension request. I’m not certain about optimal though, there may be better ideas turn up.
  • "The more connected we get the more alone we become” - Kyle Broflovski© 🇬🇧
User avatar
3Di
I've Been Banned!
Posts: 17538
Joined: Mon Apr 04, 2005 11:09 pm
Location: I'm with Ukraine 🇺🇦
Name: Marco

Re: [3.2][ALPHA] EXIR - Exif Image Rotation

Post by 3Di »

Andimp3 wrote: Fri Jun 29, 2018 6:14 am
KYPREO wrote: Thu Jun 28, 2018 11:23 pmThe ideal fix for this would be to have rotate icon next to attachments or inline attachments in the preview window, allowing the user to see the orientiation error and fix it in the post itself.
In my opinion, this would be the optimal solution to the problem.
That would be the natural fallback for those imgs which don't have an exif 'Orientation' flag in the metadata.
As I explained in my above posts the extension - as it is now - it works only if that bit extra is present.

I agree that, for completeness (features), this extension needs a such implementation...
... that's why the Jquery/Ajax code it is - as of now - under testing in my local environment. :)

C'mon testers, if any, I am still waiting for someone who will be so brave to post a link to an archive to download and use for testing. :geek:

Please do not overkill this topic with posted images, there is not really the need of it, I need not manipulated images.
🆓 Free support for our extensions also provided here: phpBB Studio
🚀 Looking for a specific feature or alternative option? We will rock you!
Please PM me only to request paid works. Thx. Buy me a coffee -> Image
My development's activity º PhpStorm's proud user º Extensions, Scripts, MOD porting, Update/Upgrades
User avatar
lopoto
Registered User
Posts: 111
Joined: Thu Feb 12, 2015 3:13 pm

Re: [3.2][ALPHA] EXIR - Exif Image Rotation

Post by lopoto »

So far, he's working well ,sometimes the photos from the iphone were bad, now I checked a few photos and all were as it should be. So thx 3Di for you work .
User avatar
3Di
I've Been Banned!
Posts: 17538
Joined: Mon Apr 04, 2005 11:09 pm
Location: I'm with Ukraine 🇺🇦
Name: Marco

Re: [3.2][ALPHA] EXIR - Exif Image Rotation

Post by 3Di »

lopoto wrote: Fri Jun 29, 2018 11:22 pm So far, he's working well ,sometimes the photos from the iphone were bad, now I checked a few photos and all were as it should be. So thx 3Di for you work .
Great! :)
Could you please tell us which iPhone/model has been used there?
🆓 Free support for our extensions also provided here: phpBB Studio
🚀 Looking for a specific feature or alternative option? We will rock you!
Please PM me only to request paid works. Thx. Buy me a coffee -> Image
My development's activity º PhpStorm's proud user º Extensions, Scripts, MOD porting, Update/Upgrades
User avatar
3Di
I've Been Banned!
Posts: 17538
Joined: Mon Apr 04, 2005 11:09 pm
Location: I'm with Ukraine 🇺🇦
Name: Marco

Re: [3.2][ALPHA] EXIR - Exif Image Rotation

Post by 3Di »

Teh Online Tool to use to check for free if your image contains the 'Orientation' Exif metadata: https://www.get-metadata.com/
🆓 Free support for our extensions also provided here: phpBB Studio
🚀 Looking for a specific feature or alternative option? We will rock you!
Please PM me only to request paid works. Thx. Buy me a coffee -> Image
My development's activity º PhpStorm's proud user º Extensions, Scripts, MOD porting, Update/Upgrades
User avatar
thecoalman
Community Team Member
Community Team Member
Posts: 6432
Joined: Wed Dec 22, 2004 3:52 am
Location: Pennsylvania, U.S.A.

Re: [3.2][ALPHA] EXIR - Exif Image Rotation

Post by thecoalman »

Does this work with Imagmacick? If you wanted to add this for ImageMagick hardcoding it is pretty easy. As far as including in extension I have no clue but I figured this might be helpful if you wanted to do it if the extension doesn't already support it. ;)

On line 564 of includes/functions_posting.php, you only need to add the -auto-orient flag.

Find:

Code: Select all

		@passthru(escapeshellcmd($config['img_imagick']) . 'convert' . ((defined('PHP_OS') && preg_match('#^win#i', PHP_OS)) ? '.exe' : '') . ' -quality 85 -geometry ' . $new_width . 'x' . $new_height . ' "' . str_replace('\\', '/', $source) . '" "' . str_replace('\\', '/', $destination) . '"');
Replace with:

Code: Select all

		@passthru(escapeshellcmd($config['img_imagick']) . 'convert' . ((defined('PHP_OS') && preg_match('#^win#i', PHP_OS)) ? '.exe' : '') . ' -auto-orient -quality 85 -geometry ' . $new_width . 'x' . $new_height . ' "' . str_replace('\\', '/', $source) . '" "' . str_replace('\\', '/', $destination) . '"');
“Results! Why, man, I have gotten a lot of results! I have found several thousand things that won’t work.”

Attributed - Thomas Edison
User avatar
3Di
I've Been Banned!
Posts: 17538
Joined: Mon Apr 04, 2005 11:09 pm
Location: I'm with Ukraine 🇺🇦
Name: Marco

Re: [3.2][ALPHA] EXIR - Exif Image Rotation

Post by 3Di »

thecoalman wrote: Sun Jul 01, 2018 11:07 am Does this work with Imagmacick?
Let me test it for you. :geek:

Image

I bet you know the image below - ref.: viewtopic.php?p=14802971#p14802971

As you can see the image has been automatically horizontally flipped as well, not only rotated.
The 'Rotation' metadata of your image is as follows: Mirror horizontal and rotate 270 CW
More on https://www.get-metadata.com/file-info/orientation

Image

On a side note my phpBB 3.2.2 test-bed is vanilla. The modification you posted is just for to create thumbnails, btw.
🆓 Free support for our extensions also provided here: phpBB Studio
🚀 Looking for a specific feature or alternative option? We will rock you!
Please PM me only to request paid works. Thx. Buy me a coffee -> Image
My development's activity º PhpStorm's proud user º Extensions, Scripts, MOD porting, Update/Upgrades
KYPREO
Registered User
Posts: 392
Joined: Fri Feb 02, 2018 9:56 am

Re: [3.2][ALPHA] EXIR - Exif Image Rotation

Post by KYPREO »

I tested images which were taken with a Samsung 7 Edge and Samsung 9 plus in portrait orientation and the EXIF data includes Rotate 90 CW. I took another upside down and in portrait and it embedded the tag Rotate 270 CW.

Without reading EXIF data, phpBB see these as taken in landscape (or upside down). In other words, this extension should work for Samsung too!
phpBB user since 2002
www.AusRotary.com
User avatar
3Di
I've Been Banned!
Posts: 17538
Joined: Mon Apr 04, 2005 11:09 pm
Location: I'm with Ukraine 🇺🇦
Name: Marco

Re: [3.2][ALPHA] EXIR - Exif Image Rotation

Post by 3Di »

Thank you for feedback!

Should work with any image which contains the Exif metadata ['Orientation'], it doesn't matter which device it's used when the img was created.

The destination IMG will be manipulated using memory resources, image rotation might fail because of needing much memory, in the code I put a ini_set max memory to 256M at function's runtime. Depending on server's settings though it could fail, in the next version that logic will be improved a bit, first checking if that memory limit is already set to =< 256M so to don't interfere with greater settings. Then providing a meaningful error handling for such cases.

The outcome is always a re-encoded picture, which means no (quality) lossless operation is involved.
As per default the quality is set to 95 (a config in the DB which will be manageable in ACP for the next version) , which preserves the filesize (more or less) bringing you a decent image quality, good I can say.

All of the Exif metadata will be stripped with this operation.

The new feature Jquery/Ajax to rotate every img with no Exif metadata ['Orientation'] will be present as well.

Now I am involved on custom works which have priorities, therefore at the moment that's it. :)
🆓 Free support for our extensions also provided here: phpBB Studio
🚀 Looking for a specific feature or alternative option? We will rock you!
Please PM me only to request paid works. Thx. Buy me a coffee -> Image
My development's activity º PhpStorm's proud user º Extensions, Scripts, MOD porting, Update/Upgrades
User avatar
thecoalman
Community Team Member
Community Team Member
Posts: 6432
Joined: Wed Dec 22, 2004 3:52 am
Location: Pennsylvania, U.S.A.

Re: [3.2][ALPHA] EXIR - Exif Image Rotation

Post by thecoalman »

3Di wrote: Sun Jul 01, 2018 2:16 pmLet me test it for you.
Is it using Imagemagick for manipulation? The reason i ask is I've found the thumbnails created using Imagemagick superior to GD.
The modification you posted is just for to create thumbnails, btw.
I deal with the full size images client side with minor edit to phpbb/plupload/plupload.php however that would fail if the user does not have JS enabled. The image is already rotated by the time it gets posted and the edit for Imagemagick I posted above should only come into play if JS is disabled.

Not sure if you would be able to manipulate this with this extension but doing it client side is preferable because of the RAM issue. On line 270 you need to set the preserve headers tag to false which rotates the image and strips the EXIF info. Big notation is this doesn't work with the current version of plupload utilized by phpBB. I'm using it successfully with 2.3.6.

Code: Select all

				'resize: {width: %d, height: %d, quality: 85, preserve_headers: false},',		

Code: Select all

The destination IMG will be manipulated using memory resources, image rotation might fail because of needing much memory, in the code I put a ini_set max memory to 256M at function's runtime. Depending on server's settings though it could fail, in the next version that logic will be improved a bit, first checking if that memory limit is already set to =< 256M so to don't interfere with greater settings. Then providing a meaningful error handling for such cases. 
If I recall correctly when using GD for really large images of 12MP I may have had the memory set in the script to 512. GD decompresses the image hence the reason it requires so much memory.

The new feature Jquery/Ajax to rotate every img with no Exif metadata ['Orientation'] will be present as well.
This would be available for edits? That by itself would be reason enough for me to install it so i could easily fix the hundreds of older images as I come across them.
“Results! Why, man, I have gotten a lot of results! I have found several thousand things that won’t work.”

Attributed - Thomas Edison
User avatar
3Di
I've Been Banned!
Posts: 17538
Joined: Mon Apr 04, 2005 11:09 pm
Location: I'm with Ukraine 🇺🇦
Name: Marco

Re: [3.2][ALPHA] EXIR - Exif Image Rotation

Post by 3Di »

thecoalman wrote: Mon Jul 02, 2018 11:59 am I deal with the full size images client side with minor edit to plupload/plupload.php however that would fail if the user does not have JS enabled. The image is already rotated by the time it gets posted and the edit for Imagemagick I posted above should only come into play if JS is disabled
As I previously said
3Di wrote: Thu Jun 28, 2018 11:39 pm ... this extension uses an event which does the job before of that, where the image have to be posted/stored, still.
and no need of JS, that's PHP.

Code: Select all

		/**
		 * Event to modify uploaded file before submit to the post
		 *
		 * @event core.modify_uploaded_file
		 * @var	array	filedata	Array containing uploaded file data
		 * @var	bool	is_image	Flag indicating if the file is an image
		 * @since 3.1.0-RC3
		 */
		$vars = array(
			'filedata',
			'is_image',
		);
		extract($this->phpbb_dispatcher->trigger_event('core.modify_uploaded_file', compact($vars)));
		$this->file_data = $filedata;
		unset($filedata);

		// Check for attachment quota and free space
		if (!$this->check_attach_quota() || !$this->check_disk_space())
		{
			return $this->file_data;
		}

		// Create Thumbnail
		$this->create_thumbnail();
thecoalman wrote: Mon Jul 02, 2018 11:59 am Is it using Imagemagick for manipulation? The reason i ask is I've found the thumbnails created using Imagemagick superior to GD.
To be more precise, the image will be rotated prior of the native create_thumbnail()'s execution (see above code, the last line), which will use ImageMagik if it is present (active), yes.
thecoalman wrote: Mon Jul 02, 2018 11:59 am If I recall correctly when using GD for thumbnails for really large images of 12MP I may have had the memory set in the script to 512.
You can change that value here https://github.com/3D-I/phpBB-Exif-Imag ... er.php#L85 - at the moment is hard-coded.
thecoalman wrote: Mon Jul 02, 2018 11:59 am
The new feature Jquery/Ajax to rotate every img with no Exif metadata ['Orientation'] will be present as well.
This would be available for edits? That by itself would be reason enough for me to install it so i could easily fix the hundreds of older images as I come across them.
That's a bonus not really the reason for what this extension has been made for, but.. for any other questions/request like plupload.php and what not yet discussed/implemented here, pls consider to use the tracker located here https://github.com/3D-I/phpBB-Exif-Imag ... new/choose - so that I can keep tracks of all at a glance.

Enough said, you can try it and in case you have issues report here.
🆓 Free support for our extensions also provided here: phpBB Studio
🚀 Looking for a specific feature or alternative option? We will rock you!
Please PM me only to request paid works. Thx. Buy me a coffee -> Image
My development's activity º PhpStorm's proud user º Extensions, Scripts, MOD porting, Update/Upgrades
User avatar
tojag
Registered User
Posts: 422
Joined: Thu Aug 07, 2014 8:00 am
Location: Warsaw, Poland, EU
Name: Gregory

Re: [3.2][ALPHA] EXIR - Exif Image Rotation

Post by tojag »

I am testing it in my test environment xampp, php7.1.7
The first image from this post display correct!
Image from iPad mini 4. Orientation saved in EXIF: Right-Top;
Thanks for this extension!

My production server works with php7.2. I think it should works.

Early I tried this:

Code: Select all

@passthru(escapeshellcmd($config['img_imagick']) . 'convert' . ((defined('PHP_OS') && preg_match('#^win#i', PHP_OS)) ? '.exe' : '') . ' -auto-orient -quality 85 -resize 600' . ' "' . str_replace('\\', '/', $source) . '" "' . str_replace('\\', '/', $destination) . '"');
on my production server but without positive effect.

Return to “Extensions in Development”