[3.2][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!
Scam Warning
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: 115
Joined: Fri Feb 02, 2018 9:56 am
Contact:

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

Post by KYPREO » Fri Nov 09, 2018 12:48 pm

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
Former Team Member
Posts: 14348
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milan (IT) Frankfurt (DE)
Name: Marco
Contact:

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

Post by 3Di » Sat Nov 10, 2018 4:07 am

@ KYPREO

Thank you for your valuable contribution, I will take into account your feedback once I return to this code. :)
Please PM me only to request paid works. Thx.
Want to compensate me for my interest? Donate
My development's activity º PhpStorm's proud user
Extensions, Scripts, MOD porting, Update/Upgrades
👨‍🏫 | Take a tour to | The Studio | 👨‍🏫

User avatar
tojag
Registered User
Posts: 400
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 » Wed Nov 14, 2018 10:04 pm

I confirm it. With new plupload 2.3.6 and this fix everything seems to work good.
Good job gentlemens!
Sorry my english. I hope You understand what I mean.

User avatar
3Di
Former Team Member
Posts: 14348
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milan (IT) Frankfurt (DE)
Name: Marco
Contact:

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

Post by 3Di » Thu Nov 15, 2018 12:03 pm

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. :)
Please PM me only to request paid works. Thx.
Want to compensate me for my interest? Donate
My development's activity º PhpStorm's proud user
Extensions, Scripts, MOD porting, Update/Upgrades
👨‍🏫 | Take a tour to | The Studio | 👨‍🏫

benwtf
Registered User
Posts: 6
Joined: Mon Nov 05, 2018 10:52 pm

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

Post by benwtf » Mon Dec 03, 2018 7:11 am

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 » Sun Dec 16, 2018 7:09 am

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
Former Team Member
Posts: 14348
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milan (IT) Frankfurt (DE)
Name: Marco
Contact:

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

Post by 3Di » Sun Dec 16, 2018 3:29 pm

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. :)
Please PM me only to request paid works. Thx.
Want to compensate me for my interest? Donate
My development's activity º PhpStorm's proud user
Extensions, Scripts, MOD porting, Update/Upgrades
👨‍🏫 | Take a tour to | The Studio | 👨‍🏫

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 » Sun Dec 16, 2018 9:07 pm

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
Former Team Member
Posts: 14348
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milan (IT) Frankfurt (DE)
Name: Marco
Contact:

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

Post by 3Di » Sun Dec 16, 2018 9:13 pm

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. :)
Please PM me only to request paid works. Thx.
Want to compensate me for my interest? Donate
My development's activity º PhpStorm's proud user
Extensions, Scripts, MOD porting, Update/Upgrades
👨‍🏫 | Take a tour to | The Studio | 👨‍🏫

Hervé
Registered User
Posts: 10
Joined: Tue Jun 04, 2019 7:51 am

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

Post by Hervé » Tue Jun 18, 2019 8:54 am

Hi,
I downoaded the extension which seems to work.
Is there an official release ?

User avatar
3Di
Former Team Member
Posts: 14348
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milan (IT) Frankfurt (DE)
Name: Marco
Contact:

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

Post by 3Di » Tue Jun 18, 2019 9:32 pm

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. :)
Please PM me only to request paid works. Thx.
Want to compensate me for my interest? Donate
My development's activity º PhpStorm's proud user
Extensions, Scripts, MOD porting, Update/Upgrades
👨‍🏫 | Take a tour to | The Studio | 👨‍🏫

Hervé
Registered User
Posts: 10
Joined: Tue Jun 04, 2019 7:51 am

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

Post by Hervé » Wed Jun 19, 2019 7:58 am

Thanks, but is still Alpha, Can I use it without problem ?

User avatar
3Di
Former Team Member
Posts: 14348
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milan (IT) Frankfurt (DE)
Name: Marco
Contact:

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

Post by 3Di » Thu Jun 20, 2019 11:26 pm

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. :)
Please PM me only to request paid works. Thx.
Want to compensate me for my interest? Donate
My development's activity º PhpStorm's proud user
Extensions, Scripts, MOD porting, Update/Upgrades
👨‍🏫 | Take a tour to | The Studio | 👨‍🏫

Bernd R.
Registered User
Posts: 26
Joined: Fri Feb 06, 2015 5:01 pm

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

Post by Bernd R. » Sat Sep 21, 2019 1:11 pm

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
Former Team Member
Posts: 14348
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milan (IT) Frankfurt (DE)
Name: Marco
Contact:

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

Post by 3Di » Sat Sep 21, 2019 1:21 pm

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. ;)
Please PM me only to request paid works. Thx.
Want to compensate me for my interest? Donate
My development's activity º PhpStorm's proud user
Extensions, Scripts, MOD porting, Update/Upgrades
👨‍🏫 | Take a tour to | The Studio | 👨‍🏫

Post Reply

Return to “Extensions in Development”