[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!
Get Involved
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 »

Update. Well I just managed to fix it!

I implemented this change to /phpbb/plupload/plupload.php (around line 269):

From

Code: Select all

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

Code: Select all

'resize: {width: %d, height: %d, quality: 85,preserve_headers: false},',
Previously this edit did nothing for me. Now, with the new version of plupload it works. Image is correctly orientated according to EXIF data and then the EXIF data is then stripped. 8-)
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

Thank you for your valuable contribution, I will take into account your feedback once I return to this code. :)
🆓 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 confirm it. With new plupload 2.3.6 and this fix everything seems to work good.
Good job gentlemens!
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 Nov 09, 2018 12:25 pm As noted in the other thread, the update to plupload v.2.3.6 didn't resolve image rotation for me. In the ACP, I have thumbnails turned off and max image dimensions to 1440x900. With the previous version of plupload that ships with phpBB (v.2.3.3), attachments wouldn't rotate and EXIF would be stripped. With new version of plupload, EXIF data is retained including orientation data. Within phpBB, the image won't rotate, but it will display correctly if you open the image in a new tab or image display application.

I'm thinking that because EXIF data is retained with new plupload, this extension might work even with images that are reduced in size (since the extension would actually have orientation flags to know how to rotate the image)?
Probably yes. If you have some spare time please check it yourself and report.
I will take care of test everything when I get back to this, including the "fix" above, which is more a "hack" than anything else.. though.

Sorry guys but I am busy on a bunch of prioritised projects at the moment. :)
🆓 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
benwtf
Registered User
Posts: 6
Joined: Mon Nov 05, 2018 10:52 pm

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

Post by benwtf »

Testing with an image provided by a user who complained, I was able to use this extension with max dimensions set in attachments with no code modifications in 3.2.4.

Thank you!
wojtek64
Registered User
Posts: 4
Joined: Mon Feb 06, 2017 8:30 am
Name: Wojtek Musiał

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

Post by wojtek64 »

Very nice extention!

I reading code and have suggestion:
First check exif tag of orientation in file, and load picture to memory only when modification is needed.
In actuall version, picture is loaded to memory for all JPG's!
Wojtek Musiał
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 »

wojtek64 wrote: Sun Dec 16, 2018 7:09 am First check exif tag of orientation in file, and load picture to memory only when modification is needed.
In actuall version, picture is loaded to memory for all JPG's!
This is what the event in use has to offer.

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
	 */
As you can see the file has been already uploaded when I am working with it.

Hence I check for ...

Code: Select all

		if ($is_image)
		{
			/* Only JPEG supported so far */
			if ( function_exists('exif_read_data') && ($filedata['mimetype'] == 'image/jpeg') )
			{
				$this->image_orient($dest_file);
			}
			else
			{
				return;
			}
		}
Hope is all clear now. :)
🆓 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
wojtek64
Registered User
Posts: 4
Joined: Mon Feb 06, 2017 8:30 am
Name: Wojtek Musiał

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

Post by wojtek64 »

In this place is OK.
I think about this, in body of function exit_image_rotation.
Move load image to memory after checking Orientation and setting needed image manipulation, like below:

Code: Select all

protected function image_orient($dest_file)
{
	$a_exif = @exif_read_data($dest_file);
	if (isset($a_exif['Orientation']))
		{
			switch($a_exif['Orientation'])
			{
				/* Horizontal flip */
				case 2:
				/* Vertical flip */
				case 4:
				/* Vertical flip & 90° rotate clockwise */
				case 5:
				/* Horizontal flip & 90° rotate counter clockwise */
				case 7:
					$b_flip = true;
				break;

				default:
					$b_flip = false;
				break;
			}

			switch( $a_exif['Orientation'] )
			{
				/* 180° rotate */
				case 3:
				/* Vertical flip */
				case 4:
					$i_rotate = 180;
				break;

				/* Vertical flip & 90° rotate clockwise */
				case 5:
				/* 90° rotate clockwise */
				case 8:
					$i_rotate = 90;
				break;

				/* 90° rotate counter clockwise */
				case 6:
				/* Horizontal flip & 90° rotate counter clockwise */
				case 7:
					$i_rotate = -90;
				break;

				default:
					$i_rotate = 0;
				break;
			}
			if ($b_flip || $i_rotation) {
				/* For some this may be of help */
				@ini_set('memory_limit', '256M');

				/* Only JPEG supported so far */
				$orient_dest = imagecreatefromjpeg($dest_file);

				if ($b_flip)
				{
					imageflip( $orient_dest, IMG_FLIP_HORIZONTAL );
				}

				if ($i_rotate)
				{
					$orient_dest = imagerotate($orient_dest, $i_rotate, 0);
				}

				/**
				 * Using 100 means double/triple the original filesize.
				 * Default it is 95 by installation.
				 */
				imagejpeg($orient_dest, $dest_file, (int) $this->config['threedi_exir_percent']);

				/* Free memory */
				imagedestroy($orient_dest);
			}
		}
	}
Wojtek Musiał
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 »

I see what you mean. Makes sense at a first read, to be tested.
I will give to it a shot for the next version, there are other things I have to add/modify here as well.

Thanks for feedback. :)
🆓 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
Hervé
Registered User
Posts: 571
Joined: Tue Jun 04, 2019 7:51 am
Location: Belgium
Name: Rudy

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

Post by Hervé »

Hi,
I downoaded the extension which seems to work.
Is there an official release ?
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 »

Hervé wrote: Tue Jun 18, 2019 8:54 am Hi,
I downoaded the extension which seems to work.
Is there an official release ?
I officially declare that this release is the only one that exists. :)
🆓 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
Hervé
Registered User
Posts: 571
Joined: Tue Jun 04, 2019 7:51 am
Location: Belgium
Name: Rudy

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

Post by Hervé »

Thanks, but is still Alpha, Can I use it without problem ?
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 »

Hervé wrote: Wed Jun 19, 2019 7:58 am Thanks, but is still Alpha, Can I use it without problem ?
Will be raised to Beta soon.

As a thumbs of rule is nobody should use extensions in development on a production site, if something goes wrong basically you are on your own.
This doesn't means there are known issues here, the code as it is doesn't present potential solar flares/flaires AFAIK. :geek:

It is a good habit though, to have a test bed where to try these out and be so gentle to feedback the authors. Right or wrong. :)
🆓 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
Bernd R.
Registered User
Posts: 28
Joined: Fri Feb 06, 2015 5:01 pm

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

Post by Bernd R. »

Requirements: phpBB => 3.2.2, PHP => 5.5, PHP extension 'exif'.
Can`t find the extention 'exif'... :(
A big thank you to all the people, spending time to keep phpBB running
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 »

Bernd R. wrote: Sat Sep 21, 2019 1:11 pm
Requirements: phpBB => 3.2.2, PHP => 5.5, PHP extension 'exif'.
Can`t find the extention 'exif'... :(
Ask your host. ;)
🆓 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

Return to “Extensions in Development”