public function save($destfilename = null, $mime_type = null)
{
$saved = $this->_save($this->image, $destfilename, $mime_type);
if (!is_wp_error($saved)) {
$this->file = $saved['path'];
$this->mime_type = $saved['mime-type'];
try {
$this->image->setImageFormat(strtoupper($this->get_extension($this->mime_type)));
} catch (Exception $e) {
return new WP_Error('image_save_error', $e->getMessage(), $this->file);
}
}
return $saved;
}
/** * It's expected that we can't save image uses imagick built in, as * the undlaying system library can't write to the "s3://" filesystem. * */ public function test_save_image_with_inbuilt_fails() { $upload_dir = wp_upload_dir(); $path = $upload_dir['basedir'] . '/canola.jpg'; copy($this->image_path, $path); $image_editor = new WP_Image_Editor_Imagick($path); $image_editor->load(); $status = $image_editor->save($upload_dir['basedir'] . '/canola-100x100.jpg'); $this->assertWPError($status); }