Skip to content

Commit 41e2bbc

Browse files
committed
Merge pull request #46 from chrissachs/master
suppress warnings from exif_read_data if image does not contain valid exif
2 parents 8d710d4 + 13a0e09 commit 41e2bbc

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/ImageResize.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,11 @@ public function __construct($filename)
8181

8282
case IMAGETYPE_JPEG:
8383
$this->source_image = $this->imageCreateJpegfromExif($filename);
84-
84+
8585
// set new width and height for image, maybe it has changed
8686
$this->original_w = ImageSX($this->source_image);
8787
$this->original_h = ImageSY($this->source_image);
88-
88+
8989
break;
9090

9191
case IMAGETYPE_PNG:
@@ -99,16 +99,16 @@ public function __construct($filename)
9999

100100
return $this->resize($this->getSourceWidth(), $this->getSourceHeight());
101101
}
102-
102+
103103
// http://stackoverflow.com/a/28819866
104104
public function imageCreateJpegfromExif($filename){
105105
$img = imagecreatefromjpeg($filename);
106-
$exif = exif_read_data($filename);
107-
106+
$exif = @exif_read_data($filename);
107+
108108
if (!$exif || !isset($exif['Orientation'])){
109109
return $img;
110110
}
111-
111+
112112
$orientation = $exif['Orientation'];
113113

114114
if ($orientation === 6 || $orientation === 5){
@@ -122,7 +122,7 @@ public function imageCreateJpegfromExif($filename){
122122
if ($orientation === 5 || $orientation === 4 || $orientation === 7){
123123
imageflip($img, IMG_FLIP_HORIZONTAL);
124124
}
125-
125+
126126
return $img;
127127
}
128128

0 commit comments

Comments
 (0)