File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -147,6 +147,9 @@ function removeMetadata(){
147
147
return $ this ->setOption ('--strip ' );
148
148
}
149
149
150
+ /**
151
+ * Run the built command
152
+ */
150
153
function execute (){
151
154
$ consoleInstruction = $ this ->buildCommand ();
152
155
$ output = null ;
@@ -155,4 +158,28 @@ function execute(){
155
158
156
159
return $ output ;
157
160
}
161
+
162
+ /**
163
+ * Execute PNGQUANT with the providen commands and retrieve the generated image
164
+ * directly into a variable
165
+ */
166
+ // Create a temporal file in the system
167
+ $ fileName = uniqid ().'.png ' ;
168
+ $ temp_file = tempnam (sys_get_temp_dir (), $ fileName );
169
+
170
+ // Set the output path the tmp file
171
+ $ this ->setOutputImage ($ temp_file );
172
+
173
+ $ consoleInstruction = $ this ->buildCommand ();
174
+
175
+ $ output = null ;
176
+
177
+ system($ consoleInstruction , $ output );
178
+
179
+ return array(
180
+ 'statusCode ' => $ output ,
181
+ 'tempFile ' => $ temp_file ,
182
+ 'imageData ' => file_get_contents($ temp_file )
183
+ );
184
+ }
158
185
}
You can’t perform that action at this time.
0 commit comments