$img->read(data => $data) or die; or $img->write(data => \$data, type => $type) or die;