Error with Picture resulotion on Upload

Get help with installation and running phpBB 3.2.x here. Please do not post bug reports, feature requests, or extension related questions here.
Sycend
Registered User
Posts: 15
Joined: Fri Apr 25, 2014 5:03 pm

Error with Picture resulotion on Upload

Post by Sycend »

Hello

i observed a strange thing on my server:
If I upload a picture for a avatar or as a attachment in a post. Witch I reduced in size with paint to under 150px x 150px. I get this Error message with the original resolution:
The submitted avatar is 2507 pixels wide and 3987 pixels high. Avatars must be at least 20 pixels wide and 20 pixels high, but no larger than 150 pixels wide and 150 pixels high.
Even windows tell me it’s just 150px to 150px.

Next strange thing, on my other server I have the same problems, but the numbers don't show at all:
The submitted avatar is pixels wide and pixels high. Avatars must be at least pixels wide and pixels high, but no larger than pixels wide and pixels high.
Any idea, are the wrong meta data pf the picture read out?
(Problem still exist when all ext are disabled)
User avatar
janus_zonstraal
Registered User
Posts: 6427
Joined: Sat Aug 30, 2014 1:30 pm

Re: Error with Picture resulotion on Upload

Post by janus_zonstraal »

Do you have a link to the avatar?
Sorry! My English is bat ;) !!!
Sycend
Registered User
Posts: 15
Joined: Fri Apr 25, 2014 5:03 pm

Re: Error with Picture resulotion on Upload

Post by Sycend »

Here this is my testfile:
https://1drv.ms/i/s!Aqgv-WgtZ6Qok_1LKN9xfrWREpFXXA
(just a onedrive link)
Sycend
Registered User
Posts: 15
Joined: Fri Apr 25, 2014 5:03 pm

Re: Error with Picture resulotion on Upload

Post by Sycend »

I tested it on the phpbb.com Forum, it doesn't work as well if you resize pictures in paint or other programms.

To the second problem (dimensions arn't displayed) does anyone know what is failing? The Board runs on an upgraded version from 3.0->3.2
Unbenannt.PNG
User avatar
AmigoJack
Registered User
Posts: 6113
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: Error with Picture resulotion on Upload

Post by AmigoJack »

There are multiple problems:
  1. The picture itself is correct, but has EXIF data which seems to be from the original file, not this 150x150px version. EXIF data is (amongst other):

    Code: Select all

    Image width: 		2507 					(Exif 0100 0)
    Image length: 		3987 					(Exif 0101 0)
    Camera Manufacturer: 	Canon 					(Exif 010F 0)
    Camera Model: 		Canon EOS 1100D 			(Exif 0110 0)
    Software: 		Windows Photo Editor 10.0.10011.16384 	(Exif 0131 0)
    Date modified: 		2017:10:14 17:05:38 			(Exif 0132 0)
    Date taken: 		2015:09:12 10:14:55 			(Exif 9003 Main)
    EXIF image width: 	2507 					(Exif A002 Main)
    EXIF image length: 	3987 					(Exif A003 Main)
  2. phpBB wants to be smart at detecting the dimensions, but fails (again). It trusts the EXIF data more than the SOF0 segment, although the latter correctly tells us width and height and is more trustworthy. This comes from /vendor/marc1706/fast-image-size/lib/Type/TypeJpeg.php which has a wrong order of checks:

    Code: Select all

    	protected function getSizeInfo()
    	{
    		...
    		for ($i = 0; $i < $dataLength; $i++)
    		{
    			...
    			$size = $this->checkExifData($i);
    
    			if (count($size) > 0)
    			{
    				break;
    			}
    
    			if ($this->isSofMarker($this->data[$i], $this->data[$i + 1]))
    			{
  3. Avoid software which breaks JPEG standards and/or mistreats EXIF data (anything from Adobe, which can be seen in the XMP metadata:

    Code: Select all

    <?xpacket begin="" id="W5M0MpCehiHzreSzNTczkc9d"?>
    	<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Adobe XMP Core 5.0-c060 61.134777, 2010/02/12-17:32:00        ">
    		<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
    			<rdf:Description rdf:about="" ...>
    				<xmpMM:History>
    					<rdf:Seq>
    						<rdf:li stEvt:action="derived" stEvt:parameters="converted from image/x-canon-cr2 to image/jpeg, saved to new location"/>
    						<rdf:li stEvt:action="saved" stEvt:instanceID="xmp.iid:2CD39D4E55A7E511ACC4885E12A0D126" stEvt:when="2015-12-20T21:07:33+01:00" stEvt:softwareAgent="Adobe Photoshop Camera Raw 6.7 (Windows)" stEvt:changed="/"/>
    						<rdf:li stEvt:action="saved" stEvt:instanceID="xmp.iid:33FE88E658A7E511A317FE6AB61570D8" stEvt:when="2015-12-20T21:33:17+01:00" stEvt:softwareAgent="Adobe Photoshop CS5 Windows" stEvt:changed="/"/>
    						<rdf:li stEvt:action="saved" stEvt:instanceID="xmp.iid:34FE88E658A7E511A317FE6AB61570D8" stEvt:when="2015-12-20T21:33:17+01:00" stEvt:softwareAgent="Adobe Photoshop CS5 Windows" stEvt:changed="/"/>
    					</rdf:Seq>
    				</xmpMM:History>
    
If you want to "repair" your picture then
  1. Open it in your favorite image editor (mostly thru CTRL+O), then either
    1. copy it to the clipboard (the picture's 150x150px canvas, not the file - this means to most editors CTRL+A, then CTRL+C),
    2. create a new file with the same dimensions (mostly CTRL+N),
    3. paste your clipboard content (mostly CTRL+V),
    4. save the file (mostly CTRL+S).
  2. ...or save the file in a different format (PNG, GIF, BMP...).
That way the metadata will not be copied (in case you choose JPEG as format again you'll notice a big difference in the filesize) and phpBB will finally recognize the correct dimensions.

Proof:
asd2.jpg
asd2.jpg (11.73 KiB) Viewed 2113 times
  • "The problem is probably not my English but you do not want to understand correctly. ... We will not come anybody anyway, nevertheless, it's best to shit this." Affin, 2018-11-20
  • "But this shit is not here for you. You can follow with your. Maybe the question, instead, was for you, who know, so you shoved us how you are." axe70, 2020-10-10
  • "My reaction is not to everyone, especially to you." Raptiye, 2021-02-28
mrix2000
Registered User
Posts: 1207
Joined: Sun Dec 03, 2006 2:23 pm

Re: Error with Picture resulotion on Upload

Post by mrix2000 »

That`s all very annoying as I am getting the same problem but when members are uploading post attachment images, this was not an issue for my members before 3.2.1 :?
The strange thing is I asked one of the members to send me one of the images which I uploaded from my end and all was fine :? We are both using the Windows 10 operating system.
Hopefully what ever was changed can be reverted back ?
Cheers all
mrix
Sycend
Registered User
Posts: 15
Joined: Fri Apr 25, 2014 5:03 pm

Re: Error with Picture resulotion on Upload

Post by Sycend »

Thanks alot for the detailed explenation AmigoJack. :)
Is there a workaround on server side to fix it?

Any idea about the 2nd problem? (That the error message not displayed correctly, see my last post)
User avatar
AmigoJack
Registered User
Posts: 6113
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: Error with Picture resulotion on Upload

Post by AmigoJack »

Sycend wrote: Tue Nov 14, 2017 5:28 pmIs there a workaround on server side to fix it?
Workarounds and fixes are two different things. A fix would be to use checkExifData()'s result only when isSofMarker() never led to usable results.
Sycend wrote: Tue Nov 14, 2017 5:28 pmthe 2nd problem
You didn't state your full version; 3.2.0 had even more problems recognizing JPEG files in contrast to 3.2.1. Compare actual versions.
  • "The problem is probably not my English but you do not want to understand correctly. ... We will not come anybody anyway, nevertheless, it's best to shit this." Affin, 2018-11-20
  • "But this shit is not here for you. You can follow with your. Maybe the question, instead, was for you, who know, so you shoved us how you are." axe70, 2020-10-10
  • "My reaction is not to everyone, especially to you." Raptiye, 2021-02-28
Sycend
Registered User
Posts: 15
Joined: Fri Apr 25, 2014 5:03 pm

Re: Error with Picture resulotion on Upload

Post by Sycend »

My Board runs currently at 3.2.1
User avatar
AmigoJack
Registered User
Posts: 6113
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: Error with Picture resulotion on Upload

Post by AmigoJack »

Then compare files with a default 3.2.1 installation to find differences.
  • "The problem is probably not my English but you do not want to understand correctly. ... We will not come anybody anyway, nevertheless, it's best to shit this." Affin, 2018-11-20
  • "But this shit is not here for you. You can follow with your. Maybe the question, instead, was for you, who know, so you shoved us how you are." axe70, 2020-10-10
  • "My reaction is not to everyone, especially to you." Raptiye, 2021-02-28
Lucan
Registered User
Posts: 46
Joined: Fri Jun 13, 2008 10:24 pm

Re: Error with Picture resulotion on Upload

Post by Lucan »

Same issue here, any plans to fix this?
bsdmike
Registered User
Posts: 164
Joined: Tue Mar 28, 2006 1:27 pm

Re: Error with Picture resulotion on Upload

Post by bsdmike »

I have not tried this, but is this a possible solution then?
Just move the checkExifData under the isSofMarker check as below?
(this is from /vendor/marc1706/fast-image-size/lib/Type/TypeJpeg.php)
-Mike

Code: Select all

  // Look through file for SOF marker
                for ($i = 0; $i < $dataLength; $i++)
                {
                        // Only look for EXIF and XMP app marker once, other types more often
                        if (!$this->checkForAppMarker($dataLength, $i))
                        {
                                break;
                        }

                        if ($this->isSofMarker($this->data[$i], $this->data[$i + 1]))
                        {
                                // Extract size info from SOF marker
                                list(, $unpacked) = unpack("H*", substr($this->data, $i + self::LONG_SIZE + 1, self::LONG_SIZE));

                                // Get width and height from unpacked size info
                                $size = array(
                                        'width'         => hexdec(substr($unpacked, 4, 4)),
                                        'height'        => hexdec(substr($unpacked, 0, 4)),
                                );

                                break;
                        }
                        
                        $size = $this->checkExifData($i);

                        if (count($size) > 0)
                        {
                                break;
                        }
                        
                }

                return $size;
User avatar
AmigoJack
Registered User
Posts: 6113
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: Error with Picture resulotion on Upload

Post by AmigoJack »

No.
  • "The problem is probably not my English but you do not want to understand correctly. ... We will not come anybody anyway, nevertheless, it's best to shit this." Affin, 2018-11-20
  • "But this shit is not here for you. You can follow with your. Maybe the question, instead, was for you, who know, so you shoved us how you are." axe70, 2020-10-10
  • "My reaction is not to everyone, especially to you." Raptiye, 2021-02-28
bsdmike
Registered User
Posts: 164
Joined: Tue Mar 28, 2006 1:27 pm

Re: Error with Picture resulotion on Upload

Post by bsdmike »

Is there no easy fix for this then?

Is there a known picture resizer, online or otherwise, that works properly?

(Or is the only solution to save the picture as a different type?)

-Mike
User avatar
AmigoJack
Registered User
Posts: 6113
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: Error with Picture resulotion on Upload

Post by AmigoJack »

bsdmike wrote: Mon Jan 22, 2018 11:29 ameasy fix
Well yes - just follow my instructions to change the code instead of your approach. And after that you might want to tweak the code according to Re: Problem with uploading large jpg files after update 3.2.2.
  • "The problem is probably not my English but you do not want to understand correctly. ... We will not come anybody anyway, nevertheless, it's best to shit this." Affin, 2018-11-20
  • "But this shit is not here for you. You can follow with your. Maybe the question, instead, was for you, who know, so you shoved us how you are." axe70, 2020-10-10
  • "My reaction is not to everyone, especially to you." Raptiye, 2021-02-28
Post Reply

Return to “[3.2.x] Support Forum”