File tree Expand file tree Collapse file tree 2 files changed +22
-8
lines changed Expand file tree Collapse file tree 2 files changed +22
-8
lines changed Original file line number Diff line number Diff line change @@ -111,15 +111,19 @@ public function open($source = null)
111
111
'Source must be a string (file path) '
112
112
);
113
113
}
114
+
114
115
$ source = ($ source ) ? $ source : $ this ->source ();
115
116
$ this ->resetTmp ();
116
117
if (!file_exists ($ source )) {
117
- throw new Exception (
118
- sprintf ('File "%s" does not exist ' , $ source )
119
- );
118
+ if (null === parse_url ($ source , PHP_URL_HOST )) {
119
+ throw new Exception (
120
+ sprintf ('File "%s" does not exist ' , $ source )
121
+ );
122
+ }
120
123
}
121
- $ tmp = $ this ->tmp ();
122
- copy ($ source , $ tmp );
124
+
125
+ copy ($ source , $ this ->tmp ());
126
+
123
127
return $ this ;
124
128
}
125
129
@@ -139,13 +143,16 @@ public function save($target = null)
139
143
'Target must be a string (file path) '
140
144
);
141
145
}
146
+
142
147
$ target = ($ target ) ? $ target : $ this ->target ();
143
148
if (!is_writable (dirname ($ target ))) {
144
149
throw new Exception (
145
150
sprintf ('Target "%s" is not writable ' , $ target )
146
151
);
147
152
}
153
+
148
154
copy ($ this ->tmp (), $ target );
155
+
149
156
return $ this ;
150
157
}
151
158
Original file line number Diff line number Diff line change @@ -87,8 +87,15 @@ public function open($source = null)
87
87
'Source must be a string '
88
88
);
89
89
}
90
+
90
91
$ source = ($ source ) ? $ source : $ this ->source ();
91
- $ this ->imagick ()->readImage ($ source );
92
+ if (parse_url ($ source , PHP_URL_HOST )) {
93
+ $ handle = fopen ($ source , 'rb ' );
94
+ $ this ->imagick ()->readImageFile ($ handle );
95
+ } else {
96
+ $ this ->imagick ()->readImage ($ source );
97
+ }
98
+
92
99
return $ this ;
93
100
}
94
101
@@ -107,13 +114,13 @@ public function save($target = null)
107
114
'Target must be a string (file path) '
108
115
);
109
116
}
110
- $ target = ($ target ) ? $ target : $ this ->target ();
111
117
118
+ $ target = ($ target ) ? $ target : $ this ->target ();
112
119
$ fileExt = pathinfo ($ target , PATHINFO_EXTENSION );
113
120
114
121
$ this ->imagick ()->setImageFormat ($ fileExt );
115
-
116
122
$ this ->imagick ()->writeImage ($ target );
123
+
117
124
return $ this ;
118
125
}
119
126
You can’t perform that action at this time.
0 commit comments