note 103657 added to function.imagecreatefromjpeg
| From: | JrnBerkefeld at osu1 dot php dot net | Date: | Tue, 26 Apr 2011 18:08:41 +0000 |
| Subject: | note 103657 added to function.imagecreatefromjpeg | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-179171@lists.php.net to get a copy of this message | ||
I encountered a very strange behaviour:
The background:
Each time users uploaded images, the original file was stored along with a thumbnail and a medium
sized version for small-sized slideshows.
that means that on upload all of these original images were acknowledged by php as valid jpg
The change:
I created a new slideshow script that featured full-screen display. My old "medium-sized"
version were only about 600px wide which caused them to luck all ugly after stretching that to
modern screen sizes.
--> I created a small script that opens all original images and saves bigger
"medium-sized" versions than the once I had.
the problem:
for some reason about 1/3 of all images (not the last third but always the same images) were now
labeled as "... is not a valid JPEG file ..." by php
the cause:
still unknown
the solution:
<?php
...
$src_img = @imagecreatefromjpeg($myJPGfile_relative);
if (!$src_img) {
$src_img = LoadJPEG("http://domain.com/".$myJPGfile);
}
?>
Each time the local approach fails the script falls back to loading the same file "from the
outside" via the below mentioned "LoadJPEG" script - big thanks to the author!
That worked even though I'm talking about the exact same file on the exact same server. The
only difference is that one time it's accessed locally and the second via port 80.
when using this, watch for correct paths relative to your script and the possibly different path
relative to your domain.
----
Server IP: 69.147.83.197
Probable Submitter: 85.178.176.130
----
Manual Page -- http://www.php.net/manual/en/function.imagecreatefromjpeg.php
Edit -- https://master.php.net/note/edit/103657
Del: integrated -- https://master.php.net/note/delete/103657/integrated
Del: useless -- https://master.php.net/note/delete/103657/useless
Del: bad code -- https://master.php.net/note/delete/103657/bad+code
Del: spam -- https://master.php.net/note/delete/103657/spam
Del: non-english -- https://master.php.net/note/delete/103657/non-english
Del: in docs -- https://master.php.net/note/delete/103657/in+docs
Del: other reasons-- https://master.php.net/note/delete/103657
Reject -- https://master.php.net/note/reject/103657
Search -- https://master.php.net/manage/user-notes.php